-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Lifetime code style consistency in impl
s and other easy grabs
#16141
base: main
Are you sure you want to change the base?
Conversation
Hold on, I made a mistake |
@alice-i-cecile No longer 2 lines :( |
Ok, clippy isn't requiring anything more. |
All the |
Yeah, I don't like these changes as a whole, and would prefer to allow this lint. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rescinding my approval: we shouldn't do this systematically. The 'a lifetimes are fine, but as @Victoronz points out, the loss of named lifetimes is a net downgrade for readability.
I agree. My opinion (for impls) generally is: |
9738eae
to
42041ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a couple more fixes left! I'm in favor of these changes now, and I'm glad to see the lint allowed.
I would be careful about keeping the scope of this PR down. I see it now also specifies some named lifetimes, which is fine for impls, but there are also some function (and trait function?) definitions in there now. Caution should be taken with other locations, because specifying lifetimes in function definitions (i.e. adding generic arguments) can be a breaking change. It also means no longer systematically following/allowing a lint, so that should be a separate decision/PR imo. |
I totally understand if we aren't interested in tackling "lifetime style consistency" right now. The problems I noticed are:
|
impl
and common types
impl
and common typesimpl
s and other easy grabs
For what it's worth, I like the elisions described as "regressions" above, so I'd like to argue in favor of them briefly. The advantage of This is especially useful for The other advantage is that the lint can enforce consistency. If the preferred style is to include |
I also prefer to just follow the lints, for similar reasons. I'm just doing my best given the feedback since I think pretty much every member has been against that strategy. I'm trying to find a balance between "We don't want to have to write all the lifetimes" in #15916 (for example, writing |
Just in case it wasn't clear: I think you're doing a great job with this PR! My comment was for the folks who were against that strategy. There are definitely tradeoffs to be made here, but I wanted to highlight some of the benefits of your original proposal in case they hadn't been considered. |
Objective
A certain level of consistency in how lifetimes are (or aren't) written.
Solution
Fix
'a
->'w
where appropriate.Fix "
'w
should always be written" where appropriate.Fix "
's
should always be written" where appropriate.Fix "named lifetimes should always be written" where appropriate.
Testing
Changes should be effectively "code style", not semantic.