Closed
Description
Given this test which is included in #48592 and when merged will be located here https://github.com/rust-lang/rust/tree/master/src/test/ui/nll/borrowed-local-error.rs
// compile-flags: -Znll-dump-cause
#![feature(nll)]
fn gimme(x: &(u32,)) -> &u32 {
&x.0
}
fn main() {
let x = gimme({
let v = (22,);
&v
//~^ ERROR `v` does not live long enough [E0597]
});
println!("{:?}", x);
}
With #48592 merged, the output looks like ...
[santiago@archlinux rust1 (borrowed_value_error)]$ RUST_BACKTRACE=1 rustc +stage1 src/test/ui/nll/borrowed-local-error.rs -Znll-dump-cause
error[E0597]: `v` does not live long enough
--> src/test/ui/nll/borrowed-local-error.rs:22:9
|
20 | let x = gimme({
| _____________-
21 | | let v = (22,);
22 | | &v
| | ^^ borrowed value does not live long enough
23 | | //~^ ERROR `v` does not live long enough [E0597]
24 | | });
| |_____-- borrow later used here
| |
| borrowed value only lives until here
error: aborting due to previous error
If you want more information on this error, try using "rustc --explain E0597"
@nikomatsakis said that the output should look like ...
This is what I think it should look like:
error[E0597]: `v` does not live long enough
--> borrowed-local-error.rs:20:9
|
18 | let x = gimme({
| ----- borrow later used here, during the call
19 | let v = (22,);
20 | &v
| ^^ borrowed value does not live long enough
21 | });
| - borrowed value only lives until here
Previous discussion #48592 (comment)