Skip to content

Commit 49d5453

Browse files
Rollup merge of rust-lang#157364 - JonathanBrouwer:target-dummy, r=mejrs
Rewrite target checking of `rustc_dummy` r? @mejrs
2 parents e2c935b + 9bc4e33 commit 49d5453

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/dummy.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ use rustc_span::{Symbol, sym};
55
use crate::attributes::{OnDuplicate, SingleAttributeParser};
66
use crate::context::AcceptContext;
77
use crate::parser::ArgParser;
8-
use crate::target_checking::{ALL_TARGETS, AllowedTargets};
8+
use crate::target_checking::AllowedTargets;
99
use crate::unstable;
1010

1111
pub(crate) struct RustcDummyParser;
1212
impl SingleAttributeParser for RustcDummyParser {
1313
const PATH: &[Symbol] = &[sym::rustc_dummy];
1414
const ON_DUPLICATE: OnDuplicate = OnDuplicate::Ignore;
15-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
15+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::ManuallyChecked;
1616
const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really
1717
const STABILITY: AttributeStability =
1818
unstable!(rustc_attrs, "the `#[rustc_dummy]` attribute is used for rustc unit tests");
1919

20-
fn convert(_: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
20+
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
2121
args.ignore_args();
22+
cx.ignore_target_checks();
2223
Some(AttributeKind::RustcDummy)
2324
}
2425
}

compiler/rustc_attr_parsing/src/target_checking.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,15 @@ impl<'f, 'sess> AcceptContext<'f, 'sess> {
422422
attribute_args: &'static str,
423423
allowed_targets: &AllowedTargets,
424424
) {
425+
self.ignore_target_checks();
426+
AttributeParser::check_target(allowed_targets, attribute_args, self);
427+
}
428+
429+
pub(crate) fn ignore_target_checks(&mut self) {
425430
#[cfg(debug_assertions)]
426431
{
427432
self.has_target_been_checked = true;
428433
}
429-
AttributeParser::check_target(allowed_targets, attribute_args, self);
430434
}
431435
}
432436

0 commit comments

Comments
 (0)