rustc_middle::query::keys

Trait Key

Source
pub trait Key: Sized {
    type Cache<V>;

    // Required method
    fn default_span(&self, tcx: TyCtxt<'_>) -> Span;

    // Provided methods
    fn key_as_def_id(&self) -> Option<DefId> { ... }
    fn ty_def_id(&self) -> Option<DefId> { ... }
}
Expand description

The Key trait controls what types can legally be used as the key for a query.

Required Associated Types§

Source

type Cache<V>

Required Methods§

Source

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

In the event that a cycle occurs, if no explicit span has been given for a query with key self, what span should we use?

Provided Methods§

Source

fn key_as_def_id(&self) -> Option<DefId>

If the key is a DefId or DefId–equivalent, return that DefId. Otherwise, return None.

Source

fn ty_def_id(&self) -> Option<DefId>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Key for (CrateNum, DefId)

Source§

type Cache<V> = DefaultCache<(CrateNum, DefId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (CrateNum, SimplifiedType)

Source§

type Cache<V> = DefaultCache<(CrateNum, SimplifiedType<DefId>), V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

impl Key for (DefId, DefId)

Source§

type Cache<V> = DefaultCache<(DefId, DefId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (DefId, LocalDefId)

Source§

type Cache<V> = DefaultCache<(DefId, LocalDefId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (DefId, Ident)

Source§

type Cache<V> = DefaultCache<(DefId, Ident), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for (DefId, SimplifiedType)

Source§

type Cache<V> = DefaultCache<(DefId, SimplifiedType<DefId>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (LocalDefId, DefId)

Source§

type Cache<V> = DefaultCache<(LocalDefId, DefId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (LocalDefId, LocalDefId)

Source§

type Cache<V> = DefaultCache<(LocalDefId, LocalDefId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (LocalDefId, LocalDefId, Ident)

Source§

type Cache<V> = DefaultCache<(LocalDefId, LocalDefId, Ident), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl Key for (LocalDefId, HirId)

Source§

type Cache<V> = DefaultCache<(LocalDefId, HirId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for (Symbol, u32, u32)

Source§

type Cache<V> = DefaultCache<(Symbol, u32, u32), V>

Source§

fn default_span(&self, _tcx: TyCtxt<'_>) -> Span

Source§

impl Key for Option<Symbol>

Source§

type Cache<V> = DefaultCache<Option<Symbol>, V>

Source§

fn default_span(&self, _tcx: TyCtxt<'_>) -> Span

Source§

impl Key for ()

Source§

type Cache<V> = SingleCache<V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

impl Key for CrateNum

Source§

type Cache<V> = VecCache<CrateNum, V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

impl Key for DefId

Source§

type Cache<V> = DefIdCache<V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for LocalDefId

Source§

type Cache<V> = VecCache<LocalDefId, V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for LocalModDefId

Source§

type Cache<V> = DefaultCache<LocalModDefId, V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for ModDefId

Source§

type Cache<V> = DefaultCache<ModDefId, V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for Symbol

Source§

type Cache<V> = DefaultCache<Symbol, V>

Source§

fn default_span(&self, _tcx: TyCtxt<'_>) -> Span

Source§

impl Key for HirId

Source§

type Cache<V> = DefaultCache<HirId, V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl Key for OwnerId

Source§

type Cache<V> = VecCache<OwnerId, V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

fn key_as_def_id(&self) -> Option<DefId>

Source§

impl<'tcx> Key for (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>)

Source§

type Cache<V> = DefaultCache<(ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>), V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

fn ty_def_id(&self) -> Option<DefId>

Source§

impl<'tcx> Key for (Instance<'tcx>, &'tcx List<Ty<'tcx>>)

Source§

type Cache<V> = DefaultCache<(Instance<'tcx>, &'tcx RawList<(), Ty<'tcx>>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (Instance<'tcx>, LocalDefId)

Source§

type Cache<V> = DefaultCache<(Instance<'tcx>, LocalDefId), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (Predicate<'tcx>, WellFormedLoc)

Source§

type Cache<V> = DefaultCache<(Predicate<'tcx>, WellFormedLoc), V>

Source§

fn default_span(&self, _tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (ParamEnv<'tcx>, TraitRef<'tcx>)

Source§

type Cache<V> = DefaultCache<(ParamEnv<'tcx>, TraitRef<TyCtxt<'tcx>>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (Ty<'tcx>, ValTree<'tcx>)

Source§

type Cache<V> = DefaultCache<(Ty<'tcx>, ValTree<'tcx>), V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>)

Source§

type Cache<V> = DefaultCache<(Ty<'tcx>, Option<Binder<TyCtxt<'tcx>, ExistentialTraitRef<TyCtxt<'tcx>>>>), V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>)

Source§

type Cache<V> = DefaultCache<(Ty<'tcx>, Ty<'tcx>), V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (Ty<'tcx>, VariantIdx)

Source§

type Cache<V> = DefaultCache<(Ty<'tcx>, VariantIdx), V>

Source§

fn default_span(&self, _tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ParamEnv<'tcx>)

Source§

type Cache<V> = DefaultCache<(DefId, Ty<'tcx>, &'tcx RawList<(), GenericArg<'tcx>>, ParamEnv<'tcx>), V>

Source§

fn default_span(&self, _tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>)

Source§

type Cache<V> = DefaultCache<(DefId, &'tcx RawList<(), GenericArg<'tcx>>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (LocalDefId, DefId, GenericArgsRef<'tcx>)

Source§

type Cache<V> = DefaultCache<(LocalDefId, DefId, &'tcx RawList<(), GenericArg<'tcx>>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (UnevaluatedConst<'tcx>, UnevaluatedConst<'tcx>)

Source§

type Cache<V> = DefaultCache<(UnevaluatedConst<TyCtxt<'tcx>>, UnevaluatedConst<TyCtxt<'tcx>>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)

Source§

type Cache<V> = DefaultCache<(Binder<TyCtxt<'tcx>, TraitRef<TyCtxt<'tcx>>>, Binder<TyCtxt<'tcx>, TraitRef<TyCtxt<'tcx>>>), V>

Source§

fn default_span(&self, tcx: TyCtxt<'_>) -> Span

Source§

impl<'tcx> Key for (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)

Source§

type Cache<V> = DefaultCache<(Binder<TyCtxt<'tcx>, FnSig<TyCtxt<'tcx>>>, &'tcx RawList<(), Ty<'tcx>>), V>

Source§

fn default_span(&self, _: TyCtxt<'_>) -> Span

Implementors§

Source§

impl Key for SimplifiedType

Source§

type Cache<V> = DefaultCache<SimplifiedType<DefId>, V>

Source§

impl<'tcx> Key for InstanceKind<'tcx>

Source§

type Cache<V> = DefaultCache<InstanceKind<'tcx>, V>

Source§

impl<'tcx> Key for GlobalId<'tcx>

Source§

type Cache<V> = DefaultCache<GlobalId<'tcx>, V>

Source§

impl<'tcx> Key for LitToConstInput<'tcx>

Source§

type Cache<V> = DefaultCache<LitToConstInput<'tcx>, V>

Source§

impl<'tcx> Key for Const<'tcx>

Source§

type Cache<V> = DefaultCache<Const<'tcx>, V>

Source§

impl<'tcx> Key for GenericArg<'tcx>

Source§

type Cache<V> = DefaultCache<GenericArg<'tcx>, V>

Source§

impl<'tcx> Key for Instance<'tcx>

Source§

type Cache<V> = DefaultCache<Instance<'tcx>, V>

Source§

impl<'tcx> Key for ParamEnv<'tcx>

Source§

type Cache<V> = DefaultCache<ParamEnv<'tcx>, V>

Source§

impl<'tcx> Key for Ty<'tcx>

Source§

type Cache<V> = DefaultCache<Ty<'tcx>, V>

Source§

impl<'tcx> Key for GenericArgsRef<'tcx>

Source§

type Cache<V> = DefaultCache<&'tcx RawList<(), GenericArg<'tcx>>, V>

Source§

impl<'tcx> Key for TyAndLayout<'tcx>

Source§

type Cache<V> = DefaultCache<TyAndLayout<'tcx, Ty<'tcx>>, V>

Source§

impl<'tcx> Key for PolyExistentialTraitRef<'tcx>

Source§

type Cache<V> = DefaultCache<Binder<TyCtxt<'tcx>, ExistentialTraitRef<TyCtxt<'tcx>>>, V>

Source§

impl<'tcx> Key for PolyTraitRef<'tcx>

Source§

type Cache<V> = DefaultCache<Binder<TyCtxt<'tcx>, TraitRef<TyCtxt<'tcx>>>, V>

Source§

impl<'tcx> Key for TraitRef<'tcx>

Source§

type Cache<V> = DefaultCache<TraitRef<TyCtxt<'tcx>>, V>

Source§

impl<'tcx> Key for Clauses<'tcx>

Source§

type Cache<V> = DefaultCache<&'tcx RawList<TypeInfo, Clause<'tcx>>, V>

Source§

impl<'tcx, T: Clone> Key for CanonicalQueryInput<'tcx, T>

Canonical query goals correspond to abstract trait operations that are not tied to any crate in particular.

Source§

type Cache<V> = DefaultCache<CanonicalQueryInput<TyCtxt<'tcx>, T>, V>

Source§

impl<'tcx, T: Key> Key for ParamEnvAnd<'tcx, T>

Source§

type Cache<V> = DefaultCache<ParamEnvAnd<'tcx, T>, V>