Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro#151596
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @nnethercote rustbot has assigned @nnethercote. Use |
This comment has been minimized.
This comment has been minimized.
|
Update: I changed my mind on this, see below. This is a reasonable attempt at fixing the issue. But I wonder if it's just a band-aid over the real problem? Every MIR pass module has a single pass within, except for The only downside is that this would break external tools relying on the current names. But this kind of API is not guaranteed to be stable, and the breakage is trivial to fix. @saethlin, what do you think? |
| } | ||
|
|
||
| macro_rules! pass_names { | ||
| ($mod_name:ident : $pass_name:ident { $($ident:ident),* $(,)? }) => { |
There was a problem hiding this comment.
It would be useful to have a brief comment on each rule explaining the case being handled. I.e. the first rule deals with pass groups, the second with lone pass names.
There was a problem hiding this comment.
And in this first rule, $pass_name would be better called $pass_group, and $ident would be better called $pass_name.
There was a problem hiding this comment.
I fixed them in the commit below
|
r=me with the aforementioned renamings but I'll give @saethlin a chance to respond in case I'm overlooking anything. |
|
cc @clubby789, who wrote this code. |
|
@sgasho: looks good. Can you squash the commits (there's no value in these particular commits being separate) and then we will be good to go. |
fac135a to
99591e6
Compare
| @@ -1,4 +1,4 @@ | |||
| //@ compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify | |||
| //@ compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify-before-inline | |||
There was a problem hiding this comment.
The fact that you had to change this is making a strong case for the value of this change.
I agree that breaking up the I don't have a strong opinion on the implementation, macros always look like token soup to me, but this one is of reasonable size. I mostly just care that this fixes the footgun. |
|
@bors r=nnethercote,saethlin |
…arn, r=nnethercote,saethlin Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro related: rust-lang#150910 I fixed declare_passes macro to detect unregistered enum names ### UI Results +nightly --> before: no warnings +stage1 --> after: detect SimplifyCfg as an unknown pass <img width="591" height="199" alt="スクリーンショット 2026-01-24 23 53 41" src="https://github.com/user-attachments/assets/ddabaa58-b4c6-4e80-a3c9-f40d866db273" />
Rollup of 8 pull requests Successful merges: - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync) - #150572 (Improve move error diagnostic for `AsyncFn` closures) - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro) - #151802 (Make `QueryDispatcher::Qcx` an associated type) - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results) - #151665 (Fix contrast ratio for `Since` element in rustodoc dark theme) - #151798 (Update `askama` to `0.15.3`) - #151800 (Subscribe myself to translation diagnostics)
Rollup of 12 pull requests Successful merges: - #150474 (Tidy: detect ui tests subdirectory changes so `tests/ui/README.md` stays in sync) - #150572 (Improve move error diagnostic for `AsyncFn` closures) - #151596 (Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro) - #151802 (Make `QueryDispatcher::Qcx` an associated type) - #149110 (Implement `cast_slice` for raw pointer types) - #151559 ([rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results) - #151665 (Fix contrast ratio for `Since` element in rustdoc dark theme) - #151785 (Stabilize feature(push_mut)) - #151798 (Update `askama` to `0.15.3`) - #151800 (Subscribe myself to translation diagnostics) - #151804 (Document, sort, and tweak spellcheck entries in `typos.toml`) - #151805 (Fix grammar in `env::current_exe()#Security`)
Rollup merge of #151596 - sgasho:150910_SimplifyCfg_passes_warn, r=nnethercote,saethlin Fix -Zmir-enable-passes to detect unregistered enum names in declare_passes macro related: #150910 I fixed declare_passes macro to detect unregistered enum names ### UI Results +nightly --> before: no warnings +stage1 --> after: detect SimplifyCfg as an unknown pass <img width="591" height="199" alt="スクリーンショット 2026-01-24 23 53 41" src="https://github.com/user-attachments/assets/ddabaa58-b4c6-4e80-a3c9-f40d866db273" />
related: #150910
I fixed declare_passes macro to detect unregistered enum names
UI Results
+nightly --> before: no warnings
+stage1 --> after: detect SimplifyCfg as an unknown pass