Closed
Description
With the 2018 edition on nightly or #![feature(nll)]
:
fn main() {
let _v_lambda = |v: &Vec<String>| v.iter().chain(v.iter()).collect::<Vec<&String>>();
}
fn _v_fn(v: &Vec<String>) -> Vec<&String> {
v.iter().chain(v.iter()).collect::<Vec<&String>>()
}
Errors:
Compiling playground v0.0.1 (/playground)
warning: unsatisfied lifetime constraints
--> src/main.rs:2:39
|
2 | let _v_lambda = |v: &Vec<String>| v.iter().chain(v.iter()).collect::<Vec<&String>>();
| - - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
| | return type of closure is std::vec::Vec<&'2 std::string::String>
| let's call the lifetime of this reference `'1`
|
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
It represents potential unsoundness in your code.
This warning will become a hard error in the future.
Finished dev [unoptimized + debuginfo] target(s) in 0.55s
Running `target/debug/playground`
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: Closures (`|…| { … }`)Area: Type inferenceArea: Lifetimes / regionsWorking towards the "valid code works" goalMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.