diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 68904c65252..d2d5facbbdc 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -90,20 +90,20 @@ macro_rules! declare_passes { )+ )* - static PASS_NAMES: LazyLock> = LazyLock::new(|| vec![ + static PASS_NAMES: LazyLock> = LazyLock::new(|| [ // Fake marker pass - "PreCodegen".to_string(), + "PreCodegen", $( $( - stringify!($pass_name).to_string(), + stringify!($pass_name), $( $( - $mod_name::$pass_name::$ident.name().to_string(), + $mod_name::$pass_name::$ident.name(), )* )? )+ )* - ]); + ].into_iter().collect()); }; } diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index bc960ae0f56..e26e0c78b29 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -200,9 +200,8 @@ fn run_passes_inner<'tcx>( let named_passes: FxIndexSet<_> = overridden_passes.iter().map(|(name, _)| name.as_str()).collect(); - let known_passes: FxIndexSet<_> = crate::PASS_NAMES.iter().map(|p| p.as_str()).collect(); - for &name in named_passes.difference(&known_passes) { + for &name in named_passes.difference(&*crate::PASS_NAMES) { tcx.dcx().emit_warn(errors::UnknownPassName { name }); } @@ -213,7 +212,7 @@ fn run_passes_inner<'tcx>( { let used_passes: FxIndexSet<_> = passes.iter().map(|p| p.name()).collect(); - let undeclared = used_passes.difference(&known_passes).collect::>(); + let undeclared = used_passes.difference(&*crate::PASS_NAMES).collect::>(); if let Some((name, rest)) = undeclared.split_first() { let mut err = tcx.dcx().struct_bug(format!("pass `{name}` is not declared in `PASS_NAMES`"));