You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
19:20: 19:24 error: illegal borrow: cannot root managed value long enough
19 Some(next) => next.get(),
^~~~
17:32: 22:3 note: managed value would have to be rooted for the lifetime &self as defined on the block at 17:32...
17 pure fn get(&self) -> &self/T {
18 match self.next {
19 Some(next) => next.get(),
20 None => &self.val
21 }
22 }
17:32: 22:3 note: ...but can only be rooted for the block at 17:32
17 pure fn get(&self) -> &self/T {
18 match self.next {
19 Some(next) => next.get(),
20 None => &self.val
21 }
22 }
I think this never should have worked, since the Node struct is declared to contain a managed box. The error message isn't the clearest, but is saying the compiler doesn't know that the lifetime of the contents of a node's next field is the same as the lifetime of the contents of the node itself.
I'll check in a modified run-pass test case (where the next field contains a pointer with a lifetime annotation).
Yeah, this is working-as-intended. The associated test (which landed) shows how this needs to be written if you want to use borrowed pointers here. Closing.
I wonder if this shouldn't work?
The failure is:
https://github.com/mozilla/rust/blob/incoming/src/librustc/middle/borrowck/preserve.rs#L333
attempt_root()
expects aty::re_scope
butself.scope_region
is aty::re_free
.self.scope_region
's id is the same asself.root_ub
(root_region
's id).CC'ing @nikomatsakis because he's the borrowed pointer specialist.
The text was updated successfully, but these errors were encountered: