-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Separate lint needless_lifetimes for types with multiple lifetimes #12495
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
@rustbot claim |
@antoyo instead of providing a separate lint, I would like to introduce a configuration in this lint, allowing you to toggle this functionality as follows:
|
I didn't know lints could be configured.
Not sure if this going to be a problem. |
Yes, that. We discussed this a bit on zulip and the consensus is that this lint and suggestion are good candidates for this. |
I'm good with this. |
See: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes I applied the suggestion in places where we only use one lifetime. However, I disabled the lint in places where there is more than one lifetime. I believe, that having the lifetime explicit if there are many of them aids readability and makes the code easier to understand. There is a tracking issue for configuration of the lint. See: rust-lang/rust-clippy#12495
Uh oh!
There was an error while loading. Please reload this page.
What it does
I'd like to propose to make the lint
needless_lifetimes
only warn for references (and possibly types with a single lifetime) and add a new separate lint likeneedless_lifetimes
, but that warns for types with multiple lifetimes (where at least one could be elided).An alternative could to be not warn about
needless_lifetimes
when the lifetimes contain multiple characters (like'stuff
).Advantage
For types with multiple lifetimes, it might help readability to keep the lifetimes in the code even if they could be elided.
So, by having a new separate lint, users who prefer to keep lifetimes on types with multiple lifetimes, they could disable this new lint and keep the ability to get warned about
needless_lifetimes
for simple cases.Drawbacks
None since the choice would be up to the user.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: