diff options
| author | Jana Dönszelmann <jana@donsz.nl> | 2025-08-11 11:46:30 +0200 |
|---|---|---|
| committer | Jana Dönszelmann <jana@donsz.nl> | 2025-08-16 10:51:09 +0200 |
| commit | 70e26c1b7bd4e9f8ba610de6dca2d74ab233cb64 (patch) | |
| tree | a8fb911385eafee0361851fbffa06296429e3229 /compiler/rustc_feature | |
| parent | 1ae7c4907275f10b3db9e886bc8809ec063e45ee (diff) | |
| download | rust-70e26c1b7bd4e9f8ba610de6dca2d74ab233cb64.tar.gz rust-70e26c1b7bd4e9f8ba610de6dca2d74ab233cb64.zip | |
take attr style into account in attr diagnostics
Diffstat (limited to 'compiler/rustc_feature')
| -rw-r--r-- | compiler/rustc_feature/src/builtin_attrs.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index ab6b8f92802..1f648edaa7d 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -6,6 +6,7 @@ use AttributeDuplicates::*; use AttributeGate::*; use AttributeType::*; use rustc_data_structures::fx::FxHashMap; +use rustc_hir::AttrStyle; use rustc_hir::attrs::EncodeCrossCrate; use rustc_span::edition::Edition; use rustc_span::{Symbol, sym}; @@ -132,9 +133,12 @@ pub struct AttributeTemplate { } impl AttributeTemplate { - pub fn suggestions(&self, inner: bool, name: impl std::fmt::Display) -> Vec<String> { + pub fn suggestions(&self, style: AttrStyle, name: impl std::fmt::Display) -> Vec<String> { let mut suggestions = vec![]; - let inner = if inner { "!" } else { "" }; + let inner = match style { + AttrStyle::Outer => "", + AttrStyle::Inner => "!", + }; if self.word { suggestions.push(format!("#{inner}[{name}]")); } |
