Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upmethod call fails to upcast trait objects, resulting in overlong borrows #24950
Comments
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium -- annoying, but there exists a workaround |
rust-highfive
added
the
P-medium
label
Apr 29, 2015
nikomatsakis
self-assigned this
Apr 29, 2015
This comment has been minimized.
This comment has been minimized.
|
I assigned myself but have not yet actively started working on this... it occurs to me it is not entirely clear when this upcast should be done in method dispatch. Perhaps just whenever the (fully transformed) receiver is of the form The most obvious thing to do would be to wait until we've fully autoderefered to a trait object type ( |
This comment has been minimized.
This comment has been minimized.
|
Note for future people triaging this bug: there are easy modifications of @nikomatsakis 's test that exhibit the same compile failure that will not infinite loop after this is fixed; for example, this: pub trait Flow {
fn foo();
}
pub trait LayoutDamageComputation {
fn compute_layout_damage(self);
fn children(&self) -> Vec<Self>;
}
impl<'a> LayoutDamageComputation for &'a mut (Flow + 'a) {
fn compute_layout_damage(self) {
for k in self.children() {
k.compute_layout_damage();
k.compute_layout_damage();
}
}
fn children(&self) -> Vec<&'a mut (Flow + 'a)> { vec![] }
}
fn main() { } |
This comment has been minimized.
This comment has been minimized.
The work around exists, but is hardly discoverable… unless “every one ask Niko about their borrowck errors” is acceptable ;) |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin indeed. I intend to fix this soon -- it's just that I don't think it's a "stop everything" emergency (which is what we are trying to use P-High for). |
This comment has been minimized.
This comment has been minimized.
|
Ok, fair enough. |
steveklabnik
added
A-typesystem
A-lang
labels
Jul 14, 2016
brson
added
the
T-lang
label
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
triage: P-low We've gone this long w/o a fix, probably not P-medium anymore (esp b/c there's a workaround). Also removing @nikomatsakis as an assignee as I don't think this is actively being worked on. |
rust-highfive
added
P-low
and removed
P-medium
labels
Jul 14, 2016
alexcrichton
unassigned
nikomatsakis
Jul 14, 2016
steveklabnik
removed
the
A-lang
label
Mar 24, 2017
Mark-Simulacrum
added
the
C-bug
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Triage: i now get
for all cases, including the "fixed" ones. Was this bug fixed in the last two years? |
nikomatsakis commentedApr 29, 2015
•
edited by alexcrichton
@SimonSapin encountered an error in servo that I reduced to the following test case http://is.gd/w7HPbJ:
The errors you get are:
There are various possible workarounds:
but the gist (no pun intended, I kill me) is to ensure a coercion from
selfto&mut Flow, which allows us to upcast the lifetime in the trait object. The easiest way to do that is to convert the recursive callself.compute_layout_damage()to UFCS form<&mut Flow as ComputeLayoutDamage>::compute_layout_damage(self). Method dispatch ought to automatically performing this upcast, I think, must as we auto-reborrow here and there.cc @pnkfelix who experimented on this with me