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            LintAttributes { .. } => No,
60            LoopMatch(..) => No,
61            MacroEscape(..) => No,
62            MacroExport { .. } => Yes,
63            MacroUse { .. } => No,
64            Marker(..) => No,
65            MayDangle(..) => No,
66            MoveSizeLimit { .. } => No,
67            MustNotSupend { .. } => Yes,
68            MustUse { .. } => Yes,
69            Naked(..) => No,
70            NeedsAllocator => No,
71            NeedsPanicRuntime => No,
72            NoBuiltins => Yes,
73            NoCore(..) => No,
74            NoImplicitPrelude(..) => No,
75            NoLink => No,
76            NoMain => No,
77            NoMangle(..) => Yes, // Needed for rustdoc
78            NoStd(..) => No,
79            NonExhaustive(..) => Yes, // Needed for rustdoc
80            OnConst { .. } => Yes,
81            OnMove { .. } => Yes,
82            OnUnimplemented { .. } => 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            RustcDefPath(..) => No,
121            RustcDelayedBugFromInsideQuery => No,
122            RustcDenyExplicitImpl(..) => No,
123            RustcDeprecatedSafe2024 { .. } => Yes,
124            RustcDiagnosticItem(..) => Yes,
125            RustcDoNotConstCheck => Yes,
126            RustcDocPrimitive(..) => Yes,
127            RustcDummy => No,
128            RustcDumpDefParents => No,
129            RustcDumpInferredOutlives => No,
130            RustcDumpItemBounds => No,
131            RustcDumpObjectLifetimeDefaults => No,
132            RustcDumpPredicates => No,
133            RustcDumpUserArgs => No,
134            RustcDumpVariances => No,
135            RustcDumpVariancesOfOpaques => No,
136            RustcDumpVtable(..) => No,
137            RustcDynIncompatibleTrait(..) => No,
138            RustcEffectiveVisibility => Yes,
139            RustcEiiForeignItem => No,
140            RustcEvaluateWhereClauses => Yes,
141            RustcHasIncoherentInherentImpls => Yes,
142            RustcHiddenTypeOfOpaques => No,
143            RustcIfThisChanged(..) => No,
144            RustcInheritOverflowChecks => No,
145            RustcInsignificantDtor => Yes,
146            RustcIntrinsic => Yes,
147            RustcIntrinsicConstStableIndirect => No,
148            RustcLayout(..) => No,
149            RustcLayoutScalarValidRangeEnd(..) => Yes,
150            RustcLayoutScalarValidRangeStart(..) => Yes,
151            RustcLegacyConstGenerics { .. } => Yes,
152            RustcLintOptDenyFieldAccess { .. } => Yes,
153            RustcLintOptTy => Yes,
154            RustcLintQueryInstability => Yes,
155            RustcLintUntrackedQueryInformation => Yes,
156            RustcMacroTransparency(..) => Yes,
157            RustcMain => No,
158            RustcMir(..) => Yes,
159            RustcMustImplementOneOf { .. } => No,
160            RustcNeverReturnsNullPtr => Yes,
161            RustcNeverTypeOptions { .. } => No,
162            RustcNoImplicitAutorefs => Yes,
163            RustcNoImplicitBounds => No,
164            RustcNoMirInline => Yes,
165            RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
166            RustcNonnullOptimizationGuaranteed => Yes,
167            RustcNounwind => No,
168            RustcObjcClass { .. } => No,
169            RustcObjcSelector { .. } => No,
170            RustcOffloadKernel => Yes,
171            RustcParenSugar(..) => No,
172            RustcPassByValue(..) => Yes,
173            RustcPassIndirectlyInNonRusticAbis(..) => No,
174            RustcPreserveUbChecks => No,
175            RustcProcMacroDecls => No,
176            RustcPubTransparent(..) => Yes,
177            RustcReallocator => No,
178            RustcRegions => No,
179            RustcReservationImpl(..) => Yes,
180            RustcScalableVector { .. } => Yes,
181            RustcShouldNotBeCalledOnConstItems(..) => Yes,
182            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
183            RustcSkipDuringMethodDispatch { .. } => No,
184            RustcSpecializationTrait(..) => No,
185            RustcStdInternalSymbol(..) => No,
186            RustcStrictCoherence(..) => Yes,
187            RustcSymbolName(..) => Yes,
188            RustcTestMarker(..) => No,
189            RustcThenThisWouldNeed(..) => No,
190            RustcTrivialFieldReads => Yes,
191            RustcUnsafeSpecializationMarker(..) => No,
192            Sanitize { .. } => No,
193            ShouldPanic { .. } => No,
194            Stability { .. } => Yes,
195            TargetFeature { .. } => No,
196            TestRunner(..) => Yes,
197            ThreadLocal => No,
198            TrackCaller(..) => Yes,
199            TypeLengthLimit { .. } => No,
200            UnstableFeatureBound(..) => No,
201            Used { .. } => No,
202            WindowsSubsystem(..) => No,
203            // tidy-alphabetical-end
204        }
205    }
206}