Closed
Description
fn foo<'a>(u: &'a usize) -> impl IntoIterator<Item = usize> + 'a {
std::thread::spawn(|| {
println!("{}", u);
});
vec![]
}
displays:
error: cannot infer an appropriate lifetime
--> src/lib.rs:2:24
|
2 | std::thread::spawn(|| {
| _____------------------_^
| | |
| | this return type evaluates to the `'static` lifetime...
3 | | println!("{}", u);
4 | | });
| |_____^ ...but this borrow...
|
note: ...can't outlive the lifetime 'a as defined on the function body at 1:8
Notice how `'static`
is surrounded in backticks, but 'a
is not.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsDiagnostics: Inconsistency in formatting, grammar or style between diagnostic messages.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.