Skip to content

Commit b702a34

Browse files
committed
Auto merge of #151015 - JonathanBrouwer:fix-cratelevel-perf, r=<try>
Fix perf of `check_crate_level` refactor
2 parents 1377169 + 573c309 commit b702a34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/rustc_attr_parsing/src/target_checking.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_span::sym;
1010
use crate::AttributeParser;
1111
use crate::context::{AcceptContext, Stage};
1212
use crate::session_diagnostics::InvalidTarget;
13+
use crate::target_checking::Policy::Allow;
1314

1415
#[derive(Debug)]
1516
pub(crate) enum AllowedTargets {
@@ -88,7 +89,9 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
8889
target: Target,
8990
cx: &mut AcceptContext<'_, 'sess, S>,
9091
) {
91-
if allowed_targets.allowed_targets() == &[Target::Crate] {
92+
// For crate-level attributes we emit a specific set of lints to warn
93+
// people about accidentally not using them on the crate.
94+
if let &AllowedTargets::AllowList(&[Allow(Target::Crate)]) = allowed_targets {
9295
Self::check_crate_level(target, cx);
9396
return;
9497
}
@@ -146,8 +149,6 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
146149
}
147150

148151
pub(crate) fn check_crate_level(target: Target, cx: &mut AcceptContext<'_, 'sess, S>) {
149-
// For crate-level attributes we emit a specific set of lints to warn
150-
// people about accidentally not using them on the crate.
151152
if target == Target::Crate {
152153
return;
153154
}

0 commit comments

Comments
 (0)