rustc_hir/attrs/
data_structures.rs

1use std::borrow::Cow;
2use std::path::PathBuf;
3
4pub use ReprAttr::*;
5use rustc_abi::Align;
6pub use rustc_ast::attr::data_structures::*;
7use rustc_ast::token::DocFragmentKind;
8use rustc_ast::{AttrStyle, ast};
9use rustc_data_structures::fx::FxIndexMap;
10use rustc_error_messages::{DiagArgValue, IntoDiagArg};
11use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute};
12use rustc_span::def_id::DefId;
13use rustc_span::hygiene::Transparency;
14use rustc_span::{Ident, Span, Symbol};
15pub use rustc_target::spec::SanitizerSet;
16use thin_vec::ThinVec;
17
18use crate::attrs::pretty_printing::PrintAttribute;
19use crate::limit::Limit;
20use crate::{DefaultBodyStability, PartialConstStability, RustcVersion, Stability};
21
22#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
23pub struct EiiImpl {
24    pub eii_macro: DefId,
25    pub impl_marked_unsafe: bool,
26    pub span: Span,
27    pub inner_span: Span,
28    pub is_default: bool,
29}
30
31#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
32pub struct EiiDecl {
33    pub eii_extern_target: DefId,
34    /// whether or not it is unsafe to implement this EII
35    pub impl_unsafe: bool,
36    pub span: Span,
37}
38
39#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)]
40pub enum InlineAttr {
41    None,
42    Hint,
43    Always,
44    Never,
45    /// `#[rustc_force_inline]` forces inlining to happen in the MIR inliner - it reports an error
46    /// if the inlining cannot happen. It is limited to only free functions so that the calls
47    /// can always be resolved.
48    Force {
49        attr_span: Span,
50        reason: Option<Symbol>,
51    },
52}
53
54impl InlineAttr {
55    pub fn always(&self) -> bool {
56        match self {
57            InlineAttr::Always | InlineAttr::Force { .. } => true,
58            InlineAttr::None | InlineAttr::Hint | InlineAttr::Never => false,
59        }
60    }
61}
62
63#[derive(
64    Copy,
65    Clone,
66    Encodable,
67    Decodable,
68    Debug,
69    PartialEq,
70    Eq,
71    HashStable_Generic,
72    PrintAttribute
73)]
74pub enum InstructionSetAttr {
75    ArmA32,
76    ArmT32,
77}
78
79#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, PrintAttribute)]
80#[derive(Encodable, Decodable, HashStable_Generic)]
81pub enum OptimizeAttr {
82    /// No `#[optimize(..)]` attribute
83    #[default]
84    Default,
85    /// `#[optimize(none)]`
86    DoNotOptimize,
87    /// `#[optimize(speed)]`
88    Speed,
89    /// `#[optimize(size)]`
90    Size,
91}
92
93impl OptimizeAttr {
94    pub fn do_not_optimize(&self) -> bool {
95        matches!(self, Self::DoNotOptimize)
96    }
97}
98
99#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable_Generic, PrintAttribute)]
100pub enum ReprAttr {
101    ReprInt(IntType),
102    ReprRust,
103    ReprC,
104    ReprPacked(Align),
105    ReprSimd,
106    ReprTransparent,
107    ReprAlign(Align),
108}
109
110pub enum TransparencyError {
111    UnknownTransparency(Symbol, Span),
112    MultipleTransparencyAttrs(Span, Span),
113}
114
115#[derive(Eq, PartialEq, Debug, Copy, Clone)]
116#[derive(Encodable, Decodable, HashStable_Generic, PrintAttribute)]
117pub enum IntType {
118    SignedInt(ast::IntTy),
119    UnsignedInt(ast::UintTy),
120}
121
122#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
123pub struct Deprecation {
124    pub since: DeprecatedSince,
125    /// The note to issue a reason.
126    pub note: Option<Symbol>,
127    /// A text snippet used to completely replace any use of the deprecated item in an expression.
128    ///
129    /// This is currently unstable.
130    pub suggestion: Option<Symbol>,
131}
132
133/// Release in which an API is deprecated.
134#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
135pub enum DeprecatedSince {
136    RustcVersion(RustcVersion),
137    /// Deprecated in the future ("to be determined").
138    Future,
139    /// `feature(staged_api)` is off. Deprecation versions outside the standard
140    /// library are allowed to be arbitrary strings, for better or worse.
141    NonStandard(Symbol),
142    /// Deprecation version is unspecified but optional.
143    Unspecified,
144    /// Failed to parse a deprecation version, or the deprecation version is
145    /// unspecified and required. An error has already been emitted.
146    Err,
147}
148
149/// Successfully-parsed value of a `#[coverage(..)]` attribute.
150#[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)]
151#[derive(HashStable_Generic, PrintAttribute)]
152pub enum CoverageAttrKind {
153    On,
154    Off,
155}
156
157impl Deprecation {
158    /// Whether an item marked with #[deprecated(since = "X")] is currently
159    /// deprecated (i.e., whether X is not greater than the current rustc
160    /// version).
161    pub fn is_in_effect(&self) -> bool {
162        match self.since {
163            DeprecatedSince::RustcVersion(since) => since <= RustcVersion::CURRENT,
164            DeprecatedSince::Future => false,
165            // The `since` field doesn't have semantic purpose without `#![staged_api]`.
166            DeprecatedSince::NonStandard(_) => true,
167            // Assume deprecation is in effect if "since" field is absent or invalid.
168            DeprecatedSince::Unspecified | DeprecatedSince::Err => true,
169        }
170    }
171
172    pub fn is_since_rustc_version(&self) -> bool {
173        matches!(self.since, DeprecatedSince::RustcVersion(_))
174    }
175}
176
177/// There are three valid forms of the attribute:
178/// `#[used]`, which is equivalent to `#[used(linker)]` on targets that support it, but `#[used(compiler)]` if not.
179/// `#[used(compiler)]`
180/// `#[used(linker)]`
181#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
182#[derive(HashStable_Generic, PrintAttribute)]
183pub enum UsedBy {
184    Default,
185    Compiler,
186    Linker,
187}
188
189#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash)]
190#[derive(HashStable_Generic, PrintAttribute)]
191pub enum MacroUseArgs {
192    UseAll,
193    UseSpecific(ThinVec<Ident>),
194}
195
196impl Default for MacroUseArgs {
197    fn default() -> Self {
198        Self::UseSpecific(ThinVec::new())
199    }
200}
201
202#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)]
203pub struct StrippedCfgItem<ModId = DefId> {
204    pub parent_module: ModId,
205    pub ident: Ident,
206    pub cfg: (CfgEntry, Span),
207}
208
209impl<ModId> StrippedCfgItem<ModId> {
210    pub fn map_mod_id<New>(self, f: impl FnOnce(ModId) -> New) -> StrippedCfgItem<New> {
211        StrippedCfgItem { parent_module: f(self.parent_module), ident: self.ident, cfg: self.cfg }
212    }
213}
214
215/// Possible values for the `#[linkage]` attribute, allowing to specify the
216/// linkage type for a `MonoItem`.
217///
218/// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
219#[derive(Encodable, Decodable, Clone, Copy, Debug, PartialEq, Eq, Hash)]
220#[derive(HashStable_Generic, PrintAttribute)]
221pub enum Linkage {
222    AvailableExternally,
223    Common,
224    ExternalWeak,
225    External,
226    Internal,
227    LinkOnceAny,
228    LinkOnceODR,
229    WeakAny,
230    WeakODR,
231}
232
233#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)]
234#[derive(HashStable_Generic, PrintAttribute)]
235pub enum MirDialect {
236    Analysis,
237    Built,
238    Runtime,
239}
240
241impl IntoDiagArg for MirDialect {
242    fn into_diag_arg(self, _path: &mut Option<PathBuf>) -> DiagArgValue {
243        let arg = match self {
244            MirDialect::Analysis => "analysis",
245            MirDialect::Built => "built",
246            MirDialect::Runtime => "runtime",
247        };
248        DiagArgValue::Str(Cow::Borrowed(arg))
249    }
250}
251
252#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)]
253#[derive(HashStable_Generic, PrintAttribute)]
254pub enum MirPhase {
255    Initial,
256    PostCleanup,
257    Optimized,
258}
259
260impl IntoDiagArg for MirPhase {
261    fn into_diag_arg(self, _path: &mut Option<PathBuf>) -> DiagArgValue {
262        let arg = match self {
263            MirPhase::Initial => "initial",
264            MirPhase::PostCleanup => "post-cleanup",
265            MirPhase::Optimized => "optimized",
266        };
267        DiagArgValue::Str(Cow::Borrowed(arg))
268    }
269}
270
271/// Different ways that the PE Format can decorate a symbol name.
272/// From <https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type>
273#[derive(
274    Copy,
275    Clone,
276    Debug,
277    Encodable,
278    Decodable,
279    HashStable_Generic,
280    PartialEq,
281    Eq,
282    PrintAttribute
283)]
284pub enum PeImportNameType {
285    /// IMPORT_ORDINAL
286    /// Uses the ordinal (i.e., a number) rather than the name.
287    Ordinal(u16),
288    /// Same as IMPORT_NAME
289    /// Name is decorated with all prefixes and suffixes.
290    Decorated,
291    /// Same as IMPORT_NAME_NOPREFIX
292    /// Prefix (e.g., the leading `_` or `@`) is skipped, but suffix is kept.
293    NoPrefix,
294    /// Same as IMPORT_NAME_UNDECORATE
295    /// Prefix (e.g., the leading `_` or `@`) and suffix (the first `@` and all
296    /// trailing characters) are skipped.
297    Undecorated,
298}
299
300#[derive(
301    Copy,
302    Clone,
303    Debug,
304    PartialEq,
305    Eq,
306    PartialOrd,
307    Ord,
308    Hash,
309    Encodable,
310    Decodable,
311    PrintAttribute
312)]
313#[derive(HashStable_Generic)]
314pub enum NativeLibKind {
315    /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
316    Static {
317        /// Whether to bundle objects from static library into produced rlib
318        bundle: Option<bool>,
319        /// Whether to link static library without throwing any object files away
320        whole_archive: Option<bool>,
321    },
322    /// Dynamic library (e.g. `libfoo.so` on Linux)
323    /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
324    Dylib {
325        /// Whether the dynamic library will be linked only if it satisfies some undefined symbols
326        as_needed: Option<bool>,
327    },
328    /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
329    /// On Linux, it refers to a generated shared library stub.
330    RawDylib {
331        /// Whether the dynamic library will be linked only if it satisfies some undefined symbols
332        as_needed: Option<bool>,
333    },
334    /// A macOS-specific kind of dynamic libraries.
335    Framework {
336        /// Whether the framework will be linked only if it satisfies some undefined symbols
337        as_needed: Option<bool>,
338    },
339    /// Argument which is passed to linker, relative order with libraries and other arguments
340    /// is preserved
341    LinkArg,
342
343    /// Module imported from WebAssembly
344    WasmImportModule,
345
346    /// The library kind wasn't specified, `Dylib` is currently used as a default.
347    Unspecified,
348}
349
350impl NativeLibKind {
351    pub fn has_modifiers(&self) -> bool {
352        match self {
353            NativeLibKind::Static { bundle, whole_archive } => {
354                bundle.is_some() || whole_archive.is_some()
355            }
356            NativeLibKind::Dylib { as_needed }
357            | NativeLibKind::Framework { as_needed }
358            | NativeLibKind::RawDylib { as_needed } => as_needed.is_some(),
359            NativeLibKind::Unspecified
360            | NativeLibKind::LinkArg
361            | NativeLibKind::WasmImportModule => false,
362        }
363    }
364
365    pub fn is_statically_included(&self) -> bool {
366        matches!(self, NativeLibKind::Static { .. })
367    }
368
369    pub fn is_dllimport(&self) -> bool {
370        matches!(
371            self,
372            NativeLibKind::Dylib { .. }
373                | NativeLibKind::RawDylib { .. }
374                | NativeLibKind::Unspecified
375        )
376    }
377}
378
379#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
380pub struct LinkEntry {
381    pub span: Span,
382    pub kind: NativeLibKind,
383    pub name: Symbol,
384    pub cfg: Option<CfgEntry>,
385    pub verbatim: Option<bool>,
386    pub import_name_type: Option<(PeImportNameType, Span)>,
387}
388
389#[derive(HashStable_Generic, PrintAttribute)]
390#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)]
391pub enum DebuggerVisualizerType {
392    Natvis,
393    GdbPrettyPrinter,
394}
395
396#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
397pub struct DebugVisualizer {
398    pub span: Span,
399    pub visualizer_type: DebuggerVisualizerType,
400    pub path: Symbol,
401}
402
403#[derive(Clone, Copy, Debug, Decodable, Encodable, Eq, PartialEq)]
404#[derive(HashStable_Generic, PrintAttribute)]
405#[derive_const(Default)]
406pub enum RtsanSetting {
407    Nonblocking,
408    Blocking,
409    #[default]
410    Caller,
411}
412
413#[derive(Eq, PartialEq, Debug, Copy, Clone)]
414#[derive(Encodable, Decodable, HashStable_Generic, PrintAttribute)]
415pub enum WindowsSubsystemKind {
416    Console,
417    Windows,
418}
419
420impl WindowsSubsystemKind {
421    pub fn as_str(&self) -> &'static str {
422        match self {
423            WindowsSubsystemKind::Console => "console",
424            WindowsSubsystemKind::Windows => "windows",
425        }
426    }
427}
428
429#[derive(Copy, Clone, Debug, PartialEq)]
430#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
431pub enum DocInline {
432    Inline,
433    NoInline,
434}
435
436#[derive(Copy, Clone, Debug, PartialEq)]
437#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
438pub enum HideOrShow {
439    Hide,
440    Show,
441}
442
443#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
444pub struct CfgInfo {
445    pub name: Symbol,
446    pub name_span: Span,
447    pub value: Option<(Symbol, Span)>,
448}
449
450impl CfgInfo {
451    pub fn span_for_name_and_value(&self) -> Span {
452        if let Some((_, value_span)) = self.value {
453            self.name_span.with_hi(value_span.hi())
454        } else {
455            self.name_span
456        }
457    }
458}
459
460#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
461pub struct CfgHideShow {
462    pub kind: HideOrShow,
463    pub values: ThinVec<CfgInfo>,
464}
465
466#[derive(Clone, Debug, Default, HashStable_Generic, Decodable, PrintAttribute)]
467pub struct DocAttribute {
468    pub aliases: FxIndexMap<Symbol, Span>,
469    pub hidden: Option<Span>,
470    // Because we need to emit the error if there is more than one `inline` attribute on an item
471    // at the same time as the other doc attributes, we store a list instead of using `Option`.
472    pub inline: ThinVec<(DocInline, Span)>,
473
474    // unstable
475    pub cfg: ThinVec<CfgEntry>,
476    pub auto_cfg: ThinVec<(CfgHideShow, Span)>,
477    /// This is for `#[doc(auto_cfg = false|true)]`/`#[doc(auto_cfg)]`.
478    pub auto_cfg_change: ThinVec<(bool, Span)>,
479
480    // builtin
481    pub fake_variadic: Option<Span>,
482    pub keyword: Option<(Symbol, Span)>,
483    pub attribute: Option<(Symbol, Span)>,
484    pub masked: Option<Span>,
485    pub notable_trait: Option<Span>,
486    pub search_unbox: Option<Span>,
487
488    // valid on crate
489    pub html_favicon_url: Option<(Symbol, Span)>,
490    pub html_logo_url: Option<(Symbol, Span)>,
491    pub html_playground_url: Option<(Symbol, Span)>,
492    pub html_root_url: Option<(Symbol, Span)>,
493    pub html_no_source: Option<Span>,
494    pub issue_tracker_base_url: Option<(Symbol, Span)>,
495    pub rust_logo: Option<Span>,
496
497    // #[doc(test(...))]
498    pub test_attrs: ThinVec<Span>,
499    pub no_crate_inject: Option<Span>,
500}
501
502impl<E: rustc_span::SpanEncoder> rustc_serialize::Encodable<E> for DocAttribute {
503    fn encode(&self, encoder: &mut E) {
504        let DocAttribute {
505            aliases,
506            hidden,
507            inline,
508            cfg,
509            auto_cfg,
510            auto_cfg_change,
511            fake_variadic,
512            keyword,
513            attribute,
514            masked,
515            notable_trait,
516            search_unbox,
517            html_favicon_url,
518            html_logo_url,
519            html_playground_url,
520            html_root_url,
521            html_no_source,
522            issue_tracker_base_url,
523            rust_logo,
524            test_attrs,
525            no_crate_inject,
526        } = self;
527        rustc_serialize::Encodable::<E>::encode(aliases, encoder);
528        rustc_serialize::Encodable::<E>::encode(hidden, encoder);
529
530        // FIXME: The `doc(inline)` attribute is never encoded, but is it actually the right thing
531        // to do? I suspect the condition was broken, should maybe instead not encode anything if we
532        // have `doc(no_inline)`.
533        let inline: ThinVec<_> =
534            inline.iter().filter(|(i, _)| *i != DocInline::Inline).cloned().collect();
535        rustc_serialize::Encodable::<E>::encode(&inline, encoder);
536
537        rustc_serialize::Encodable::<E>::encode(cfg, encoder);
538        rustc_serialize::Encodable::<E>::encode(auto_cfg, encoder);
539        rustc_serialize::Encodable::<E>::encode(auto_cfg_change, encoder);
540        rustc_serialize::Encodable::<E>::encode(fake_variadic, encoder);
541        rustc_serialize::Encodable::<E>::encode(keyword, encoder);
542        rustc_serialize::Encodable::<E>::encode(attribute, encoder);
543        rustc_serialize::Encodable::<E>::encode(masked, encoder);
544        rustc_serialize::Encodable::<E>::encode(notable_trait, encoder);
545        rustc_serialize::Encodable::<E>::encode(search_unbox, encoder);
546        rustc_serialize::Encodable::<E>::encode(html_favicon_url, encoder);
547        rustc_serialize::Encodable::<E>::encode(html_logo_url, encoder);
548        rustc_serialize::Encodable::<E>::encode(html_playground_url, encoder);
549        rustc_serialize::Encodable::<E>::encode(html_root_url, encoder);
550        rustc_serialize::Encodable::<E>::encode(html_no_source, encoder);
551        rustc_serialize::Encodable::<E>::encode(issue_tracker_base_url, encoder);
552        rustc_serialize::Encodable::<E>::encode(rust_logo, encoder);
553        rustc_serialize::Encodable::<E>::encode(test_attrs, encoder);
554        rustc_serialize::Encodable::<E>::encode(no_crate_inject, encoder);
555    }
556}
557
558/// Represents parsed *built-in* inert attributes.
559///
560/// ## Overview
561/// These attributes are markers that guide the compilation process and are never expanded into other code.
562/// They persist throughout the compilation phases, from AST to HIR and beyond.
563///
564/// ## Attribute Processing
565/// While attributes are initially parsed by [`rustc_parse`] into [`ast::Attribute`], they still contain raw token streams
566/// because different attributes have different internal structures. This enum represents the final,
567/// fully parsed form of these attributes, where each variant contains all the information and
568/// structure relevant for the specific attribute.
569///
570/// Some attributes can be applied multiple times to the same item, and they are "collapsed" into a single
571/// semantic attribute. For example:
572/// ```rust
573/// #[repr(C)]
574/// #[repr(packed)]
575/// struct S { }
576/// ```
577/// This is equivalent to `#[repr(C, packed)]` and results in a single [`AttributeKind::Repr`] containing
578/// both `C` and `packed` annotations. This collapsing happens during parsing and is reflected in the
579/// data structures defined in this enum.
580///
581/// ## Usage
582/// These parsed attributes are used throughout the compiler to:
583/// - Control code generation (e.g., `#[repr]`)
584/// - Mark API stability (`#[stable]`, `#[unstable]`)
585/// - Provide documentation (`#[doc]`)
586/// - Guide compiler behavior (e.g., `#[allow_internal_unstable]`)
587///
588/// ## Note on Attribute Organization
589/// Some attributes like `InlineAttr`, `OptimizeAttr`, and `InstructionSetAttr` are defined separately
590/// from this enum because they are used in specific compiler phases (like code generation) and don't
591/// need to persist throughout the entire compilation process. They are typically processed and
592/// converted into their final form earlier in the compilation pipeline.
593///
594/// For example:
595/// - `InlineAttr` is used during code generation to control function inlining
596/// - `OptimizeAttr` is used to control optimization levels
597/// - `InstructionSetAttr` is used for target-specific code generation
598///
599/// These attributes are handled by their respective compiler passes in the [`rustc_codegen_ssa`] crate
600/// and don't need to be preserved in the same way as the attributes in this enum.
601///
602/// For more details on attribute parsing, see the [`rustc_attr_parsing`] crate.
603///
604/// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
605/// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html
606/// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html
607#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
608pub enum AttributeKind {
609    // tidy-alphabetical-start
610    /// Represents `#[align(N)]`.
611    // FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
612    Align { align: Align, span: Span },
613
614    /// Represents `#[rustc_allow_const_fn_unstable]`.
615    AllowConstFnUnstable(ThinVec<Symbol>, Span),
616
617    /// Represents `#[rustc_allow_incoherent_impl]`.
618    AllowIncoherentImpl(Span),
619
620    /// Represents `#[allow_internal_unsafe]`.
621    AllowInternalUnsafe(Span),
622
623    /// Represents `#[allow_internal_unstable]`.
624    AllowInternalUnstable(ThinVec<(Symbol, Span)>, Span),
625
626    /// Represents `#[rustc_as_ptr]` (used by the `dangling_pointers_from_temporaries` lint).
627    AsPtr(Span),
628
629    /// Represents `#[automatically_derived]`
630    AutomaticallyDerived(Span),
631
632    /// Represents `#[rustc_default_body_unstable]`.
633    BodyStability {
634        stability: DefaultBodyStability,
635        /// Span of the `#[rustc_default_body_unstable(...)]` attribute
636        span: Span,
637    },
638
639    /// Represents the trace attribute of `#[cfg_attr]`
640    CfgAttrTrace,
641
642    /// Represents the trace attribute of `#[cfg]`
643    CfgTrace(ThinVec<(CfgEntry, Span)>),
644
645    /// Represents `#[cfi_encoding]`
646    CfiEncoding { encoding: Symbol },
647
648    /// Represents `#[rustc_coinductive]`.
649    Coinductive(Span),
650
651    /// Represents `#[cold]`.
652    Cold(Span),
653
654    /// Represents `#[rustc_confusables]`.
655    Confusables {
656        symbols: ThinVec<Symbol>,
657        // FIXME(jdonszelmann): remove when target validation code is moved
658        first_span: Span,
659    },
660
661    /// Represents `#[const_continue]`.
662    ConstContinue(Span),
663
664    /// Represents `#[rustc_const_stable]` and `#[rustc_const_unstable]`.
665    ConstStability {
666        stability: PartialConstStability,
667        /// Span of the `#[rustc_const_stable(...)]` or `#[rustc_const_unstable(...)]` attribute
668        span: Span,
669    },
670
671    /// Represents `#[rustc_const_stable_indirect]`.
672    ConstStabilityIndirect,
673
674    /// Represents `#[coroutine]`.
675    Coroutine(Span),
676
677    /// Represents `#[coverage(..)]`.
678    Coverage(Span, CoverageAttrKind),
679
680    /// Represents `#[crate_name = ...]`
681    CrateName { name: Symbol, name_span: Span, attr_span: Span },
682
683    /// Represents `#[custom_mir]`.
684    CustomMir(Option<(MirDialect, Span)>, Option<(MirPhase, Span)>, Span),
685
686    /// Represents `#[debugger_visualizer]`.
687    DebuggerVisualizer(ThinVec<DebugVisualizer>),
688
689    /// Represents `#[rustc_deny_explicit_impl]`.
690    DenyExplicitImpl(Span),
691
692    /// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
693    Deprecation { deprecation: Deprecation, span: Span },
694
695    /// Represents `#[rustc_do_not_implement_via_object]`.
696    DoNotImplementViaObject(Span),
697
698    /// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
699    /// Represents all other uses of the [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html)
700    /// attribute.
701    Doc(Box<DocAttribute>),
702
703    /// Represents specifically [`#[doc = "..."]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
704    /// i.e. doc comments.
705    DocComment { style: AttrStyle, kind: DocFragmentKind, span: Span, comment: Symbol },
706
707    /// Represents `#[rustc_dummy]`.
708    Dummy,
709
710    /// Implementation detail of `#[eii]`
711    EiiExternItem,
712
713    /// Implementation detail of `#[eii]`
714    EiiExternTarget(EiiDecl),
715
716    /// Implementation detail of `#[eii]`
717    EiiImpls(ThinVec<EiiImpl>),
718
719    /// Represents [`#[export_name]`](https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute).
720    ExportName {
721        /// The name to export this item with.
722        /// It may not contain \0 bytes as it will be converted to a null-terminated string.
723        name: Symbol,
724        span: Span,
725    },
726
727    /// Represents `#[export_stable]`.
728    ExportStable,
729
730    /// Represents `#[ffi_const]`.
731    FfiConst(Span),
732
733    /// Represents `#[ffi_pure]`.
734    FfiPure(Span),
735
736    /// Represents `#[fundamental]`.
737    Fundamental,
738
739    /// Represents `#[ignore]`
740    Ignore {
741        span: Span,
742        /// ignore can optionally have a reason: `#[ignore = "reason this is ignored"]`
743        reason: Option<Symbol>,
744    },
745
746    /// Represents `#[inline]` and `#[rustc_force_inline]`.
747    Inline(InlineAttr, Span),
748
749    /// Represents `#[instruction_set]`
750    InstructionSet(InstructionSetAttr),
751
752    /// Represents `#[link]`.
753    Link(ThinVec<LinkEntry>, Span),
754
755    /// Represents `#[link_name]`.
756    LinkName { name: Symbol, span: Span },
757
758    /// Represents `#[link_ordinal]`.
759    LinkOrdinal { ordinal: u16, span: Span },
760
761    /// Represents [`#[link_section]`](https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute)
762    LinkSection { name: Symbol, span: Span },
763
764    /// Represents `#[linkage]`.
765    Linkage(Linkage, Span),
766
767    /// Represents `#[loop_match]`.
768    LoopMatch(Span),
769
770    /// Represents `#[macro_escape]`.
771    MacroEscape(Span),
772
773    /// Represents [`#[macro_export]`](https://doc.rust-lang.org/reference/macros-by-example.html#r-macro.decl.scope.path).
774    MacroExport { span: Span, local_inner_macros: bool },
775
776    /// Represents `#[rustc_macro_transparency]`.
777    MacroTransparency(Transparency),
778
779    /// Represents `#[macro_use]`.
780    MacroUse { span: Span, arguments: MacroUseArgs },
781
782    /// Represents `#[marker]`.
783    Marker(Span),
784
785    /// Represents [`#[may_dangle]`](https://std-dev-guide.rust-lang.org/tricky/may-dangle.html).
786    MayDangle(Span),
787
788    /// Represents `#[move_size_limit]`
789    MoveSizeLimit { attr_span: Span, limit_span: Span, limit: Limit },
790
791    /// Represents `#[must_use]`.
792    MustUse {
793        span: Span,
794        /// must_use can optionally have a reason: `#[must_use = "reason this must be used"]`
795        reason: Option<Symbol>,
796    },
797
798    /// Represents `#[naked]`
799    Naked(Span),
800
801    /// Represents `#[no_core]`
802    NoCore(Span),
803
804    /// Represents `#[no_implicit_prelude]`
805    NoImplicitPrelude(Span),
806
807    /// Represents `#[no_link]`
808    NoLink,
809
810    /// Represents `#[no_mangle]`
811    NoMangle(Span),
812
813    /// Represents `#[no_std]`
814    NoStd(Span),
815
816    /// Represents `#[non_exhaustive]`
817    NonExhaustive(Span),
818
819    /// Represents `#[rustc_objc_class]`
820    ObjcClass { classname: Symbol, span: Span },
821
822    /// Represents `#[rustc_objc_selector]`
823    ObjcSelector { methname: Symbol, span: Span },
824
825    /// Represents `#[optimize(size|speed)]`
826    Optimize(OptimizeAttr, Span),
827
828    /// Represents `#[rustc_paren_sugar]`.
829    ParenSugar(Span),
830
831    /// Represents `#[rustc_pass_by_value]` (used by the `rustc_pass_by_value` lint).
832    PassByValue(Span),
833
834    /// Represents `#[path]`
835    Path(Symbol, Span),
836
837    /// Represents `#[pattern_complexity_limit]`
838    PatternComplexityLimit { attr_span: Span, limit_span: Span, limit: Limit },
839
840    /// Represents `#[pin_v2]`
841    PinV2(Span),
842
843    /// Represents `#[pointee]`
844    Pointee(Span),
845
846    /// Represents `#[proc_macro]`
847    ProcMacro(Span),
848
849    /// Represents `#[proc_macro_attribute]`
850    ProcMacroAttribute(Span),
851
852    /// Represents `#[proc_macro_derive]`
853    ProcMacroDerive { trait_name: Symbol, helper_attrs: ThinVec<Symbol>, span: Span },
854
855    /// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
856    PubTransparent(Span),
857
858    /// Represents [`#[recursion_limit]`](https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute)
859    RecursionLimit { attr_span: Span, limit_span: Span, limit: Limit },
860
861    /// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations).
862    Repr { reprs: ThinVec<(ReprAttr, Span)>, first_span: Span },
863
864    /// Represents `#[rustc_builtin_macro]`.
865    RustcBuiltinMacro { builtin_name: Option<Symbol>, helper_attrs: ThinVec<Symbol>, span: Span },
866
867    /// Represents `#[rustc_coherence_is_core]`
868    RustcCoherenceIsCore(Span),
869
870    /// Represents `#[rustc_layout_scalar_valid_range_end]`.
871    RustcLayoutScalarValidRangeEnd(Box<u128>, Span),
872
873    /// Represents `#[rustc_layout_scalar_valid_range_start]`.
874    RustcLayoutScalarValidRangeStart(Box<u128>, Span),
875
876    /// Represents `#[rustc_legacy_const_generics]`
877    RustcLegacyConstGenerics { fn_indexes: ThinVec<(usize, Span)>, attr_span: Span },
878
879    /// Represents `#[rustc_lint_diagnostics]`
880    RustcLintDiagnostics,
881
882    /// Represents `#[rustc_lint_opt_deny_field_access]`
883    RustcLintOptDenyFieldAccess { lint_message: Symbol },
884
885    /// Represents `#[rustc_lint_opt_ty]`
886    RustcLintOptTy,
887
888    /// Represents `#[rustc_lint_query_instability]`
889    RustcLintQueryInstability,
890
891    /// Represents `#[rustc_lint_untracked_query_information]`
892    RustcLintUntrackedQueryInformation,
893
894    /// Represents `#[rustc_main]`.
895    RustcMain,
896
897    /// Represents `#[rustc_must_implement_one_of]`
898    RustcMustImplementOneOf { attr_span: Span, fn_names: ThinVec<Ident> },
899
900    /// Represents `#[rustc_never_returns_null_ptr]`
901    RustcNeverReturnsNullPointer,
902
903    /// Represents `#[rustc_no_implicit_autorefs]`
904    RustcNoImplicitAutorefs,
905
906    /// Represents `#[rustc_object_lifetime_default]`.
907    RustcObjectLifetimeDefault,
908
909    /// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`
910    RustcPassIndirectlyInNonRusticAbis(Span),
911
912    /// Represents `#[rustc_scalable_vector(N)]`
913    RustcScalableVector {
914        /// The base multiple of lanes that are in a scalable vector, if provided. `element_count`
915        /// is not provided for representing tuple types.
916        element_count: Option<u16>,
917        span: Span,
918    },
919
920    /// Represents `#[rustc_should_not_be_called_on_const_items]`
921    RustcShouldNotBeCalledOnConstItems(Span),
922
923    /// Represents `#[rustc_simd_monomorphize_lane_limit = "N"]`.
924    RustcSimdMonomorphizeLaneLimit(Limit),
925
926    /// Represents `#[sanitize]`
927    ///
928    /// the on set and off set are distjoint since there's a third option: unset.
929    /// a node may not set the sanitizer setting in which case it inherits from parents.
930    /// rtsan is unset if None
931    Sanitize {
932        on_set: SanitizerSet,
933        off_set: SanitizerSet,
934        rtsan: Option<RtsanSetting>,
935        span: Span,
936    },
937
938    /// Represents `#[should_panic]`
939    ShouldPanic { reason: Option<Symbol>, span: Span },
940
941    /// Represents `#[rustc_skip_during_method_dispatch]`.
942    SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },
943
944    /// Represents `#[rustc_specialization_trait]`.
945    SpecializationTrait(Span),
946
947    /// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
948    Stability {
949        stability: Stability,
950        /// Span of the attribute.
951        span: Span,
952    },
953
954    /// Represents `#[rustc_std_internal_symbol]`.
955    StdInternalSymbol(Span),
956
957    /// Represents `#[target_feature(enable = "...")]` and
958    /// `#[unsafe(force_target_feature(enable = "...")]`.
959    TargetFeature { features: ThinVec<(Symbol, Span)>, attr_span: Span, was_forced: bool },
960
961    /// Represents `#[thread_local]`
962    ThreadLocal,
963
964    /// Represents `#[track_caller]`
965    TrackCaller(Span),
966
967    /// Represents `#[type_const]`.
968    TypeConst(Span),
969
970    /// Represents `#[type_length_limit]`
971    TypeLengthLimit { attr_span: Span, limit_span: Span, limit: Limit },
972
973    /// Represents `#[rustc_unsafe_specialization_marker]`.
974    UnsafeSpecializationMarker(Span),
975
976    /// Represents `#[unstable_feature_bound]`.
977    UnstableFeatureBound(ThinVec<(Symbol, Span)>),
978
979    /// Represents `#[used]`
980    Used { used_by: UsedBy, span: Span },
981
982    /// Represents `#[windows_subsystem]`.
983    WindowsSubsystem(WindowsSubsystemKind, Span),
984    // tidy-alphabetical-end
985}