-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
How to resolve extra_unused_lifetimes? #4291
Comments
I can't reproduce this on my machine. Also your link to the implementation isn't the function in the warning message. Have you changed anything else? Can you push a reproducer in a separate branch/fork to the repo and link it here? |
Sorry, I fixed by adding lifetime to those types, which I don't think is a perfect fix. You can checkout tag 2.0.1 and reproduce. The trait at 2.0.1: The impl: |
Quite minimal reproducer: #[derive(Debug)]
pub struct Foo<'a>(&'a std::marker::PhantomData<u8>);
#[derive(Debug)]
pub struct Bar<'a: 'b, 'b>(Foo<'a>, &'b std::marker::PhantomData<u8>);
trait LT {
fn test<'a: 'b, 'b>(foo: &Foo<'a>, bar: &Bar<'a, 'b>);
}
pub struct Baz;
impl LT for Baz {
fn test<'a: 'b, 'b>(_foo: &Foo, _bar: &Bar) {
}
} We shouldn't lint trait implementations |
Fix `extra_unused_lifetimes` false positive Fixes #4291 changelog: Fix `extra_unused_lifetimes` false positive
clippy -V:
clippy 0.0.212 (b029042 2019-07-12)
I'm getting clippy warnings for unused lifetime in function definition like:
The function is defined in a trait, and here in it's implementation some unused lifetimes in argument types were omitted and compiler think it's ok. However, removing these will cause compilation error that compiler finds the definition was incompatible with trait.
Also by prefixing the unused lifetimes with
_
doesn't work for clippy.So is there a recommended solution for this case other than add all lifetime specifiers to argument types?
The text was updated successfully, but these errors were encountered: