Skip to main content

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            AllowInternalUnsafe(..) => Yes,
22            AllowInternalUnstable(..) => Yes,
23            AutomaticallyDerived(..) => Yes,
24            CfgAttrTrace => Yes,
25            CfgTrace(..) => Yes,
26            CfiEncoding { .. } => Yes,
27            Cold(..) => No,
28            CollapseDebugInfo(..) => Yes,
29            CompilerBuiltins => No,
30            ConstContinue(..) => No,
31            Coroutine(..) => No,
32            Coverage(..) => No,
33            CrateName { .. } => No,
34            CrateType(_) => No,
35            CustomMir(_, _, _) => Yes,
36            DebuggerVisualizer(..) => No,
37            DefaultLibAllocator => No,
38            Deprecated { .. } => Yes,
39            DoNotRecommend { .. } => Yes,
40            Doc(_) => Yes,
41            DocComment { .. } => Yes,
42            EiiDeclaration(_) => Yes,
43            EiiImpls(..) => No,
44            ExportName { .. } => Yes,
45            ExportStable => No,
46            Feature(..) => No,
47            FfiConst(..) => No,
48            FfiPure(..) => No,
49            Fundamental { .. } => Yes,
50            Ignore { .. } => No,
51            Inline(..) => No,
52            InstructionSet(..) => No,
53            Lang(..) => Yes,
54            Link(..) => No,
55            LinkName { .. } => Yes, // Needed for rustdoc
56            LinkOrdinal { .. } => No,
57            LinkSection { .. } => Yes, // Needed for rustdoc
58            Linkage(..) => No,
59            LoopMatch(..) => No,
60            MacroEscape(..) => No,
61            MacroExport { .. } => Yes,
62            MacroUse { .. } => No,
63            Marker(..) => No,
64            MayDangle(..) => No,
65            MoveSizeLimit { .. } => No,
66            MustNotSupend { .. } => Yes,
67            MustUse { .. } => Yes,
68            Naked(..) => No,
69            NeedsAllocator => No,
70            NeedsPanicRuntime => No,
71            NoBuiltins => Yes,
72            NoCore(..) => No,
73            NoImplicitPrelude(..) => No,
74            NoLink => No,
75            NoMain => No,
76            NoMangle(..) => Yes, // Needed for rustdoc
77            NoStd(..) => No,
78            NonExhaustive(..) => Yes, // Needed for rustdoc
79            OnConst { .. } => Yes,
80            OnUnimplemented { .. } => Yes,
81            Optimize(..) => No,
82            PanicRuntime => No,
83            PatchableFunctionEntry { .. } => Yes,
84            Path(..) => No,
85            PatternComplexityLimit { .. } => No,
86            PinV2(..) => Yes,
87            Pointee(..) => No,
88            PreludeImport => No,
89            ProcMacro(..) => No,
90            ProcMacroAttribute(..) => No,
91            ProcMacroDerive { .. } => No,
92            ProfilerRuntime => No,
93            RecursionLimit { .. } => No,
94            ReexportTestHarnessMain(..) => No,
95            RegisterTool(..) => No,
96            Repr { .. } => No,
97            RustcAbi { .. } => No,
98            RustcAlign { .. } => No,
99            RustcAllocator => No,
100            RustcAllocatorZeroed => No,
101            RustcAllocatorZeroedVariant { .. } => Yes,
102            RustcAllowConstFnUnstable(..) => No,
103            RustcAllowIncoherentImpl(..) => No,
104            RustcAsPtr(..) => Yes,
105            RustcAutodiff(..) => Yes,
106            RustcBodyStability { .. } => No,
107            RustcBuiltinMacro { .. } => Yes,
108            RustcCaptureAnalysis => No,
109            RustcCguTestAttr { .. } => No,
110            RustcClean { .. } => No,
111            RustcCoherenceIsCore(..) => No,
112            RustcCoinductive(..) => No,
113            RustcConfusables { .. } => Yes,
114            RustcConstStability { .. } => Yes,
115            RustcConstStableIndirect => No,
116            RustcConversionSuggestion => Yes,
117            RustcDeallocator => No,
118            RustcDefPath(..) => No,
119            RustcDelayedBugFromInsideQuery => No,
120            RustcDenyExplicitImpl(..) => No,
121            RustcDeprecatedSafe2024 { .. } => Yes,
122            RustcDiagnosticItem(..) => Yes,
123            RustcDoNotConstCheck => Yes,
124            RustcDocPrimitive(..) => Yes,
125            RustcDummy => No,
126            RustcDumpDefParents => No,
127            RustcDumpItemBounds => No,
128            RustcDumpPredicates => No,
129            RustcDumpUserArgs => No,
130            RustcDumpVtable(..) => No,
131            RustcDynIncompatibleTrait(..) => No,
132            RustcEffectiveVisibility => Yes,
133            RustcEiiForeignItem => No,
134            RustcEvaluateWhereClauses => Yes,
135            RustcHasIncoherentInherentImpls => Yes,
136            RustcHiddenTypeOfOpaques => No,
137            RustcIfThisChanged(..) => No,
138            RustcInheritOverflowChecks => No,
139            RustcInsignificantDtor => Yes,
140            RustcIntrinsic => Yes,
141            RustcIntrinsicConstStableIndirect => No,
142            RustcLayout(..) => No,
143            RustcLayoutScalarValidRangeEnd(..) => Yes,
144            RustcLayoutScalarValidRangeStart(..) => Yes,
145            RustcLegacyConstGenerics { .. } => Yes,
146            RustcLintOptDenyFieldAccess { .. } => Yes,
147            RustcLintOptTy => Yes,
148            RustcLintQueryInstability => Yes,
149            RustcLintUntrackedQueryInformation => Yes,
150            RustcMacroTransparency(..) => Yes,
151            RustcMain => No,
152            RustcMir(..) => Yes,
153            RustcMustImplementOneOf { .. } => No,
154            RustcNeverReturnsNullPtr => Yes,
155            RustcNeverTypeOptions { .. } => No,
156            RustcNoImplicitAutorefs => Yes,
157            RustcNoImplicitBounds => No,
158            RustcNoMirInline => Yes,
159            RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
160            RustcNonnullOptimizationGuaranteed => Yes,
161            RustcNounwind => No,
162            RustcObjcClass { .. } => No,
163            RustcObjcSelector { .. } => No,
164            RustcObjectLifetimeDefault => No,
165            RustcOffloadKernel => Yes,
166            RustcOutlives => No,
167            RustcParenSugar(..) => No,
168            RustcPassByValue(..) => Yes,
169            RustcPassIndirectlyInNonRusticAbis(..) => No,
170            RustcPreserveUbChecks => No,
171            RustcProcMacroDecls => No,
172            RustcPubTransparent(..) => Yes,
173            RustcReallocator => No,
174            RustcRegions => No,
175            RustcReservationImpl(..) => Yes,
176            RustcScalableVector { .. } => Yes,
177            RustcShouldNotBeCalledOnConstItems(..) => Yes,
178            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
179            RustcSkipDuringMethodDispatch { .. } => No,
180            RustcSpecializationTrait(..) => No,
181            RustcStdInternalSymbol(..) => No,
182            RustcStrictCoherence(..) => Yes,
183            RustcSymbolName(..) => Yes,
184            RustcTestMarker(..) => No,
185            RustcThenThisWouldNeed(..) => No,
186            RustcTrivialFieldReads => Yes,
187            RustcUnsafeSpecializationMarker(..) => No,
188            RustcVariance => No,
189            RustcVarianceOfOpaques => No,
190            Sanitize { .. } => No,
191            ShouldPanic { .. } => No,
192            Stability { .. } => Yes,
193            TargetFeature { .. } => No,
194            TestRunner(..) => Yes,
195            ThreadLocal => No,
196            TrackCaller(..) => Yes,
197            TypeLengthLimit { .. } => No,
198            UnstableFeatureBound(..) => No,
199            Used { .. } => No,
200            WindowsSubsystem(..) => No,
201            // tidy-alphabetical-end
202        }
203    }
204}