Closed
Description
Code (play):
#![feature(nll)]
fn main() {
let f = |x: &i32| -> &i32 { x };
let i = &3;
let j = f(i);
}
yields:
error: lifetime may not live long enough
--> src/main.rs:4:33
|
4 | let f = |x: &i32| -> &i32 { x };
| - - ^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of closure is &'2 i32
| let's call the lifetime of this reference `'1`
but I would have expected it to use the span:
error: lifetime may not live long enough
--> src/main.rs:4:33
|
4 | let f = |x: &i32| -> &i32 { x };
| - - ^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of closure is &'2 i32
| let's call the lifetime of this reference `'1`