-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve diagnostics regarding how static_in_const doesn't work for associated constants #38831
Comments
This is intentional, but it seems like the RFC text wasn't updated to accommodate this detail. |
@petrochenkov I feel that if that's the case, then the error message should be improved and the RFC text should be updated. |
Doc team triage: tagging as p-low because this is for an unstable feature |
Would extending |
I personally would be careful to only default to |
Should this still be P-low considering how this feature got stabilised? @steveklabnik |
@clarcharr you're right! We should change the prioritization. I'm going to nominate this to be discussed at the docs meeting today. |
Doc team triage: the RFC issue in the reference repo rust-lang/reference#9 should be tracking adding this to the reference, so that takes care of the doc requirement. As such, leaving this to diagnostics now. Removing the p-tag because that's for @rust-lang/compiler to decide. |
We decided against it because, in that case, there might be other lifetimes you would want. For example: trait Foo<'a> {
const T: &'a str;
} that said, revisiting this explanation, it feel a bit weak, since the value of an associated constant would still have to be all consisting of static data. So it seems like |
Yes, please! |
Going through old issues on GitHub, I think we can close this. The latest diagnostics for this seem good to me:
|
…oc-ct-lt, r=cjgillot Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`) Elided lifetimes in associated constants (in impls) erroneously resolve to fresh lifetime parameters on the impl since rust-lang#97313. This is not correct behavior (see rust-lang#38831). I originally opened rust-lang#114716 to fix this, but given the time that has passed, the crater results seem pretty bad: rust-lang#114716 (comment) This PR alternatively implements a lint against this behavior, and I'm hoping to bump this to deny in a few versions.
…oc-ct-lt, r=cjgillot Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`) Elided lifetimes in associated constants (in impls) erroneously resolve to fresh lifetime parameters on the impl since rust-lang#97313. This is not correct behavior (see rust-lang#38831). I originally opened rust-lang#114716 to fix this, but given the time that has passed, the crater results seem pretty bad: rust-lang#114716 (comment) This PR alternatively implements a lint against this behavior, and I'm hoping to bump this to deny in a few versions.
…oc-ct-lt, r=cjgillot Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`) Elided lifetimes in associated constants (in impls) erroneously resolve to fresh lifetime parameters on the impl since rust-lang#97313. This is not correct behavior (see rust-lang#38831). I originally opened rust-lang#114716 to fix this, but given the time that has passed, the crater results seem pretty bad: rust-lang#114716 (comment) This PR alternatively implements a lint against this behavior, and I'm hoping to bump this to deny in a few versions.
Example code:
Would default
CONST
to&'static str
if this actually worked for associated constants. The original RFC decided to not do this, so, it makes sense to document the behaviour.EDIT: the error message should be better, not the docs.
The text was updated successfully, but these errors were encountered: