Skip to content

Commit

Permalink
Fix lifetimes elision suggestion in where clauses (rust-lang#13752)
Browse files Browse the repository at this point in the history
Fix rust-lang#13749

changelog: [`needless_lifetimes`]: do not suggest using `'_` in `where`
clauses
  • Loading branch information
Manishearth authored Dec 2, 2024
2 parents 2ddfc92 + 2b0e7bb commit 74dd50c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 0 additions & 6 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/needless_lifetimes.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
14 changes: 14 additions & 0 deletions tests/ui/needless_lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 74dd50c

Please sign in to comment.