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            OnMove { .. } => Yes,
81            OnUnimplemented { .. } => Yes,
82            OnUnknown { .. } => Yes,
83            Optimize(..) => No,
84            PanicRuntime => No,
85            PatchableFunctionEntry { .. } => Yes,
86            Path(..) => No,
87            PatternComplexityLimit { .. } => No,
88            PinV2(..) => Yes,
89            Pointee(..) => No,
90            PreludeImport => No,
91            ProcMacro(..) => No,
92            ProcMacroAttribute(..) => No,
93            ProcMacroDerive { .. } => No,
94            ProfilerRuntime => No,
95            RecursionLimit { .. } => No,
96            ReexportTestHarnessMain(..) => No,
97            RegisterTool(..) => No,
98            Repr { .. } => No,
99            RustcAbi { .. } => No,
100            RustcAlign { .. } => No,
101            RustcAllocator => No,
102            RustcAllocatorZeroed => No,
103            RustcAllocatorZeroedVariant { .. } => Yes,
104            RustcAllowConstFnUnstable(..) => No,
105            RustcAllowIncoherentImpl(..) => No,
106            RustcAsPtr(..) => Yes,
107            RustcAutodiff(..) => Yes,
108            RustcBodyStability { .. } => No,
109            RustcBuiltinMacro { .. } => Yes,
110            RustcCaptureAnalysis => No,
111            RustcCguTestAttr { .. } => No,
112            RustcClean { .. } => No,
113            RustcCoherenceIsCore(..) => No,
114            RustcCoinductive(..) => No,
115            RustcConfusables { .. } => Yes,
116            RustcConstStability { .. } => Yes,
117            RustcConstStableIndirect => No,
118            RustcConversionSuggestion => Yes,
119            RustcDeallocator => No,
120            RustcDelayedBugFromInsideQuery => No,
121            RustcDenyExplicitImpl(..) => No,
122            RustcDeprecatedSafe2024 { .. } => Yes,
123            RustcDiagnosticItem(..) => Yes,
124            RustcDoNotConstCheck => Yes,
125            RustcDocPrimitive(..) => Yes,
126            RustcDummy => No,
127            RustcDumpDefParents => No,
128            RustcDumpDefPath(..) => No,
129            RustcDumpHiddenTypeOfOpaques => No,
130            RustcDumpInferredOutlives => No,
131            RustcDumpItemBounds => No,
132            RustcDumpLayout(..) => No,
133            RustcDumpObjectLifetimeDefaults => No,
134            RustcDumpPredicates => No,
135            RustcDumpSymbolName(..) => Yes,
136            RustcDumpUserArgs => No,
137            RustcDumpVariances => No,
138            RustcDumpVariancesOfOpaques => No,
139            RustcDumpVtable(..) => No,
140            RustcDynIncompatibleTrait(..) => No,
141            RustcEffectiveVisibility => Yes,
142            RustcEiiForeignItem => No,
143            RustcEvaluateWhereClauses => Yes,
144            RustcHasIncoherentInherentImpls => Yes,
145            RustcIfThisChanged(..) => No,
146            RustcInheritOverflowChecks => No,
147            RustcInsignificantDtor => Yes,
148            RustcIntrinsic => Yes,
149            RustcIntrinsicConstStableIndirect => No,
150            RustcLayoutScalarValidRangeEnd(..) => Yes,
151            RustcLayoutScalarValidRangeStart(..) => Yes,
152            RustcLegacyConstGenerics { .. } => Yes,
153            RustcLintOptDenyFieldAccess { .. } => Yes,
154            RustcLintOptTy => Yes,
155            RustcLintQueryInstability => Yes,
156            RustcLintUntrackedQueryInformation => Yes,
157            RustcMacroTransparency(..) => Yes,
158            RustcMain => No,
159            RustcMir(..) => Yes,
160            RustcMustImplementOneOf { .. } => No,
161            RustcMustMatchExhaustively(..) => Yes,
162            RustcNeverReturnsNullPtr => Yes,
163            RustcNeverTypeOptions { .. } => No,
164            RustcNoImplicitAutorefs => Yes,
165            RustcNoImplicitBounds => No,
166            RustcNoMirInline => Yes,
167            RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
168            RustcNonnullOptimizationGuaranteed => Yes,
169            RustcNounwind => No,
170            RustcObjcClass { .. } => No,
171            RustcObjcSelector { .. } => No,
172            RustcOffloadKernel => Yes,
173            RustcParenSugar(..) => No,
174            RustcPassByValue(..) => Yes,
175            RustcPassIndirectlyInNonRusticAbis(..) => No,
176            RustcPreserveUbChecks => No,
177            RustcProcMacroDecls => No,
178            RustcPubTransparent(..) => Yes,
179            RustcReallocator => No,
180            RustcRegions => No,
181            RustcReservationImpl(..) => Yes,
182            RustcScalableVector { .. } => Yes,
183            RustcShouldNotBeCalledOnConstItems(..) => Yes,
184            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
185            RustcSkipDuringMethodDispatch { .. } => No,
186            RustcSpecializationTrait(..) => No,
187            RustcStdInternalSymbol(..) => No,
188            RustcStrictCoherence(..) => Yes,
189            RustcTestMarker(..) => No,
190            RustcThenThisWouldNeed(..) => No,
191            RustcTrivialFieldReads => Yes,
192            RustcUnsafeSpecializationMarker(..) => No,
193            Sanitize { .. } => No,
194            ShouldPanic { .. } => No,
195            Stability { .. } => Yes,
196            TargetFeature { .. } => No,
197            TestRunner(..) => Yes,
198            ThreadLocal => No,
199            TrackCaller(..) => Yes,
200            TypeLengthLimit { .. } => No,
201            UnstableFeatureBound(..) => No,
202            Used { .. } => No,
203            WindowsSubsystem(..) => No,
204            // tidy-alphabetical-end
205        }
206    }
207}