-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Rework target checking for built-in attributes #145085
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
base: master
Are you sure you want to change the base?
Conversation
66feb37
to
a1c6f2a
Compare
- Added a few more variants which are needed for various attributes - Previously a trait method with default block had the same target representation as a method in a `impl trait for` block, this has been changed (See `MethodKind`) - Added both `singular_name` and `plural_name` for more precision on the form of the name
This comment has been minimized.
This comment has been minimized.
Every acceptor gets an `ALLOWED_TARGETS` specification which can specify per target whether it is allowed, warned, or errored.
a1c6f2a
to
df39f8d
Compare
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. This PR modifies Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
@@ -64,27 +71,32 @@ pub(crate) struct ExportStableParser; | |||
impl<S: Stage> NoArgsAttributeParser<S> for ExportStableParser { | |||
const PATH: &[Symbol] = &[sym::export_stable]; | |||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn; | |||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowAll; //FIXME Still checked fully in `check_attr.rs` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some attributes were a little non-trivial to check, I will do these soon but I think let's get all the easy ones done first
Allow(Target::AssocTy), | ||
Allow(Target::AssocConst), | ||
Allow(Target::Variant), | ||
Allow(Target::Impl { of_trait: false }), //FIXME This does not make sense |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make breaking changes in a future PR, for example to fix this.
| | ||
= note: `#[deny(useless_deprecated)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made all attributes that were previously warnings a future error. I can try to replicate the previous behaviour if you wish but I think this should be fine.
--> $DIR/issue-31769.rs:2:5 | ||
| | ||
LL | #[inline] struct Foo; | ||
| ^^^^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I've just noticed this is super ugly with the help
getting its own codespan, let me see if I can fix that
@@ -57,7 +57,7 @@ LL | #[lang = "fn"] | |||
| ^^^^^^^^^^^^^^ | |||
... | |||
LL | trait Fn { | |||
| - this trait has 0 generic arguments | |||
| - this a trait has 0 generic arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I'll have to fix that
The job Click to see the possible cause of the failure (guessed by this bot)
|
This is a refactoring of target checking for built-in attributes.
This PR has the following goals:
#[repr]
will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future.I've split it in commits and left a description on some of the commits to help review.
r? @jdonszelmann