diff options
| author | Jonathan Brouwer <jonathantbrouwer@gmail.com> | 2025-08-09 20:37:48 +0200 |
|---|---|---|
| committer | Jonathan Brouwer <jonathantbrouwer@gmail.com> | 2025-08-14 18:18:22 +0200 |
| commit | 35e04b67a6eeb1603d67f4220b05da9c1b77eed7 (patch) | |
| tree | 2d01563a7c2970fad090c450aa0065e9d646b5ab /compiler/rustc_attr_parsing/src/attributes/confusables.rs | |
| parent | 744d39ebe61ad8cc674797793c743493af078d74 (diff) | |
| download | rust-35e04b67a6eeb1603d67f4220b05da9c1b77eed7.tar.gz rust-35e04b67a6eeb1603d67f4220b05da9c1b77eed7.zip | |
Specify the list of allowed targets per attribute
Diffstat (limited to 'compiler/rustc_attr_parsing/src/attributes/confusables.rs')
| -rw-r--r-- | compiler/rustc_attr_parsing/src/attributes/confusables.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_attr_parsing/src/attributes/confusables.rs b/compiler/rustc_attr_parsing/src/attributes/confusables.rs index edd22172ca2..00f949c82c5 100644 --- a/compiler/rustc_attr_parsing/src/attributes/confusables.rs +++ b/compiler/rustc_attr_parsing/src/attributes/confusables.rs @@ -1,12 +1,13 @@ use rustc_feature::template; use rustc_hir::attrs::AttributeKind; +use rustc_hir::{MethodKind, Target}; use rustc_span::{Span, Symbol, sym}; use thin_vec::ThinVec; use super::{AcceptMapping, AttributeParser}; -use crate::context::{FinalizeContext, Stage}; +use crate::context::MaybeWarn::Allow; +use crate::context::{AllowedTargets, FinalizeContext, Stage}; use crate::session_diagnostics; - #[derive(Default)] pub(crate) struct ConfusablesParser { confusables: ThinVec<Symbol>, @@ -41,6 +42,8 @@ impl<S: Stage> AttributeParser<S> for ConfusablesParser { this.first_span.get_or_insert(cx.attr_span); }, )]; + const ALLOWED_TARGETS: AllowedTargets = + AllowedTargets::AllowList(&[Allow(Target::Method(MethodKind::Inherent))]); fn finalize(self, _cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> { if self.confusables.is_empty() { |
