Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AttributeKind> {
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
args.ignore_args();
cx.ignore_target_checks();
Some(AttributeKind::RustcDummy)
}
}
6 changes: 5 additions & 1 deletion compiler/rustc_attr_parsing/src/target_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading