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>
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, SimplifiedType)
impl Key for (CrateNum, SimplifiedType)
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)
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 (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
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<'tcx> Key for (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>)
impl<'tcx> Key for (ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>)
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 (DefId, GenericArgsRef<'tcx>)
impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>)
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 (UnevaluatedConst<'tcx>, UnevaluatedConst<'tcx>)
impl<'tcx> Key for (UnevaluatedConst<'tcx>, UnevaluatedConst<'tcx>)
Source§impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)
impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)
Implementors§
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>
Source§impl<'tcx> Key for TyAndLayout<'tcx>
impl<'tcx> Key for TyAndLayout<'tcx>
Source§impl<'tcx> Key for PolyExistentialTraitRef<'tcx>
impl<'tcx> Key for PolyExistentialTraitRef<'tcx>
Source§impl<'tcx> Key for PolyTraitRef<'tcx>
impl<'tcx> Key for PolyTraitRef<'tcx>
Source§impl<'tcx, T: Clone> Key for CanonicalQueryInput<'tcx, T>
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.