diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-19 14:18:23 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 14:18:23 +1000 |
| commit | 11c6d898b6f1e47c55b91e794c114ba79b301f1a (patch) | |
| tree | 3772918ce3d1c3ed81de5792f8dc5b4397f804ce /compiler/rustc_feature | |
| parent | f3f1847e40f0b33dcf7bee55af49054f7ec1875c (diff) | |
| parent | 70e26c1b7bd4e9f8ba610de6dca2d74ab233cb64 (diff) | |
| download | rust-11c6d898b6f1e47c55b91e794c114ba79b301f1a.tar.gz rust-11c6d898b6f1e47c55b91e794c114ba79b301f1a.zip | |
Rollup merge of #145243 - jdonszelmann:inner-attr-errors, r=petrochenkov
take attr style into account in diagnostics when the original attribute was specified as an inner attribute, the suggestion will now match that attribute style
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 9749028adb0..3b11a2bc7df 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}]")); } |
