Trait rustc_middle::query::keys::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>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Key for (CrateNum, DefId)

§

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

source§

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

source§

impl Key for (CrateNum, SimplifiedType)

source§

impl Key for (DefId, DefId)

§

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

source§

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

source§

impl Key for (DefId, LocalDefId)

§

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

source§

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

source§

impl Key for (DefId, Ident)

§

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§

impl Key for (LocalDefId, HirId)

source§

impl Key for (LocalDefId, DefId)

§

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

source§

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

source§

impl Key for (LocalDefId, LocalDefId)

source§

impl Key for (LocalDefId, LocalDefId, Ident)

source§

impl Key for (Symbol, u32, u32)

§

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

source§

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

source§

impl Key for Option<Symbol>

§

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

source§

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

source§

impl Key for ()

§

type Cache<V> = SingleCache<V>

source§

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

source§

impl Key for HirId

source§

impl Key for OwnerId

§

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 Key for CrateNum

§

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

source§

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

source§

impl Key for DefId

§

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§

impl Key for LocalModDefId

source§

impl Key for ModDefId

source§

impl Key for Symbol

§

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

source§

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

source§

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

§

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 (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ParamEnv<'tcx>)

§

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>)

§

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>)

§

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

source§

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

source§

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

§

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)

§

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

source§

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

source§

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

§

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>)

§

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>)

§

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>>)

§

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>, VariantIdx)

§

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

source§

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

source§

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

§

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

source§

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

source§

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

source§

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

§

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>>)

§

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§

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

§

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

source§

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

§

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

source§

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

source§

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

§

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

source§

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

§

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

source§

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

§

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

source§

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

§

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

source§

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

§

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

source§

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

§

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

source§

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

§

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

source§

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

source§

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

§

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

source§

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

§

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

source§

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

§

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

source§

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

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

§

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

source§

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

§

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