Closed
Description
e.g.
fn bar<'a>() -> &'a mut u32 {
&mut 4
}
Gives the following errors for AST and MIR borrowck - the MIR error should be more like the AST error
error[E0597]: borrowed value does not live long enough (Ast)
--> bar.rs:2:10
|
2 | &mut 4
| ^ does not live long enough
3 | }
| - temporary value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 1:1...
--> bar.rs:1:1
|
1 | / fn bar<'a>() -> &'a mut u32 {
2 | | &mut 4
3 | | }
| |_^
error[E0597]: borrowed value does not live long enough (Mir)
--> bar.rs:3:2
|
2 | &mut 4
| - temporary value created here
3 | }
| -^ 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