2a3969a3f7
This gives at least some explanation for why a borrow is expected to last for a certain free region. Also: * Reports E0373: "closure may outlive the current function" with NLL. * Special cases the case of returning a reference to (or value referencing) a local variable or temporary (E0515). * Special case assigning a reference to a local variable in a closure to a captured variable.
43 lines
1.8 KiB
Plaintext
43 lines
1.8 KiB
Plaintext
error[E0597]: `c` does not live long enough
|
|
--> $DIR/adt-brace-enums.rs:37:48
|
|
|
|
|
LL | SomeEnum::SomeVariant::<&'static u32> { t: &c }; //~ ERROR
|
|
| ^^
|
|
| |
|
|
| borrowed value does not live long enough
|
|
| requires that `c` is borrowed for `'static`
|
|
LL | }
|
|
| - `c` dropped here while still borrowed
|
|
|
|
error[E0597]: `c` does not live long enough
|
|
--> $DIR/adt-brace-enums.rs:42:43
|
|
|
|
|
LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) {
|
|
| -- lifetime `'a` defined here
|
|
LL | let c = 66;
|
|
LL | SomeEnum::SomeVariant::<&'a u32> { t: &c }; //~ ERROR
|
|
| ^^
|
|
| |
|
|
| borrowed value does not live long enough
|
|
| requires that `c` is borrowed for `'a`
|
|
LL | }
|
|
| - `c` dropped here while still borrowed
|
|
|
|
error[E0597]: `c` does not live long enough
|
|
--> $DIR/adt-brace-enums.rs:52:47
|
|
|
|
|
LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) {
|
|
| -- lifetime `'a` defined here
|
|
...
|
|
LL | SomeEnum::SomeVariant::<&'a u32> { t: &c }; //~ ERROR
|
|
| ^^
|
|
| |
|
|
| borrowed value does not live long enough
|
|
| requires that `c` is borrowed for `'a`
|
|
LL | };
|
|
| - `c` dropped here while still borrowed
|
|
|
|
error: aborting due to 3 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0597`.
|