Skip to main content

QueryKey

Trait QueryKey 

Source
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§

Source

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§

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 QueryKey for (CrateNum, DefId)

Source§

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

Source§

impl QueryKey for (CrateNum, SimplifiedType)

Source§

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

Source§

impl QueryKey for (DefId, SizedTraitKind)

Source§

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

Source§

impl QueryKey for (DefId, DefId)

Source§

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

Source§

impl QueryKey for (DefId, Ident)

Source§

impl QueryKey for (LocalDefId, LocalDefId, Ident)

Source§

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

Source§

impl QueryKey for Option<Symbol>

Source§

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

Source§

impl QueryKey for ()

Source§

type Cache<V> = SingleCache<V>

Source§

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

Source§

impl QueryKey for OwnerId

Source§

impl QueryKey for CrateNum

Source§

impl QueryKey for DefId

Source§

impl QueryKey for LocalDefId

Source§

impl QueryKey for LocalModDefId

Source§

impl QueryKey for Symbol

Source§

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

Source§

impl<'tcx> QueryKey for &'tcx OsStr

Source§

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

Source§

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

Source§

impl<'tcx> QueryKey for (DefId, GenericArgsRef<'tcx>)

Source§

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

Source§

impl<'tcx> QueryKey for (LocalExpnId, &'tcx TokenStream)

Source§

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

Source§

impl<'tcx> QueryKey for (Instance<'tcx>, &'tcx List<Ty<'tcx>>)

Source§

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

Source§

impl<'tcx> QueryKey for (Instance<'tcx>, CollectionMode)

Source§

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

Source§

impl<'tcx> QueryKey for (Predicate<'tcx>, WellFormedLoc)

Source§

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

Source§

impl<'tcx> QueryKey for (Ty<'tcx>, Option<ExistentialTraitRef<'tcx>>)

Source§

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

Source§

impl<'tcx> QueryKey for (Ty<'tcx>, VariantIdx)

Source§

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

Source§

impl<'tcx> QueryKey for (Ty<'tcx>, Ty<'tcx>)

Source§

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

Source§

impl<'tcx> QueryKey for (PolyFnSig<'tcx>, &'tcx List<Ty<'tcx>>)

Source§

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

Source§

impl<'tcx, T: QueryKeyBounds> QueryKey for (CanonicalQueryInput<'tcx, T>, bool)

Source§

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

Implementors§

Source§

impl QueryKey for SimplifiedType

Source§

impl<'tcx> QueryKey for InstanceKind<'tcx>

Source§

impl<'tcx> QueryKey for GlobalId<'tcx>

Source§

impl<'tcx> QueryKey for GenericArg<'tcx>

Source§

impl<'tcx> QueryKey for Instance<'tcx>

Source§

impl<'tcx> QueryKey for LitToConstInput<'tcx>

Source§

impl<'tcx> QueryKey for Ty<'tcx>

Source§

impl<'tcx> QueryKey for Value<'tcx>

Source§

impl<'tcx> QueryKey for Clauses<'tcx>

Source§

impl<'tcx> QueryKey for GenericArgsRef<'tcx>

Source§

impl<'tcx> QueryKey for TraitRef<'tcx>

Source§

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

Source§

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.