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            RustcDumpInferredOutlives => No,
128            RustcDumpItemBounds => No,
129            RustcDumpObjectLifetimeDefaults => No,
130            RustcDumpPredicates => No,
131            RustcDumpUserArgs => No,
132            RustcDumpVariances => No,
133            RustcDumpVariancesOfOpaques => No,
134            RustcDumpVtable(..) => No,
135            RustcDynIncompatibleTrait(..) => No,
136            RustcEffectiveVisibility => Yes,
137            RustcEiiForeignItem => No,
138            RustcEvaluateWhereClauses => Yes,
139            RustcHasIncoherentInherentImpls => Yes,
140            RustcHiddenTypeOfOpaques => No,
141            RustcIfThisChanged(..) => No,
142            RustcInheritOverflowChecks => No,
143            RustcInsignificantDtor => Yes,
144            RustcIntrinsic => Yes,
145            RustcIntrinsicConstStableIndirect => No,
146            RustcLayout(..) => No,
147            RustcLayoutScalarValidRangeEnd(..) => Yes,
148            RustcLayoutScalarValidRangeStart(..) => Yes,
149            RustcLegacyConstGenerics { .. } => Yes,
150            RustcLintOptDenyFieldAccess { .. } => Yes,
151            RustcLintOptTy => Yes,
152            RustcLintQueryInstability => Yes,
153            RustcLintUntrackedQueryInformation => Yes,
154            RustcMacroTransparency(..) => Yes,
155            RustcMain => No,
156            RustcMir(..) => Yes,
157            RustcMustImplementOneOf { .. } => No,
158            RustcNeverReturnsNullPtr => Yes,
159            RustcNeverTypeOptions { .. } => No,
160            RustcNoImplicitAutorefs => Yes,
161            RustcNoImplicitBounds => No,
162            RustcNoMirInline => Yes,
163            RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
164            RustcNonnullOptimizationGuaranteed => Yes,
165            RustcNounwind => No,
166            RustcObjcClass { .. } => No,
167            RustcObjcSelector { .. } => No,
168            RustcOffloadKernel => Yes,
169            RustcParenSugar(..) => No,
170            RustcPassByValue(..) => Yes,
171            RustcPassIndirectlyInNonRusticAbis(..) => No,
172            RustcPreserveUbChecks => No,
173            RustcProcMacroDecls => No,
174            RustcPubTransparent(..) => Yes,
175            RustcReallocator => No,
176            RustcRegions => No,
177            RustcReservationImpl(..) => Yes,
178            RustcScalableVector { .. } => Yes,
179            RustcShouldNotBeCalledOnConstItems(..) => Yes,
180            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
181            RustcSkipDuringMethodDispatch { .. } => No,
182            RustcSpecializationTrait(..) => No,
183            RustcStdInternalSymbol(..) => No,
184            RustcStrictCoherence(..) => Yes,
185            RustcSymbolName(..) => Yes,
186            RustcTestMarker(..) => No,
187            RustcThenThisWouldNeed(..) => No,
188            RustcTrivialFieldReads => Yes,
189            RustcUnsafeSpecializationMarker(..) => 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}