Closed
Description
In #47596, @SimonSapin reported several NLL errors in dependencies of the servo crate. @Aaron1011 later minimized one of those errors into this example:
#![feature(nll)]
struct MyStruct<'a> {
field: &'a mut (),
field2: WithDrop
}
struct WithDrop;
impl Drop for WithDrop {
fn drop(&mut self) {}
}
impl<'a> MyStruct<'a> {
fn consume(self) -> &'a mut () { self.field }
}
fn main() {}
which yields:
error[E0597]: `*self.field` does not live long enough
--> src/main.rs:18:38
|
18 | fn consume(self) -> &'a mut () { self.field }
| ^^^^^^^^^^ - borrowed value only lives until here
| |
| borrowed value does not live long enough
|
= note: borrowed value must be valid for lifetime '_#3r...
Removing feature(nll) makes the code work, so probably this is an NLL bug.