mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Store known passes as an IndexSet
This commit is contained in:
parent
94371d5a8c
commit
12036830d0
@ -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
|
||||
"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());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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::<Vec<_>>();
|
||||
let undeclared = used_passes.difference(&*crate::PASS_NAMES).collect::<Vec<_>>();
|
||||
if let Some((name, rest)) = undeclared.split_first() {
|
||||
let mut err =
|
||||
tcx.dcx().struct_bug(format!("pass `{name}` is not declared in `PASS_NAMES`"));
|
||||
|
Loading…
Reference in New Issue
Block a user