-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Use a default lifetime of 'static
in associated consts
#125190
Comments
@rfcbot fcp merge |
Team member @tmandry has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
I can put up a PR to implement this adjustment, pending FCP approval. |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
…=nnethercote Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: rust-lang#125190 (comment) Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
Rollup merge of rust-lang#125258 - compiler-errors:static-if-no-lt, r=nnethercote Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: rust-lang#125190 (comment) Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
This is done |
Expand the interpretation of rust-lang/rfcs#1623 "static_lifetime_in_statics" to include associated consts in traits and trait impls when there are no other lifetimes in scope. This means the following code will compile:
However, if there are any lifetime parameters on the item declaration or const, we will continue to require an explicit choice of lifetime. We may revisit this decision in the future. Examples are listed in the appendix below.
Rationale: There is a high level of churn suggested by the backreferences to #115010. The primary intention of this FCP is to reduce the churn associated with this change. The lang team discussed #124211 and thought it would be good to decide on what we want in the most obvious (and common) cases, which should also reduce the level of churn significantly.
Appendix: Examples with lifetimes
The text was updated successfully, but these errors were encountered: