Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,32 @@ macro_rules! declare_passes {
)+
)*

static PASS_NAMES: LazyLock<FxIndexSet<&str>> = LazyLock::new(|| [
static PASS_NAMES: LazyLock<FxIndexSet<&str>> = LazyLock::new(|| {
let mut set = FxIndexSet::default();
// Fake marker pass
"PreCodegen",
set.insert("PreCodegen");
$(
$(
stringify!($pass_name),
$(
$(
$mod_name::$pass_name::$ident.name(),
)*
)?
set.extend(pass_names!($mod_name : $pass_name $( { $($ident),* } )? ));
)+
)*
].into_iter().collect());
set
});
};
}

macro_rules! pass_names {
// pass groups: only pass names inside are considered pass_names
($mod_name:ident : $pass_group:ident { $($pass_name:ident),* $(,)? }) => {
[
$(
$mod_name::$pass_group::$pass_name.name(),
)*
]
};
// lone pass names: stringify the struct or enum name
($mod_name:ident : $pass_name:ident) => {
[stringify!($pass_name)]
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/invalid_value-polymorphic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify
//@ compile-flags: --crate-type=lib -Zmir-enable-passes=+InstSimplify-before-inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that you had to change this is making a strong case for the value of this change.

//@ build-pass

#![feature(core_intrinsics)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: MIR pass `SimplifyCfg` is unknown and will be ignored

warning: MIR pass `SimplifyCfg` is unknown and will be ignored
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

warning: 2 warnings emitted

9 changes: 9 additions & 0 deletions tests/ui/mir/enable_passes_validation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ revisions: empty unprefixed all_unknown all_known mixed
//@ revisions: enum_not_in_pass_names enum_in_pass_names

//@[empty] compile-flags: -Zmir-enable-passes=

Expand All @@ -13,6 +14,12 @@
//@[mixed] check-pass
//@[mixed] compile-flags: -Zmir-enable-passes=+ThisPassDoesNotExist,+CheckAlignment

//@[enum_not_in_pass_names] check-pass
//@[enum_not_in_pass_names] compile-flags: -Zmir-enable-passes=+SimplifyCfg

//@[enum_in_pass_names] check-pass
//@[enum_in_pass_names] compile-flags: -Zmir-enable-passes=+AddCallGuards

fn main() {}

//[empty]~? ERROR incorrect value `` for unstable option `mir-enable-passes`
Expand All @@ -23,3 +30,5 @@ fn main() {}
//[all_unknown]~? WARN MIR pass `DoesNotExist` is unknown and will be ignored
//[all_unknown]~? WARN MIR pass `ThisPass` is unknown and will be ignored
//[all_unknown]~? WARN MIR pass `DoesNotExist` is unknown and will be ignored
//[enum_not_in_pass_names]~? WARN MIR pass `SimplifyCfg` is unknown and will be ignored
//[enum_not_in_pass_names]~? WARN MIR pass `SimplifyCfg` is unknown and will be ignored
Loading