Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra_unused_lifetimes doesn't warn for lifetimes declared on impl and never used #6437

Closed
carols10cents opened this issue Dec 9, 2020 · 0 comments · Fixed by #8737
Closed
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@carols10cents
Copy link
Member

I tried this code (simplified from the actual code):

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
    }
}

I expected to see this happen: I expected to get an unused lifetime warning for all the lifetimes in this example: 'a because it's not used anywhere in the AddAssign impl block (and AddAssign's definition doesn't have any lifetimes), 'b because it's not used anywhere in the impl Scalar block, and 'c because it's not used anywhere in fn something.

Instead, this happened: I only see a warning for 'c:

warning: this lifetime isn't used in the function definition
  --> src/lib.rs:10:22
   |
10 |     pub fn something<'c>() -> Self {
   |                      ^^
   |
   = note: `#[warn(clippy::extra_unused_lifetimes)]` on by default

Meta

  • cargo clippy -V: On the playground: 0.0.212 (2020-12-03 5be3f9f)
  • rustc -Vv: Stable on the playground: 1.48.0
@carols10cents carols10cents added the C-bug Category: Clippy is not doing the correct thing label Dec 9, 2020
@phansch phansch added the I-false-negative Issue: The lint should have been triggered on code, but wasn't label Dec 18, 2020
@camsteffen camsteffen added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. and removed C-bug Category: Clippy is not doing the correct thing labels Feb 18, 2021
@bors bors closed this as completed in 94623ee Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants