-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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)
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.