Move feature gating to the new attr parsing infrastructure#157195
Move feature gating to the new attr parsing infrastructure#157195JonathanBrouwer wants to merge 4 commits into
Conversation
598d5b0 to
2d3c8a8
Compare
2d3c8a8 to
d79693e
Compare
| const ATTRIBUTES: AcceptMapping<Self> = &[( | ||
| &[sym::diagnostic, sym::on_const], | ||
| template!(List: &[r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#]), | ||
| AttributeStability::Stable, // Unstable, stability checked manually in the parser |
There was a problem hiding this comment.
I'm considering adding special logic for this, but I'd prefer to do that in a separate PR as this one is already big enough
| cx: &mut AcceptContext<'_, '_>, | ||
| args: &ArgParser, | ||
| ) -> impl IntoIterator<Item = Self::Item> { | ||
| if !cx.features().staged_api() { |
There was a problem hiding this comment.
Not sure why specifically staged_api had a manual feature gate (and is marked as stable in builtin_attr), from looking at the git history this has always been the case?
| sym::lang_items => ("lang items are subject to change".to_string(), &[]), | ||
| sym::prelude_import => ("`#[prelude_import]` is for use by rustc only".to_string(), &[]), | ||
| sym::profiler_runtime => ("the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate which contains the profiler runtime and will never be stable".to_string(), &[]), | ||
| sym::thread_local => ("`#[thread_local]` is an experimental feature, and does not currently handle destructors".to_string(), &[]), |
There was a problem hiding this comment.
I would like to change and fine-tune some of these messages, but I have kept them the same as much as easily possible in this PR and will send a follow-up PR to clean this up
|
|
||
| /// Attributes that have a special meaning to rustc or rustdoc. | ||
| #[rustfmt::skip] | ||
| pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ |
There was a problem hiding this comment.
Goal is to make a follow-up PR to remove all of BUILTIN_ATTRIBUTES, we'll see how realistic that is when I get to it :P
There was a problem hiding this comment.
I think this would possibly be a bit nicer if this was in a block that did use sym::*; so you could not have all the sym:: prefixes
There was a problem hiding this comment.
I don't really like that because that would indent everything more, but also don't have strong opinions about it. If everything goes well this code will be gone soon anyways so 🤷
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable | ||
| = note: the `#[rustc_diagnostic_item]` attribute is an internal implementation detail that will never be stable |
There was a problem hiding this comment.
rustc_diagnostic_item was the only attribute with the rustc_attrs feature gate that was excluded from this message, idk why I so I added it for consistency (and to not make the PR more complex)
|
Some changes occurred to diagnostic attributes. cc @mejrs Some changes occurred in compiler/rustc_attr_parsing |
Does the feature gate checking for attributes during attribute parsing, rather than during expansion.
This is one more step towards removing
BUILTIN_ATTRIBUTES.My goal was to keep the diagnostics mostly the same during this PR, and do some improvements and cleanups later, to reduce the diff. Some diagnostics still had minor changes to keep the implementation simpler.
This PR was fully manually written, I triple-checked that I didn't accidentally stabilize or change the gate of an attribute, but I'm terrified of a mistake still slipping through so please check this again.
r? @mejrs @jdonszelmann
cc @nnethercote @scrabsha @Bryntet