rustc_hir/attrs/
encode_cross_crate.rs

1use crate::attrs::AttributeKind;
2
3#[derive(#[automatically_derived]
impl ::core::cmp::PartialEq for EncodeCrossCrate {
    #[inline]
    fn eq(&self, other: &EncodeCrossCrate) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq)]
4pub enum EncodeCrossCrate {
5    Yes,
6    No,
7}
8
9impl AttributeKind {
10    /// Whether this attribute should be encoded in metadata files.
11    ///
12    /// If this is "Yes", then another crate can do `tcx.get_all_attrs(did)` for a did in this crate, and get the attribute.
13    /// When this is No, the attribute is filtered out while encoding and other crate won't be able to observe it.
14    /// This can be unexpectedly good for performance, so unless necessary for cross-crate compilation, prefer No.
15    pub fn encode_cross_crate(&self) -> EncodeCrossCrate {
16        use AttributeKind::*;
17        use EncodeCrossCrate::*;
18
19        match self {
20            // tidy-alphabetical-start
21            Align { .. } => No,
22            AllowConstFnUnstable(..) => No,
23            AllowIncoherentImpl(..) => No,
24            AllowInternalUnsafe(..) => Yes,
25            AllowInternalUnstable(..) => Yes,
26            AsPtr(..) => Yes,
27            AutomaticallyDerived(..) => Yes,
28            BodyStability { .. } => No,
29            CfgAttrTrace => Yes,
30            CfgTrace(..) => Yes,
31            CfiEncoding { .. } => Yes,
32            Coinductive(..) => No,
33            Cold(..) => No,
34            CollapseDebugInfo(..) => Yes,
35            Confusables { .. } => Yes,
36            ConstContinue(..) => No,
37            ConstStability { .. } => Yes,
38            ConstStabilityIndirect => No,
39            Coroutine(..) => No,
40            Coverage(..) => No,
41            CrateName { .. } => No,
42            CustomMir(_, _, _) => Yes,
43            DebuggerVisualizer(..) => No,
44            DenyExplicitImpl(..) => No,
45            Deprecation { .. } => Yes,
46            DoNotImplementViaObject(..) => No,
47            DoNotRecommend { .. } => Yes,
48            Doc(_) => Yes,
49            DocComment { .. } => Yes,
50            Dummy => No,
51            EiiDeclaration(_) => Yes,
52            EiiForeignItem => No,
53            EiiImpls(..) => No,
54            ExportName { .. } => Yes,
55            ExportStable => No,
56            FfiConst(..) => No,
57            FfiPure(..) => No,
58            Fundamental { .. } => Yes,
59            Ignore { .. } => No,
60            Inline(..) => No,
61            InstructionSet(..) => No,
62            Link(..) => No,
63            LinkName { .. } => Yes, // Needed for rustdoc
64            LinkOrdinal { .. } => No,
65            LinkSection { .. } => Yes, // Needed for rustdoc
66            Linkage(..) => No,
67            LoopMatch(..) => No,
68            MacroEscape(..) => No,
69            MacroExport { .. } => Yes,
70            MacroTransparency(..) => Yes,
71            MacroUse { .. } => No,
72            Marker(..) => No,
73            MayDangle(..) => No,
74            MoveSizeLimit { .. } => No,
75            MustNotSupend { .. } => Yes,
76            MustUse { .. } => Yes,
77            Naked(..) => No,
78            NoCore(..) => No,
79            NoImplicitPrelude(..) => No,
80            NoLink => No,
81            NoMangle(..) => Yes, // Needed for rustdoc
82            NoStd(..) => No,
83            NonExhaustive(..) => Yes, // Needed for rustdoc
84            ObjcClass { .. } => No,
85            ObjcSelector { .. } => No,
86            Optimize(..) => No,
87            ParenSugar(..) => No,
88            PassByValue(..) => Yes,
89            Path(..) => No,
90            PatternComplexityLimit { .. } => No,
91            PinV2(..) => Yes,
92            Pointee(..) => No,
93            ProcMacro(..) => No,
94            ProcMacroAttribute(..) => No,
95            ProcMacroDerive { .. } => No,
96            PubTransparent(..) => Yes,
97            RecursionLimit { .. } => No,
98            Repr { .. } => No,
99            RustcBuiltinMacro { .. } => Yes,
100            RustcCoherenceIsCore(..) => No,
101            RustcDumpDefParents => No,
102            RustcDumpItemBounds => No,
103            RustcDumpPredicates => No,
104            RustcDumpUserArgs => No,
105            RustcDumpVtable(..) => No,
106            RustcHasIncoherentInherentImpls => Yes,
107            RustcLayoutScalarValidRangeEnd(..) => Yes,
108            RustcLayoutScalarValidRangeStart(..) => Yes,
109            RustcLegacyConstGenerics { .. } => Yes,
110            RustcLintDiagnostics => Yes,
111            RustcLintOptDenyFieldAccess { .. } => Yes,
112            RustcLintOptTy => Yes,
113            RustcLintQueryInstability => Yes,
114            RustcLintUntrackedQueryInformation => Yes,
115            RustcMain => No,
116            RustcMustImplementOneOf { .. } => No,
117            RustcNeverReturnsNullPointer => Yes,
118            RustcNoImplicitAutorefs => Yes,
119            RustcObjectLifetimeDefault => No,
120            RustcPassIndirectlyInNonRusticAbis(..) => No,
121            RustcScalableVector { .. } => Yes,
122            RustcShouldNotBeCalledOnConstItems(..) => Yes,
123            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
124            Sanitize { .. } => No,
125            ShouldPanic { .. } => No,
126            SkipDuringMethodDispatch { .. } => No,
127            SpecializationTrait(..) => No,
128            Stability { .. } => Yes,
129            StdInternalSymbol(..) => No,
130            TargetFeature { .. } => No,
131            ThreadLocal => No,
132            TrackCaller(..) => Yes,
133            TypeConst(..) => Yes,
134            TypeLengthLimit { .. } => No,
135            UnsafeSpecializationMarker(..) => No,
136            UnstableFeatureBound(..) => No,
137            Used { .. } => No,
138            WindowsSubsystem(..) => No,
139            // tidy-alphabetical-end
140        }
141    }
142}