-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.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
The following code:
#![feature(nll)]
struct Foo<'a>(&'a [u8]);
impl<'a> Foo<'a> {
fn make_it(&self) -> impl Iterator<Item = u8> {
self.0.iter().copied()
}
}
gives the following error:
error: lifetime may not live long enough
--> src/lib.rs:6:26
|
5 | impl<'a> Foo<'a> {
| -- lifetime `'a` defined here
6 | fn make_it(&self) -> impl Iterator<Item = u8> {
| ^^^^^^^^^^^^^^^^^^^^^^^^ opaque type requires that `'a` must outlive `'static`
|
= help: consider replacing `'a` with `'static`
Suggsting that the user change the impl to impl Foo<'static>
is usually the wrong thing to do - it's more likely that the user wants to write impl Iterator<Item = u8> + 'a
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.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.