Closed
Description
e.g.:
fn foo() -> &u32 {
let x = 0;
&x
}
Gives the following error:
error[E0597]: `x` does not live long enough (Ast)
--> foo.rs:4:6
|
4 | &x
| ^ does not live long enough
5 | }
| - borrowed value only lives until here
|
= note: borrowed value must be valid for the static lifetime...
error[E0597]: borrowed value does not live long enough (Mir)
--> foo.rs:5:2
|
3 | let x = 0;
| - temporary value created here
4 | &x
5 | }
| -^ temporary value dropped here while still borrowed
| |
| temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error: aborting due to 2 previous errors
The MIR error message should be more like the AST one