Simplify macros for target-modifier and mitigation flags#155389
Simplify macros for target-modifier and mitigation flags#155389rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| box_noalias: bool = (true, parse_bool, [TRACKED], | ||
| "emit noalias metadata for box (default: yes)"), | ||
| branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED TARGET_MODIFIER], | ||
| branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED] { TARGET_MODIFIER: BranchProtection }, |
There was a problem hiding this comment.
A limitation of the ${ignore(..)} approach is that we can't just accept a bare TARGET_MODIFIER; we have to accept some kind of variable as well (in this case an identifier).
Because of that, I took the opportunity to give the enum variants camel-case names instead of recycling the struct-field names.
| $( { TARGET_MODIFIER: $tmod_variant:ident } )? | ||
| $( { MITIGATION: $mitigation_variant:ident } )? |
There was a problem hiding this comment.
I tried a lot of different syntaxes here, and { FOO: Bar } is what I eventually settled on.
Many of the alternatives I tried ran into parse ambiguity problems.
At one point I was accepting $tmod:vis TARGET_MODIFIER to allow an empty visibility, but that ended up not working when I had to support MITIGATION at the same time.
Simplify macros for target-modifier and mitigation flags - Rebased and revised version of rust-lang#154501. --- The macros used for handling command-line flags that are “target modifiers” or “mitigations” are quite complicated, and can be significantly simplified by tweaking their syntax and by making use of `${ignore(..)}` metavars. It's possible that more code could be moved out of macros (e.g. declaring some of the enums by hand), but that can be investigated in a potential follow-up. There should be no change to compiler behaviour.
…uwer Rollup of 7 pull requests Successful merges: - #155556 (`rust-analyzer` subtree update) - #152162 (Suggest returning a reference for unsized place from a closure) - #155389 (Simplify macros for target-modifier and mitigation flags) - #155553 (miri subtree update) - #153546 (tests/ui/extern: add annotations for reference rules) - #155475 (Make reparsed guard metavars collect tokens) - #155560 (Remove `AttributeLintKind` variants - part 4)
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#155556 (`rust-analyzer` subtree update) - rust-lang/rust#152162 (Suggest returning a reference for unsized place from a closure) - rust-lang/rust#155389 (Simplify macros for target-modifier and mitigation flags) - rust-lang/rust#155553 (miri subtree update) - rust-lang/rust#153546 (tests/ui/extern: add annotations for reference rules) - rust-lang/rust#155475 (Make reparsed guard metavars collect tokens) - rust-lang/rust#155560 (Remove `AttributeLintKind` variants - part 4)
The macros used for handling command-line flags that are “target modifiers” or “mitigations” are quite complicated, and can be significantly simplified by tweaking their syntax and by making use of
${ignore(..)}metavars.It's possible that more code could be moved out of macros (e.g. declaring some of the enums by hand), but that can be investigated in a potential follow-up.
There should be no change to compiler behaviour.