Closed
Description
This manifests identically on stable and nightly without and with nll.
struct X;
impl X {
fn my_method<'a>(&'a self) -> impl Abc + 'a {
()
}
}
trait Abc {}
impl Abc for () {}
fn main() {
let my_struct = X;
match my_struct.my_method() {
_ => (),
}
// let _ = my_struct.my_method(); // uncommenting this makes it work
}
Errors:
error[E0597]: `my_struct` does not live long enough
--> src/main.rs:13:11
|
13 | match my_struct.my_method() {
| ^^^^^^^^^ borrowed value does not live long enough
...
17 | }
| - `my_struct` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created