-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Refactor deprecation attributes #82432
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
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
cc @Mark-Simulacrum, IIRC you was the last person who refactored this previously. |
So IIRC the last refactor here explicitly aimed to unify the two, rather than splitting them apart - most handling after parsing/validation should be able to treat them without needing to know which one it is. One of the reasons that I personally wanted to unify them is that some of the features currently available on the unstable attribute I'd like to see integrated into the stable attribute, so that other libraries can make use of it, and I think splitting the two into enum variants largely harms that. It seems like parts of this PR could be kept regardless, but as you have everything in one commit that might be painful. Other reviewers might also feel differently on whether this is a sufficient improvement to merit splitting rather than unifying. |
FTR at the current publishing scheme, 1.256.0 will be reached on Oct 21, 2044. But it doesn't appear in any public/stable API that can't be updated in time so it's not really a problem currently. |
I disagree that this PR either splits apart or makes it harder to unify the two attributes. Rather, I'd say this PR makes it explicit how divided they already are, whereas before the divisions were more implicit. I'd argue that exposing these divisions makes it easier, not harder, to unify the two in the future where possible. That said, I also don't think we should consider it likely that these attributes will ever be fully (or even mostly!) unified, for the following reasons:
One thing worth emphasizing is that saying that there are just two attributes here kind of simplifies the situation; arguably there are actually three, thanks to how much unique handling While we're on the topic, I think that the presence of To reiterate, I think this PR will make it easier to further unify the two where possible. Any unified behavior can be implemented via inherent accessors, as this PR does for
Ah, I thought I was supposed to be squashing all my commits before submitting. If wouldn't mind splitting things out if there's demand. |
Right, there's no need to future-proof this since it's neither a stable API nor a part of any stable ABI. There's no harm in only paying for what we'll need for the next 30 years. |
☔ The latest upstream changes (presumably #82448) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot label: -S-waiting-on-review +S-waiting-on-author |
@bstrie can you resolve the conflicts? thanks |
I'm happy to resolve the conflicts if people think this is a patch that they'd like to accept, but it does not seem as though reception has been overly enthusiastic so far. :) I originally split this patch off of the work I was doing for the proof-of-concept of rust-lang/rfcs#3088 , so unless people think this is likely to be accepted, then I'm more inclined to close this, and reopen only if the aforementioned RFC eventually gets accepted. |
The existing handling of deprecation attributes has grown organically to encompass three different meanings over two distinct attributes, and has become pretty messy as a result. This PR cleans up the handling of deprecated attributes:
rustc_attr::StabilityLevel
, replace theDeprecated
struct with aDeprKind
enum for the two deprecated attributes: the stabledeprecated
and the unstablerustc_deprecated
. This allows us to eliminate some unnecessary defensive checks regarding the fields present in the stable attribute.RustcDeprecated
variant contains a boolean field to indicate whether or not this will trigger thedeprecated
lint or thedeprecated_in_future
lint. The logic for determining this is moved fromrustc_middle
torustc_attr
. This also allows us to use the pre-existingparse_version
logic that is private torustc_attr
.Deprecated
still stores an opaqueSymbol
as itssince
field,RustcDeprecated
now stores aVersion
. Because theStabilityLevel
enum is closely related toDeprKind
, theStabilityLevel::Stable
variant now also stores aVersion
. StoringVersion
allows us to remove the custom comparison logic for a sanity check in rustc_passes (a test for this sanity check is also added). As a bonus, errors related to passing in invalid version strings now point to the offending attribute rather than to the decorated item.Version
is now being widely-used, it is exported as a public item. The sizes of its fields are also reduced fromu16
tou8
. Yes, I am aware of the irony.