Trait rustc_middle::query::Key
source · pub trait Key: Sized {
type CacheSelector;
// 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§
type CacheSelector
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 CacheSelector = DefaultCacheSelector<(CrateNum, SimplifiedType)>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl Key for (CrateNum, DefId)
impl Key for (CrateNum, DefId)
type CacheSelector = DefaultCacheSelector<(CrateNum, DefId)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (DefId, SimplifiedType)
impl Key for (DefId, SimplifiedType)
type CacheSelector = DefaultCacheSelector<(DefId, SimplifiedType)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (DefId, DefId)
impl Key for (DefId, DefId)
type CacheSelector = DefaultCacheSelector<(DefId, DefId)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (DefId, LocalDefId)
impl Key for (DefId, LocalDefId)
type CacheSelector = DefaultCacheSelector<(DefId, LocalDefId)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (DefId, Ident)
impl Key for (DefId, Ident)
type CacheSelector = DefaultCacheSelector<(DefId, Ident)>
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 CacheSelector = DefaultCacheSelector<(LocalDefId, DefId)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (LocalDefId, LocalDefId)
impl Key for (LocalDefId, LocalDefId)
type CacheSelector = DefaultCacheSelector<(LocalDefId, LocalDefId)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (LocalDefId, LocalDefId, Ident)
impl Key for (LocalDefId, LocalDefId, Ident)
type CacheSelector = DefaultCacheSelector<(LocalDefId, LocalDefId, Ident)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl Key for (Symbol, u32, u32)
impl Key for (Symbol, u32, u32)
type CacheSelector = DefaultCacheSelector<(Symbol, u32, u32)>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl Key for Option<Symbol>
impl Key for Option<Symbol>
type CacheSelector = DefaultCacheSelector<Option<Symbol>>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl Key for ()
impl Key for ()
type CacheSelector = SingleCacheSelector
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl Key for HirId
impl Key for HirId
type CacheSelector = DefaultCacheSelector<HirId>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for OwnerId
impl Key for OwnerId
type CacheSelector = VecCacheSelector<OwnerId>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
source§impl Key for CrateNum
impl Key for CrateNum
type CacheSelector = VecCacheSelector<CrateNum>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl Key for DefId
impl Key for DefId
type CacheSelector = DefIdCacheSelector
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 CacheSelector = VecCacheSelector<LocalDefId>
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 CacheSelector = DefaultCacheSelector<LocalModDefId>
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 CacheSelector = DefaultCacheSelector<ModDefId>
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 CacheSelector = DefaultCacheSelector<Symbol>
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 CacheSelector = DefaultCacheSelector<(ValidityRequirement, ParamEnvAnd<'tcx, Ty<'tcx>>)>
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 CacheSelector = DefaultCacheSelector<(DefId, Ty<'tcx>, &'tcx List<GenericArg<'tcx>>, ParamEnv<'tcx>)>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>)
impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>)
type CacheSelector = DefaultCacheSelector<(DefId, &'tcx List<GenericArg<'tcx>>)>
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 CacheSelector = DefaultCacheSelector<(LocalDefId, DefId, &'tcx List<GenericArg<'tcx>>)>
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 CacheSelector = DefaultCacheSelector<(UnevaluatedConst<'tcx>, UnevaluatedConst<'tcx>)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Instance<'tcx>, &'tcx List<Ty<'tcx>>)
impl<'tcx> Key for (Instance<'tcx>, &'tcx List<Ty<'tcx>>)
type CacheSelector = DefaultCacheSelector<(Instance<'tcx>, &'tcx List<Ty<'tcx>>)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Instance<'tcx>, LocalDefId)
impl<'tcx> Key for (Instance<'tcx>, LocalDefId)
type CacheSelector = DefaultCacheSelector<(Instance<'tcx>, LocalDefId)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Predicate<'tcx>, WellFormedLoc)
impl<'tcx> Key for (Predicate<'tcx>, WellFormedLoc)
type CacheSelector = DefaultCacheSelector<(Predicate<'tcx>, WellFormedLoc)>
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (ParamEnv<'tcx>, TraitRef<'tcx>)
impl<'tcx> Key for (ParamEnv<'tcx>, TraitRef<'tcx>)
type CacheSelector = DefaultCacheSelector<(ParamEnv<'tcx>, TraitRef<'tcx>)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Ty<'tcx>, ValTree<'tcx>)
impl<'tcx> Key for (Ty<'tcx>, ValTree<'tcx>)
type CacheSelector = DefaultCacheSelector<(Ty<'tcx>, ValTree<'tcx>)>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>)
impl<'tcx> Key for (Ty<'tcx>, Option<PolyExistentialTraitRef<'tcx>>)
type CacheSelector = DefaultCacheSelector<(Ty<'tcx>, Option<Binder<'tcx, ExistentialTraitRef<'tcx>>>)>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>)
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>)
type CacheSelector = DefaultCacheSelector<(Ty<'tcx>, Ty<'tcx>)>
fn default_span(&self, _: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)
impl<'tcx> Key for (PolyTraitRef<'tcx>, PolyTraitRef<'tcx>)
type CacheSelector = DefaultCacheSelector<(Binder<'tcx, TraitRef<'tcx>>, Binder<'tcx, TraitRef<'tcx>>)>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
source§impl<'tcx> Key for (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)
impl<'tcx> Key for (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)
type CacheSelector = DefaultCacheSelector<(Binder<'tcx, FnSig<'tcx>>, &'tcx List<Ty<'tcx>>)>
fn default_span(&self, _: TyCtxt<'_>) -> Span
Implementors§
source§impl Key for SimplifiedType
impl Key for SimplifiedType
source§impl<'tcx> Key for &'tcx List<Clause<'tcx>>
impl<'tcx> Key for &'tcx List<Clause<'tcx>>
type CacheSelector = DefaultCacheSelector<&'tcx List<Clause<'tcx>>>
source§impl<'tcx> Key for InstanceDef<'tcx>
impl<'tcx> Key for InstanceDef<'tcx>
type CacheSelector = DefaultCacheSelector<InstanceDef<'tcx>>
source§impl<'tcx> Key for GlobalId<'tcx>
impl<'tcx> Key for GlobalId<'tcx>
type CacheSelector = DefaultCacheSelector<GlobalId<'tcx>>
source§impl<'tcx> Key for LitToConstInput<'tcx>
impl<'tcx> Key for LitToConstInput<'tcx>
type CacheSelector = DefaultCacheSelector<LitToConstInput<'tcx>>
source§impl<'tcx> Key for Const<'tcx>
impl<'tcx> Key for Const<'tcx>
type CacheSelector = DefaultCacheSelector<Const<'tcx>>
source§impl<'tcx> Key for GenericArg<'tcx>
impl<'tcx> Key for GenericArg<'tcx>
type CacheSelector = DefaultCacheSelector<GenericArg<'tcx>>
source§impl<'tcx> Key for Instance<'tcx>
impl<'tcx> Key for Instance<'tcx>
type CacheSelector = DefaultCacheSelector<Instance<'tcx>>
source§impl<'tcx> Key for ParamEnv<'tcx>
impl<'tcx> Key for ParamEnv<'tcx>
type CacheSelector = DefaultCacheSelector<ParamEnv<'tcx>>
source§impl<'tcx> Key for Ty<'tcx>
impl<'tcx> Key for Ty<'tcx>
type CacheSelector = DefaultCacheSelector<Ty<'tcx>>
source§impl<'tcx> Key for GenericArgsRef<'tcx>
impl<'tcx> Key for GenericArgsRef<'tcx>
type CacheSelector = DefaultCacheSelector<&'tcx List<GenericArg<'tcx>>>
source§impl<'tcx> Key for TyAndLayout<'tcx>
impl<'tcx> Key for TyAndLayout<'tcx>
type CacheSelector = DefaultCacheSelector<TyAndLayout<'tcx, Ty<'tcx>>>
source§impl<'tcx> Key for PolyExistentialTraitRef<'tcx>
impl<'tcx> Key for PolyExistentialTraitRef<'tcx>
type CacheSelector = DefaultCacheSelector<Binder<'tcx, ExistentialTraitRef<'tcx>>>
source§impl<'tcx> Key for PolyTraitRef<'tcx>
impl<'tcx> Key for PolyTraitRef<'tcx>
type CacheSelector = DefaultCacheSelector<Binder<'tcx, TraitRef<'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.