rustc_middle::query

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 def_id_for_ty_in_cycle(&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 def_id_for_ty_in_cycle(&self) -> Option<DefId>

Used to detect when ADT def ids are used as keys in a cycle for better error reporting.

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§

impl Key for (CrateNum, SimplifiedType)

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§

impl Key for (DefId, Ident)

Source§

impl Key for (DefId, SimplifiedType)

Source§

impl Key for (LocalDefId, HirId)

Source§

impl Key for (LocalDefId, DefId)

Source§

impl Key for (LocalDefId, LocalDefId)

Source§

impl Key for (LocalDefId, LocalDefId, Ident)

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§

impl Key for ()

Source§

type Cache<V> = SingleCache<V>

Source§

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

Source§

impl Key for HirId

Source§

impl Key for OwnerId

Source§

impl Key for CrateNum

Source§

impl Key for DefId

Source§

impl Key for LocalDefId

Source§

impl Key for LocalModDefId

Source§

impl Key for ModDefId

Source§

impl Key for Symbol

Source§

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

Source§

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

Source§

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

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 (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>, CollectionMode)

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

Source§

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

Source§

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

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§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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 ParamEnvAnd<'tcx, Ty<'tcx>>

Source§

type Cache<V> = DefaultCache<ParamEnvAnd<'tcx, Ty<'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§

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§

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§

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