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            AllowConstFnUnstable(..) => No,
23            AllowIncoherentImpl(..) => No,
24            AllowInternalUnsafe(..) => Yes,
25            AllowInternalUnstable(..) => Yes,
26            AsPtr(..) => Yes,
27            AutomaticallyDerived(..) => Yes,
28            BodyStability { .. } => No,
29            CfgAttrTrace => Yes,
30            CfgTrace(..) => Yes,
31            CfiEncoding { .. } => Yes,
32            Coinductive(..) => No,
33            Cold(..) => No,
34            CollapseDebugInfo(..) => Yes,
35            CompilerBuiltins => No,
36            Confusables { .. } => Yes,
37            ConstContinue(..) => No,
38            ConstStability { .. } => Yes,
39            ConstStabilityIndirect => No,
40            Coroutine(..) => No,
41            Coverage(..) => No,
42            CrateName { .. } => No,
43            CrateType(_) => No,
44            CustomMir(_, _, _) => Yes,
45            DebuggerVisualizer(..) => No,
46            DenyExplicitImpl(..) => No,
47            Deprecation { .. } => Yes,
48            DoNotRecommend { .. } => Yes,
49            Doc(_) => Yes,
50            DocComment { .. } => Yes,
51            Dummy => No,
52            DynIncompatibleTrait(..) => No,
53            EiiDeclaration(_) => Yes,
54            EiiForeignItem => No,
55            EiiImpls(..) => No,
56            ExportName { .. } => Yes,
57            ExportStable => No,
58            FfiConst(..) => No,
59            FfiPure(..) => No,
60            Fundamental { .. } => Yes,
61            Ignore { .. } => No,
62            Inline(..) => No,
63            InstructionSet(..) => No,
64            Link(..) => No,
65            LinkName { .. } => Yes, // Needed for rustdoc
66            LinkOrdinal { .. } => No,
67            LinkSection { .. } => Yes, // Needed for rustdoc
68            Linkage(..) => No,
69            LoopMatch(..) => No,
70            MacroEscape(..) => No,
71            MacroExport { .. } => Yes,
72            MacroTransparency(..) => Yes,
73            MacroUse { .. } => No,
74            Marker(..) => No,
75            MayDangle(..) => No,
76            MoveSizeLimit { .. } => No,
77            MustNotSupend { .. } => Yes,
78            MustUse { .. } => Yes,
79            Naked(..) => No,
80            NeedsAllocator => No,
81            NeedsPanicRuntime => No,
82            NoBuiltins => Yes,
83            NoCore(..) => No,
84            NoImplicitPrelude(..) => No,
85            NoLink => No,
86            NoMain => No,
87            NoMangle(..) => Yes, // Needed for rustdoc
88            NoStd(..) => No,
89            NonExhaustive(..) => Yes, // Needed for rustdoc
90            ObjcClass { .. } => No,
91            ObjcSelector { .. } => No,
92            Optimize(..) => No,
93            PanicRuntime => No,
94            ParenSugar(..) => No,
95            PassByValue(..) => Yes,
96            PatchableFunctionEntry { .. } => Yes,
97            Path(..) => No,
98            PatternComplexityLimit { .. } => No,
99            PinV2(..) => Yes,
100            Pointee(..) => No,
101            ProcMacro(..) => No,
102            ProcMacroAttribute(..) => No,
103            ProcMacroDerive { .. } => No,
104            ProfilerRuntime => No,
105            PubTransparent(..) => Yes,
106            RecursionLimit { .. } => No,
107            Repr { .. } => No,
108            RustcAllocator => No,
109            RustcAllocatorZeroed => No,
110            RustcAllocatorZeroedVariant { .. } => Yes,
111            RustcBuiltinMacro { .. } => Yes,
112            RustcCoherenceIsCore(..) => No,
113            RustcDeallocator => No,
114            RustcDumpDefParents => No,
115            RustcDumpItemBounds => No,
116            RustcDumpPredicates => No,
117            RustcDumpUserArgs => No,
118            RustcDumpVtable(..) => No,
119            RustcHasIncoherentInherentImpls => Yes,
120            RustcLayoutScalarValidRangeEnd(..) => Yes,
121            RustcLayoutScalarValidRangeStart(..) => Yes,
122            RustcLegacyConstGenerics { .. } => Yes,
123            RustcLintOptDenyFieldAccess { .. } => Yes,
124            RustcLintOptTy => Yes,
125            RustcLintQueryInstability => Yes,
126            RustcLintUntrackedQueryInformation => Yes,
127            RustcMain => No,
128            RustcMustImplementOneOf { .. } => No,
129            RustcNeverReturnsNullPointer => Yes,
130            RustcNoImplicitAutorefs => Yes,
131            RustcNounwind => No,
132            RustcObjectLifetimeDefault => No,
133            RustcOffloadKernel => Yes,
134            RustcPassIndirectlyInNonRusticAbis(..) => No,
135            RustcReallocator => No,
136            RustcScalableVector { .. } => Yes,
137            RustcShouldNotBeCalledOnConstItems(..) => Yes,
138            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate
139            RustcVariance => No,
140            RustcVarianceOfOpaques => No,
141            Sanitize { .. } => No,
142            ShouldPanic { .. } => No,
143            SkipDuringMethodDispatch { .. } => No,
144            SpecializationTrait(..) => No,
145            Stability { .. } => Yes,
146            StdInternalSymbol(..) => No,
147            TargetFeature { .. } => No,
148            ThreadLocal => No,
149            TrackCaller(..) => Yes,
150            TypeConst(..) => Yes,
151            TypeLengthLimit { .. } => No,
152            UnsafeSpecializationMarker(..) => No,
153            UnstableFeatureBound(..) => No,
154            Used { .. } => No,
155            WindowsSubsystem(..) => No,
156            // tidy-alphabetical-end
157        }
158    }
159}