compiler/rustc_attr_ir/src/encode_cross_crate.rs RUST 218 lines View on github.com → Search inside
1use crate::AttributeKind;23#[derive(PartialEq)]4pub enum EncodeCrossCrate {5    Yes,6    No,7}89impl 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::*;1819        match self {20            // tidy-alphabetical-start21            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            EiiImpl(..) => 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            InstrumentFn(..) => No,54            Lang(..) => Yes,55            Link(..) => No,56            LinkName { .. } => Yes, // Needed for rustdoc57            LinkOrdinal { .. } => No,58            LinkSection { .. } => Yes, // Needed for rustdoc59            Linkage(..) => 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 rustdoc78            NoStd => No,79            NonExhaustive(..) => Yes, // Needed for rustdoc80            OnConst { .. } => Yes,81            OnMove { .. } => Yes,82            OnTypeError { .. } => Yes,83            OnUnimplemented { .. } => Yes,84            OnUnknown { .. } => Yes,85            OnUnmatchedArgs { .. } => Yes,86            Opaque => Yes,87            Optimize(..) => No,88            PanicRuntime => No,89            PatchableFunctionEntry { .. } => Yes,90            Path(..) => No,91            PatternComplexityLimit { .. } => No,92            PinV2(..) => Yes,93            PreludeImport => No,94            ProcMacro => No,95            ProcMacroAttribute => No,96            ProcMacroDerive { .. } => No,97            ProfilerRuntime => No,98            RecursionLimit { .. } => No,99            ReexportTestHarnessMain(..) => No,100            RegisterTool { .. } => No,101            Repr { .. } => No,102            RustcAbi { .. } => No,103            RustcAlign { .. } => No,104            RustcAllocator => No,105            RustcAllocatorZeroed => No,106            RustcAllocatorZeroedVariant { .. } => Yes,107            RustcAllowConstFnUnstable(..) => No,108            RustcAllowIncoherentImpl(..) => No,109            RustcAllowLifetimeDependentSpecialization => No,110            RustcAsPtr => Yes,111            RustcAutodiff(..) => Yes,112            RustcBodyStability { .. } => No,113            RustcBuiltinMacro { .. } => Yes,114            RustcCanonicalSymbol => No,115            RustcCaptureAnalysis => No,116            RustcCguTestAttr { .. } => No,117            RustcClean { .. } => No,118            RustcCoherenceIsCore => No,119            RustcCoinductive => No,120            RustcComptime(..) => No, // Encoded directly in signature121            RustcConfusables { .. } => Yes,122            RustcConstStability { .. } => Yes,123            RustcConstStableIndirect => No,124            RustcConversionSuggestion => Yes,125            RustcDeallocator => No,126            RustcDelayedBugFromInsideQuery => No,127            RustcDenyExplicitImpl => No,128            RustcDeprecatedSafe2024 { .. } => Yes,129            RustcDiagnosticItem(..) => Yes,130            RustcDoNotConstCheck => Yes,131            RustcDocPrimitive(..) => Yes,132            RustcDummy => No,133            RustcDumpClauses => No,134            RustcDumpDefParents => No,135            RustcDumpDefPath(..) => No,136            RustcDumpGenerics => No,137            RustcDumpHiddenTypeOfOpaques => No,138            RustcDumpInferredOutlives => No,139            RustcDumpItemBounds => No,140            RustcDumpLayout(..) => No,141            RustcDumpObjectLifetimeDefaults => No,142            RustcDumpSymbolName(..) => Yes,143            RustcDumpUserArgs => No,144            RustcDumpVariances => No,145            RustcDumpVariancesOfOpaques => No,146            RustcDumpVtable(..) => No,147            RustcDynIncompatibleTrait(..) => No,148            RustcEffectiveVisibility => Yes,149            RustcEiiForeignItem => No,150            RustcEvaluateWhereClauses => Yes,151            RustcHasIncoherentInherentImpls => Yes,152            RustcIfThisChanged(..) => No,153            RustcInheritOverflowChecks => No,154            RustcInsignificantDtor => Yes,155            RustcIntrinsic => Yes,156            RustcIntrinsicConstStableIndirect => No,157            RustcLegacyConstGenerics { .. } => Yes,158            RustcLintOptDenyFieldAccess { .. } => Yes,159            RustcLintOptTy => Yes,160            RustcLintQueryInstability => Yes,161            RustcLintUntrackedQueryInformation => Yes,162            RustcMacroTransparency(..) => Yes,163            RustcMain => No,164            RustcMir(..) => Yes,165            RustcMustImplementOneOf { .. } => No,166            RustcMustMatchExhaustively(..) => Yes,167            RustcNeverReturnsNullPtr => Yes,168            RustcNeverTypeOptions { .. } => No,169            RustcNoImplicitAutorefs => Yes,170            RustcNoImplicitBounds => No,171            RustcNoMirInline => Yes,172            RustcNoWritable => Yes,173            RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`174            RustcNonnullOptimizationGuaranteed => Yes,175            RustcNounwind => No,176            RustcObjcClass { .. } => No,177            RustcObjcSelector { .. } => No,178            RustcOffloadKernel => Yes,179            RustcPanicsWhenZero => Yes,180            RustcParenSugar => No,181            RustcPassByValue => Yes,182            RustcPassIndirectlyInNonRusticAbis(..) => No,183            RustcPreserveUbChecks => No,184            RustcProcMacroDecls => No,185            RustcPubTransparent(..) => Yes,186            RustcReallocator => No,187            RustcRegions => No,188            RustcReservationImpl(..) => Yes,189            RustcScalableVector { .. } => Yes,190            RustcShouldNotBeCalledOnConstItems => Yes,191            RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate192            RustcSkipDuringMethodDispatch { .. } => No,193            RustcSpecializationTrait => No,194            RustcStdInternalSymbol => No,195            RustcStrictCoherence(..) => Yes,196            RustcTestEntrypointMarker => No,197            RustcTestMarker(..) => No,198            RustcThenThisWouldNeed(..) => No,199            RustcTrivialFieldReads => Yes,200            Sanitize { .. } => No,201            ShouldPanic { .. } => No,202            Splat(..) => Yes,203            Stability { .. } => Yes,204            TargetFeature { .. } => No,205            TestRunner(..) => Yes,206            ThreadLocal => No,207            TrackCaller(..) => Yes,208            TypeLengthLimit { .. } => No,209            Unroll(..) => No,210            UnstableFeatureBound(..) => No,211            UnstableRemoved(..) => Yes,212            Used { .. } => No,213            WindowsSubsystem(..) => No,214            // tidy-alphabetical-end215        }216    }217}

Code quality findings 2

Info: Wildcard imports (`use some::path::*;`) can obscure the origin of names and lead to conflicts. Prefer importing specific items explicitly.
info maintainability wildcard-import
use AttributeKind::*;
Info: Wildcard imports (`use some::path::*;`) can obscure the origin of names and lead to conflicts. Prefer importing specific items explicitly.
info maintainability wildcard-import
use EncodeCrossCrate::*;

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.