diff --git a/src/tools/compiletest/src/header/cfg.rs b/src/tools/compiletest/src/header/cfg.rs index a14943c9466..dbc78dd521b 100644 --- a/src/tools/compiletest/src/header/cfg.rs +++ b/src/tools/compiletest/src/header/cfg.rs @@ -1,6 +1,8 @@ use crate::common::{CompareMode, Config, Debugger}; use std::collections::HashSet; +const EXTRA_ARCHS: &[&str] = &["asmjs", "spirv"]; + /// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86` /// or `normalize-stderr-32bit`. pub(super) fn parse_cfg_name_directive<'a>( @@ -99,7 +101,7 @@ pub(super) fn parse_cfg_name_directive<'a>( } condition! { name: &target_cfg.arch, - allowed_names: &target_cfgs.all_archs, + allowed_names: ContainsEither { a: &target_cfgs.all_archs, b: &EXTRA_ARCHS }, message: "when the architecture is {name}" } condition! { @@ -257,3 +259,14 @@ impl CustomContains for ContainsPrefixed { } } } + +struct ContainsEither<'a, A: CustomContains, B: CustomContains> { + a: &'a A, + b: &'a B, +} + +impl CustomContains for ContainsEither<'_, A, B> { + fn custom_contains(&self, item: &str) -> bool { + self.a.custom_contains(item) || self.b.custom_contains(item) + } +}