Extend extra_unused_lifetimes to handle impl lifetimes

This commit is contained in:
Samuel E. Moelius III 2022-04-22 20:05:18 -04:00
parent ed22428b72
commit b35c04f7dc
7 changed files with 97 additions and 12 deletions

View file

@ -1,4 +1,4 @@
#[allow(dead_code)]
#![allow(dead_code, clippy::extra_unused_lifetimes)]
/// Test for https://github.com/rust-lang/rust-clippy/issues/2865

View file

@ -1,4 +1,4 @@
/// Test for https://github.com/rust-lang/rust-clippy/issues/2865
/// Test for https://github.com/rust-lang/rust-clippy/issues/3151
#[derive(Clone)]
pub struct HashMap<V, S> {

View file

@ -72,4 +72,20 @@ mod issue4291 {
}
}
mod issue6437 {
pub struct Scalar;
impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar {
fn add_assign(&mut self, _rhs: &Scalar) {
unimplemented!();
}
}
impl<'b> Scalar {
pub fn something<'c>() -> Self {
Self
}
}
}
fn main() {}

View file

@ -24,5 +24,23 @@ error: this lifetime isn't used in the function definition
LL | fn unused_lt<'a>(x: u8) {}
| ^^
error: aborting due to 4 previous errors
error: this lifetime isn't used in the impl
--> $DIR/extra_unused_lifetimes.rs:78:10
|
LL | impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar {
| ^^
error: this lifetime isn't used in the impl
--> $DIR/extra_unused_lifetimes.rs:84:10
|
LL | impl<'b> Scalar {
| ^^
error: this lifetime isn't used in the function definition
--> $DIR/extra_unused_lifetimes.rs:85:26
|
LL | pub fn something<'c>() -> Self {
| ^^
error: aborting due to 7 previous errors

View file

@ -1,4 +1,4 @@
#![allow(dead_code)]
#![allow(dead_code, clippy::extra_unused_lifetimes)]
#![warn(clippy::multiple_inherent_impl)]
struct MyStruct;

View file

@ -1,4 +1,4 @@
#![allow(dead_code, clippy::missing_safety_doc)]
#![allow(dead_code, clippy::missing_safety_doc, clippy::extra_unused_lifetimes)]
#![warn(clippy::new_without_default)]
pub struct Foo;