-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
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.P-lowLow priorityLow priorityT-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
The output of this test ...
// compile-flags: -Znll-dump-cause
#![feature(nll)]
#![allow(warnings)]
fn gimme(x: &(u32,)) -> &u32 {
&x.0
}
fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
let v = 22;
gimme(&(v,))
//~^ ERROR borrowed value does not live long enough [E0597]
}
fn main() {}
is not great
[santiago@archlinux rust1 (borrowed_value_error)]$ rustc +stage1 src/test/ui/nll/borrowed-universal-error.rs -Znll-dump-cause
error[E0597]: borrowed value does not live long enough
--> src/test/ui/nll/borrowed-universal-error.rs:22:12
|
22 | gimme(&(v,))
| ^^^^ temporary value does not live long enough
23 | //~^ ERROR borrowed value does not live long enough [E0597]
24 | }
| - temporary value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:1...
--> src/test/ui/nll/borrowed-universal-error.rs:20:1
|
20 | fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
If you want more information on this error, try using "rustc --explain E0597"
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.P-lowLow priorityLow priorityT-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.