-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.Category: This is a bug.T-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
With 1.24.0-nightly (2017-12-21 250b492):
This compiles:
#![feature(nll)]
fn main() {
let mut vec = Vec::new();
let a = 1;
vec.push(&a);
let b = 2;
vec.push(&b);
println!("{:?}", vec);
}
But this does not:
#![feature(nll)]
fn f() {
let mut vec = Vec::new();
let a = String::from("");
vec.push(&a);
let b = String::from("");
vec.push(&b);
println!("{:?}", vec);
}
fn main() {}
error[E0597]: `a` does not live long enough
--> src/main.rs:7:14
|
7 | vec.push(&a);
| ^^ borrowed value does not live long enough
...
13 | }
| - borrowed value only lives until here
|
= note: borrowed value must be valid for lifetime '_#11r...
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.Category: This is a bug.T-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.