Infer all anonymous lifetimes in assoc consts as 'static#156508
Infer all anonymous lifetimes in assoc consts as 'static#156508oli-obk wants to merge 2 commits into
'static#156508Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
Turn elided_lifetimes_in_associated_constant FCW into a hard error
This comment has been minimized.
This comment has been minimized.
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
This comment has been minimized.
This comment has been minimized.
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
'static
Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do rust-lang#156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do rust-lang#156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do rust-lang#156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
Rollup merge of #156960 - oli-obk:push-rrmqnqvwtmsq, r=tiif Some cleanups around passing extra lifetime params from the resolver to ast lowering No functional changes, mostly removing information that was never used at any step. Possibly interesting to @petrochenkov and @cjgillot I originally thought this was a necessary cleanup to be able to refactor our `extra_lifetime_params_map` handling, but it turns out that I can also just do #156508 which removes all the ugly usage of that side table and makes it possible for that side table to be put into `PerOwnerResolverData`. The changes here still were an improvement on its own, thus this PR.
This comment has been minimized.
This comment has been minimized.
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
|
rustbot has assigned @JonathanBrouwer. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rfcbot fcp merge types See the main comment of this PR for a description of the changes and rationale |
|
@oli-obk 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! See this document for info about what commands tagged team members can give me. |
| warn_since: None, | ||
| deny_since: None, | ||
| }, | ||
| Lint { |
There was a problem hiding this comment.
This file is autogenerated, please revert the change.
|
How come trait Foo {
const B: S = S { s: &() };
}
struct S<'a> {
s: &'a (),
}does not lint because |
|
that's unrelated to this change. The reason it doesn't lint is "we gave up at some point due to too much churn and/or the person driving it lost momentum", so the lint has very random rules where things apply |
|
Is it? We currently error here and you explicitly state
I would prefer to keep these errors around. For associated consts their lifetimes can very much not be I don't have a strong opinion on what the behavior for free constants should be, but for assoc consts I do somewhat care about this |
|
The churn was in the ecosystem for elided lifetimes. In this specific case we can indeed just turn it into a hard error, but then it's also a hard error if you use These are entirely separate lints, but as long as we don't make it conditional on whether lifetimes are in scope, I'm fine with other solutions I'll add a commit on top of this one so you can see the diff |
View all comments
fixes #115010
This FCW has been on for almost a year, let's actually do the change that T-lang asked for now that there's no breakage to be expected anymore. I first did a crater run checking if turning it into a hard error breaks anything.
There are two cases that would be a hard error (but totally fine by defaulting to
'static), both based on an old version ofminio. One is a personal crate on github with no changes in the last year (https://github.com/PapePathe/daaray_kaamil) and the other is https://github.com/gear-tech/gear, which is developed on github actively and does not have this issue anymore (also oldminiodependency that was since updated). The crates.io version is 2 years outdated.Thus we can pretty much conclude we're not going to cause anyone any confusion or subtle bugs by changing the rules. The rules for associated constants' types are now the same as the rules for free constants' types:
We now treat all anonymous lifetimes as
'static, irrespective of whether other lifetimes are in scope or not. This means the following piece of code starts compiling without warnings or errors again.Unfortunately it also means that
now has no warning or error (just like the same const as a free constant would have). It used to emit
It is very possible to keep this error around, but it seems unfortunate to have different behaviour between const items and assoc const items.