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