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§
Required Methods§
sourcefn default_span(&self, tcx: TyCtxt<'_>) -> Span
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§
sourcefn key_as_def_id(&self) -> Option<DefId>
fn key_as_def_id(&self) -> Option<DefId>
If the key is a DefId
or DefId
–equivalent, return that DefId
.
Otherwise, return None
.
fn ty_def_id(&self) -> Option<DefId>
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl Key for (CrateNum, SimplifiedType)
impl Key for (CrateNum, SimplifiedType)
type Cache<V> = DefaultCache<(CrateNum, SimplifiedType<DefId>), V>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl Key for (DefId, LocalDefId)
impl Key for (DefId, LocalDefId)
type Cache<V> = DefaultCache<(DefId, LocalDefId), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (DefId, SimplifiedType)
impl Key for (DefId, SimplifiedType)
type Cache<V> = DefaultCache<(DefId, SimplifiedType<DefId>), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (LocalDefId, HirId)
impl Key for (LocalDefId, HirId)
type Cache<V> = DefaultCache<(LocalDefId, HirId), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for (LocalDefId, DefId)
impl Key for (LocalDefId, DefId)
type Cache<V> = DefaultCache<(LocalDefId, DefId), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (LocalDefId, LocalDefId)
impl Key for (LocalDefId, LocalDefId)
type Cache<V> = DefaultCache<(LocalDefId, LocalDefId), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (LocalDefId, LocalDefId, Ident)
impl Key for (LocalDefId, LocalDefId, Ident)
type Cache<V> = DefaultCache<(LocalDefId, LocalDefId, Ident), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for ()
impl Key for ()
type Cache<V> = SingleCache<V>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl Key for HirId
impl Key for HirId
type Cache<V> = DefaultCache<HirId, V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for DefId
impl Key for DefId
type Cache<V> = DefIdCache<V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for LocalDefId
impl Key for LocalDefId
type Cache<V> = VecCache<LocalDefId, V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for LocalModDefId
impl Key for LocalModDefId
type Cache<V> = DefaultCache<LocalModDefId, V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for ModDefId
impl Key for ModDefId
type Cache<V> = DefaultCache<ModDefId, V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for Symbol
impl Key for Symbol
type Cache<V> = DefaultCache<Symbol, V>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>)
impl<'tcx> Key for (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>)
type Cache<V> = DefaultCache<(ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>), V>
fn default_span(&self, _: TyCtxt<'_>) -> Span
fn ty_def_id(&self) -> Option<DefId>
source§impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ParamEnv<'tcx>)
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>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>)
impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>)
type Cache<V> = DefaultCache<(DefId, &'tcx RawList<(), GenericArg<'tcx>>), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (LocalDefId, DefId, GenericArgsRef<'tcx>)
impl<'tcx> Key for (LocalDefId, DefId, GenericArgsRef<'tcx>)
type Cache<V> = DefaultCache<(LocalDefId, DefId, &'tcx RawList<(), GenericArg<'tcx>>), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Instance<'tcx>, LocalDefId)
impl<'tcx> Key for (Instance<'tcx>, LocalDefId)
type Cache<V> = DefaultCache<(Instance<'tcx>, LocalDefId), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Predicate<'tcx>, WellFormedLoc)
impl<'tcx> Key for (Predicate<'tcx>, WellFormedLoc)
type Cache<V> = DefaultCache<(Predicate<'tcx>, WellFormedLoc), V>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>)
impl<'tcx> Key for (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>)
type Cache<V> = DefaultCache<(Ty<'tcx>, Option<Binder<TyCtxt<'tcx>, ExistentialTraitRef<TyCtxt<'tcx>>>>), V>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Ty<'tcx>, VariantIdx)
impl<'tcx> Key for (Ty<'tcx>, VariantIdx)
type Cache<V> = DefaultCache<(Ty<'tcx>, VariantIdx), V>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (UnevaluatedConst<'tcx>, UnevaluatedConst<'tcx>)
impl<'tcx> Key for (UnevaluatedConst<'tcx>, UnevaluatedConst<'tcx>)
type Cache<V> = DefaultCache<(UnevaluatedConst<TyCtxt<'tcx>>, UnevaluatedConst<TyCtxt<'tcx>>), V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)
impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)
Implementors§
source§impl Key for SimplifiedType
impl Key for SimplifiedType
type Cache<V> = DefaultCache<SimplifiedType<DefId>, V>
source§impl<'tcx> Key for InstanceKind<'tcx>
impl<'tcx> Key for InstanceKind<'tcx>
type Cache<V> = DefaultCache<InstanceKind<'tcx>, V>
source§impl<'tcx> Key for LitToConstInput<'tcx>
impl<'tcx> Key for LitToConstInput<'tcx>
type Cache<V> = DefaultCache<LitToConstInput<'tcx>, V>
source§impl<'tcx> Key for GenericArg<'tcx>
impl<'tcx> Key for GenericArg<'tcx>
type Cache<V> = DefaultCache<GenericArg<'tcx>, V>
source§impl<'tcx> Key for GenericArgsRef<'tcx>
impl<'tcx> Key for GenericArgsRef<'tcx>
type Cache<V> = DefaultCache<&'tcx RawList<(), GenericArg<'tcx>>, V>
source§impl<'tcx> Key for TyAndLayout<'tcx>
impl<'tcx> Key for TyAndLayout<'tcx>
type Cache<V> = DefaultCache<TyAndLayout<'tcx, Ty<'tcx>>, V>
source§impl<'tcx> Key for PolyExistentialTraitRef<'tcx>
impl<'tcx> Key for PolyExistentialTraitRef<'tcx>
type Cache<V> = DefaultCache<Binder<TyCtxt<'tcx>, ExistentialTraitRef<TyCtxt<'tcx>>>, V>
source§impl<'tcx> Key for PolyTraitRef<'tcx>
impl<'tcx> Key for PolyTraitRef<'tcx>
source§impl<'tcx, T: Clone> Key for Canonical<'tcx, T>
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.