diff --git a/compiler/rustc_attr_parsing/src/attributes/dummy.rs b/compiler/rustc_attr_parsing/src/attributes/dummy.rs index c192986a953cc..9e2c642d1bbb6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/dummy.rs +++ b/compiler/rustc_attr_parsing/src/attributes/dummy.rs @@ -5,20 +5,21 @@ use rustc_span::{Symbol, sym}; use crate::attributes::{OnDuplicate, SingleAttributeParser}; use crate::context::AcceptContext; use crate::parser::ArgParser; -use crate::target_checking::{ALL_TARGETS, AllowedTargets}; +use crate::target_checking::AllowedTargets; use crate::unstable; pub(crate) struct RustcDummyParser; impl SingleAttributeParser for RustcDummyParser { const PATH: &[Symbol] = &[sym::rustc_dummy]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Ignore; - const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::ManuallyChecked; const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really const STABILITY: AttributeStability = unstable!(rustc_attrs, "the `#[rustc_dummy]` attribute is used for rustc unit tests"); - fn convert(_: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { + fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { args.ignore_args(); + cx.ignore_target_checks(); Some(AttributeKind::RustcDummy) } } diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs index bd592b68dc79e..6d1b06cc7dfcb 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -422,11 +422,15 @@ impl<'f, 'sess> AcceptContext<'f, 'sess> { attribute_args: &'static str, allowed_targets: &AllowedTargets, ) { + self.ignore_target_checks(); + AttributeParser::check_target(allowed_targets, attribute_args, self); + } + + pub(crate) fn ignore_target_checks(&mut self) { #[cfg(debug_assertions)] { self.has_target_been_checked = true; } - AttributeParser::check_target(allowed_targets, attribute_args, self); } }