Store known passes as an IndexSet

This commit is contained in:
clubby789 2024-11-11 16:43:49 +00:00
parent 94371d5a8c
commit 12036830d0
2 changed files with 7 additions and 8 deletions

View File

@ -90,20 +90,20 @@ macro_rules! declare_passes {
)+ )+
)* )*
static PASS_NAMES: LazyLock<Vec<String>> = LazyLock::new(|| vec![ static PASS_NAMES: LazyLock<FxIndexSet<&str>> = LazyLock::new(|| [
// Fake marker pass // 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());
}; };
} }

View File

@ -200,9 +200,8 @@ fn run_passes_inner<'tcx>(
let named_passes: FxIndexSet<_> = let named_passes: FxIndexSet<_> =
overridden_passes.iter().map(|(name, _)| name.as_str()).collect(); 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 }); 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 used_passes: FxIndexSet<_> = passes.iter().map(|p| p.name()).collect();
let undeclared = used_passes.difference(&known_passes).collect::<Vec<_>>(); let undeclared = used_passes.difference(&*crate::PASS_NAMES).collect::<Vec<_>>();
if let Some((name, rest)) = undeclared.split_first() { if let Some((name, rest)) = undeclared.split_first() {
let mut err = let mut err =
tcx.dcx().struct_bug(format!("pass `{name}` is not declared in `PASS_NAMES`")); tcx.dcx().struct_bug(format!("pass `{name}` is not declared in `PASS_NAMES`"));