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 false positive regression from 1.82 to 1.83 #13578

Open
davidhewitt opened this issue Oct 21, 2024 · 0 comments · May be fixed by #13583
Open

extra_unused_lifetimes false positive regression from 1.82 to 1.83 #13578

davidhewitt opened this issue Oct 21, 2024 · 0 comments · May be fixed by #13583
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@davidhewitt
Copy link

Summary

I believe the following to be a regression in a new false positive for the extra_unused_lifetimes lint for 1.83.

The suggestion is to remove a lifetime 'a, but it is used in the where bound for &'a T: Foo. It's not valid to use where &'_ T: Foo and I also believe where for<'a> &'a T: Foo to have a different meaning, so I do not see a way to remove 'a from the impl.

I am of course happy to be wrong, in which case TIL! 😄

Reproducer

I tried this code:

pub trait Foo {}

impl<'a, T: 'a> Foo for Option<T> where &'a T: Foo {}

I expected to see this happen: no lint warning. (This is the case on 1.82 stable.)

Instead, this happened:

warning: this lifetime isn't used in the impl
 --> src/lib.rs:5:6
  |
5 | impl<'a, T: 'a> Foo for Vec<T> where &'a T: Foo {}
  |      ^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
  = note: `#[warn(clippy::extra_unused_lifetimes)]` on by default

I observe this on 1.83.0-beta.2

Version

rustc 1.83.0-beta.2 (88c1c3c11 2024-10-18)
binary: rustc
commit-hash: 88c1c3c1102bbf3860891bfa52b7ddd9f26aec2f
commit-date: 2024-10-18
host: aarch64-apple-darwin
release: 1.83.0-beta.2
LLVM version: 19.1.1

Additional Labels

No response

@davidhewitt davidhewitt added the C-bug Category: Clippy is not doing the correct thing label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
1 participant