Auto merge of #151015 - JonathanBrouwer:fix-cratelevel-perf, r=jdonszelmann
Fix perf of `check_crate_level` refactor Fixes the perf of https://github.com/rust-lang/rust/pull/150930 The problem is that `allowed_targets` allocates a `Vec` (also moves a comment around to a move useful place) r? @jdonszelmann
This commit is contained in:
commit
fcac501a73
1 changed files with 4 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ use rustc_span::sym;
|
|||
use crate::AttributeParser;
|
||||
use crate::context::{AcceptContext, Stage};
|
||||
use crate::session_diagnostics::InvalidTarget;
|
||||
use crate::target_checking::Policy::Allow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum AllowedTargets {
|
||||
|
|
@ -88,7 +89,9 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
|
|||
target: Target,
|
||||
cx: &mut AcceptContext<'_, 'sess, S>,
|
||||
) {
|
||||
if allowed_targets.allowed_targets() == &[Target::Crate] {
|
||||
// For crate-level attributes we emit a specific set of lints to warn
|
||||
// people about accidentally not using them on the crate.
|
||||
if let &AllowedTargets::AllowList(&[Allow(Target::Crate)]) = allowed_targets {
|
||||
Self::check_crate_level(target, cx);
|
||||
return;
|
||||
}
|
||||
|
|
@ -146,8 +149,6 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
|
|||
}
|
||||
|
||||
pub(crate) fn check_crate_level(target: Target, cx: &mut AcceptContext<'_, 'sess, S>) {
|
||||
// For crate-level attributes we emit a specific set of lints to warn
|
||||
// people about accidentally not using them on the crate.
|
||||
if target == Target::Crate {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue