diff options
| author | Georg Semmler <github@weiznich.de> | 2024-05-10 14:12:30 +0200 |
|---|---|---|
| committer | Georg Semmler <github@weiznich.de> | 2024-05-21 13:14:41 +0200 |
| commit | 2cff3e90bcd162964546ca9936c209aa952c1af4 (patch) | |
| tree | 78e26281013d0cdc5d9c4403729c082938b6adf6 /compiler/rustc_ast/src | |
| parent | e8ada6ab253b510ac88edda131021d9878f2984f (diff) | |
| download | rust-2cff3e90bcd162964546ca9936c209aa952c1af4.tar.gz rust-2cff3e90bcd162964546ca9936c209aa952c1af4.zip | |
Move `#[do_not_recommend]` to the `#[diagnostic]` namespace
This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires `#![feature(do_not_recommend)]` to work.
Diffstat (limited to 'compiler/rustc_ast/src')
| -rw-r--r-- | compiler/rustc_ast/src/attr/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 0684163617f..d5c9fc960c8 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -13,6 +13,7 @@ use crate::util::literal::escape_string_symbol; use rustc_index::bit_set::GrowableBitSet; use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; +use smallvec::{smallvec, SmallVec}; use std::iter; use std::sync::atomic::{AtomicU32, Ordering}; use thin_vec::{thin_vec, ThinVec}; @@ -87,10 +88,20 @@ impl Attribute { AttrKind::DocComment(..) => None, } } + pub fn name_or_empty(&self) -> Symbol { self.ident().unwrap_or_else(Ident::empty).name } + pub fn path(&self) -> SmallVec<[Symbol; 1]> { + match &self.kind { + AttrKind::Normal(normal) => { + normal.item.path.segments.iter().map(|s| s.ident.name).collect() + } + AttrKind::DocComment(..) => smallvec![sym::doc], + } + } + #[inline] pub fn has_name(&self, name: Symbol) -> bool { match &self.kind { |
