Fix lifetimes elision suggestion in where clauses (#13752)

Fix #13749

changelog: [`needless_lifetimes`]: do not suggest using `'_` in `where`
clauses
This commit is contained in:
Manish Goregaokar 2024-12-02 18:42:13 +00:00 committed by GitHub
commit 74dd50c653
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 6 deletions

View file

@ -658,12 +658,6 @@ fn report_elidable_impl_lifetimes<'tcx>(
lifetime,
in_where_predicate: false,
..
}
| Usage {
lifetime,
in_bounded_ty: false,
in_generics_arg: false,
..
},
] = usages.as_slice()
{

View file

@ -562,4 +562,18 @@ mod rayon {
}
}
mod issue13749 {
pub struct Generic<T>(T);
// Non elidable lifetime
#[expect(clippy::extra_unused_lifetimes)]
impl<'a, T> Generic<T> where T: 'a {}
}
mod issue13749bis {
pub struct Generic<T>(T);
// Non elidable lifetime
#[expect(clippy::extra_unused_lifetimes)]
impl<'a, T: 'a> Generic<T> {}
}
fn main() {}

View file

@ -562,4 +562,18 @@ mod rayon {
}
}
mod issue13749 {
pub struct Generic<T>(T);
// Non elidable lifetime
#[expect(clippy::extra_unused_lifetimes)]
impl<'a, T> Generic<T> where T: 'a {}
}
mod issue13749bis {
pub struct Generic<T>(T);
// Non elidable lifetime
#[expect(clippy::extra_unused_lifetimes)]
impl<'a, T: 'a> Generic<T> {}
}
fn main() {}