-
Notifications
You must be signed in to change notification settings - Fork 1.7k
False positive for needless_lifetimes #417
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
Comments
Been on my radar for a while, just haven't had the time to fix. We need to bail whenever there are lifetime positions (trait pointer bounds, struct/trait params) which are not specified. |
I'm having a look at this. I don't understand why we should necessarily bail on unspecified lifetimes though. E.g. pub struct Foo<'a> {
r: &'a str
}
fn do_foo<'a>(foo: Foo, other_string: &'a str) { should give a warning, even though we didn't specify the lifetime of the |
That's fine with me too. Bailing is just the easier option since there are a lot of cases here. So there are four types of lifetimes:
We should make note of the number of each type of lifetime in the input and output, and handle all the cases there. There are a lot of cases, but if you think you can work them all out, go ahead 😄 |
But don't we have to consider exactly the same cases for lifetimes on references? I'm probably missing something here. I don't think the logic to work out whether lifetimes can be elided would have to change at all. We just have to keep track of unspecified lifetimes on structs/enums as well as references, which the visitor currently doesn't do. |
Looking at the implementation it's possible to do it without needing much change, I think. You seem to be on the right track. |
👯 Thanks! |
https://github.com/Manishearth/rust-clippy/issues/417 is now solved, so this attribute is not required anymore.
remove clippy needless_lifetimes attribute https://github.com/Manishearth/rust-clippy/issues/417 is now solved, so this attribute is not required anymore.
https://github.com/Manishearth/rust-clippy/issues/417 is now solved, so this attribute is not required anymore.
While working on https://github.com/Manishearth/rust-clippy/pull/396 I ran into a false positive for the
needless_lifetimes
lint. A small example:When running clippy on this code, it gives
but after removing the explicit lifetimes, rustc fails with the following error:
The text was updated successfully, but these errors were encountered: