-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.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
I discovered an unused lifetime in my code that the compiler didn't tell me about. I was able to reduce the problem to the following snippet.
#![warn(unused_lifetimes)]
struct Foo<'a>(for<'r> fn(&'r mut Foo<'a>));
impl<'a> Foo<'a> {
pub fn new() -> Self {
Self(Self::a)
}
pub fn a(&mut self) {}
}
fn main() {
let f = Foo::new();
drop(f);
}
The lifetime 'a is unused, but the compiler doesn't complain at all. I confirmed that it still exists on stable 1.44.1 and on nightly 1.46.0.
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.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.