pub trait QueryKey: Sized + QueryKeyBounds {
type Cache<V> = DefaultCache<Self, 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
Controls what types can legally be used as the key for a query.
Provided Associated Types§
Sourcetype Cache<V> = DefaultCache<Self, V>
type Cache<V> = DefaultCache<Self, V>
The type of in-memory cache to use for queries with this key type.
In practice the cache type must implement QueryCache, though that
constraint is not enforced here.
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.
Sourcefn def_id_for_ty_in_cycle(&self) -> Option<DefId>
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 QueryKey for (CrateNum, SimplifiedType)
impl QueryKey for (CrateNum, SimplifiedType)
fn default_span(&self, _: TyCtxt<'_>) -> Span
Source§impl QueryKey for (DefId, SizedTraitKind)
impl QueryKey for (DefId, SizedTraitKind)
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
Source§impl QueryKey for (DefId, Ident)
impl QueryKey for (DefId, Ident)
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
Source§impl QueryKey for (LocalDefId, LocalDefId, Ident)
impl QueryKey for (LocalDefId, LocalDefId, Ident)
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
Source§impl QueryKey for ()
impl QueryKey for ()
type Cache<V> = SingleCache<V>
fn default_span(&self, _: TyCtxt<'_>) -> Span
Source§impl QueryKey for DefId
impl QueryKey for DefId
type Cache<V> = DefIdCache<V>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
Source§impl QueryKey for LocalDefId
impl QueryKey for LocalDefId
type Cache<V> = VecCache<LocalDefId, V, DepNodeIndex>
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
Source§impl QueryKey for LocalModDefId
impl QueryKey for LocalModDefId
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
fn key_as_def_id(&self) -> Option<DefId>
Source§impl<'tcx> QueryKey for (ValidityRequirement, PseudoCanonicalInput<'tcx, Ty<'tcx>>)
impl<'tcx> QueryKey for (ValidityRequirement, PseudoCanonicalInput<'tcx, Ty<'tcx>>)
fn default_span(&self, _: TyCtxt<'_>) -> Span
fn def_id_for_ty_in_cycle(&self) -> Option<DefId>
Source§impl<'tcx> QueryKey for (DefId, GenericArgsRef<'tcx>)
impl<'tcx> QueryKey for (DefId, GenericArgsRef<'tcx>)
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (LocalExpnId, &'tcx TokenStream)
impl<'tcx> QueryKey for (LocalExpnId, &'tcx TokenStream)
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (Instance<'tcx>, &'tcx List<Ty<'tcx>>)
impl<'tcx> QueryKey for (Instance<'tcx>, &'tcx List<Ty<'tcx>>)
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (Instance<'tcx>, CollectionMode)
impl<'tcx> QueryKey for (Instance<'tcx>, CollectionMode)
fn default_span(&self, tcx: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (Predicate<'tcx>, WellFormedLoc)
impl<'tcx> QueryKey for (Predicate<'tcx>, WellFormedLoc)
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (Ty<'tcx>, Option<ExistentialTraitRef<'tcx>>)
impl<'tcx> QueryKey for (Ty<'tcx>, Option<ExistentialTraitRef<'tcx>>)
fn default_span(&self, _: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (Ty<'tcx>, VariantIdx)
impl<'tcx> QueryKey for (Ty<'tcx>, VariantIdx)
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (Ty<'tcx>, Ty<'tcx>)
impl<'tcx> QueryKey for (Ty<'tcx>, Ty<'tcx>)
fn default_span(&self, _: TyCtxt<'_>) -> Span
Source§impl<'tcx> QueryKey for (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)
impl<'tcx> QueryKey for (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)
fn default_span(&self, _: TyCtxt<'_>) -> Span
Source§impl<'tcx, T: QueryKeyBounds> QueryKey for (CanonicalQueryInput<'tcx, T>, bool)
impl<'tcx, T: QueryKeyBounds> QueryKey for (CanonicalQueryInput<'tcx, T>, bool)
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
Implementors§
impl QueryKey for SimplifiedType
impl<'tcx> QueryKey for InstanceKind<'tcx>
impl<'tcx> QueryKey for GlobalId<'tcx>
impl<'tcx> QueryKey for GenericArg<'tcx>
impl<'tcx> QueryKey for Instance<'tcx>
impl<'tcx> QueryKey for LitToConstInput<'tcx>
impl<'tcx> QueryKey for Ty<'tcx>
impl<'tcx> QueryKey for Value<'tcx>
impl<'tcx> QueryKey for Clauses<'tcx>
impl<'tcx> QueryKey for GenericArgsRef<'tcx>
impl<'tcx> QueryKey for TraitRef<'tcx>
impl<'tcx, T: QueryKey> QueryKey for PseudoCanonicalInput<'tcx, T>
impl<'tcx, T: QueryKeyBounds> QueryKey for CanonicalQueryInput<'tcx, T>
Canonical query goals correspond to abstract trait operations that are not tied to any crate in particular.