-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Port #[instruction_set] to attribute parser
#150193
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: main
Are you sure you want to change the base?
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs Some changes occurred in compiler/rustc_hir/src/attrs Some changes occurred in compiler/rustc_attr_parsing |
This comment has been minimized.
This comment has been minimized.
|
Reminder, once the PR becomes ready for a review, use |
2815243 to
25f9a74
Compare
|
@rustbot ready |
25f9a74 to
6fd2c64
Compare
6fd2c64 to
d42c32b
Compare
|
@bors r+ rollup |
|
@bors r- |
|
|
||
| impl<S: Stage> SingleAttributeParser<S> for InstructionSetParser { | ||
| const PATH: &[Symbol] = &[sym::instruction_set]; | ||
| const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]); |
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.
The allowed targets list is not correct.
According to the spec, the allowed targets are:
The instruction_set attribute may only be applied to functions with bodies — closures, async blocks, free functions, associated functions in an inherent impl or trait impl, and associated functions in a trait definition when those functions have a default definition .
(https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute)
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 also just realised this is a stable attribute and we haven't been checking the targetlist previously, so I added these and made the rest warn
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.
Could we get a test for this? Would specifically like to see whether async blocks are indeed included under Target::Closure
d42c32b to
0516456
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Please note the test changes, and deprecation of
E0778andE0779In my opinion, all errors related to this attribute are improved I think, except for if you have
#[instruction_set(arm::)]in which case there's anerror: expected identifier, found <eof>, which is quite unhelpful I think, but this seems to be a limitation of the general attribute parsing flowr? @JonathanBrouwer