rustc_hir/attrs/
data_structures.rs

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