pub type Canonical<'tcx, V> = Canonical<TyCtxt<'tcx>, V>;
Aliased Type§
struct Canonical<'tcx, V> {
pub value: V,
pub max_universe: UniverseIndex,
pub variables: &'tcx RawList<(), CanonicalVarInfo<TyCtxt<'tcx>>>,
}
Fields§
§value: V
§max_universe: UniverseIndex
§variables: &'tcx RawList<(), CanonicalVarInfo<TyCtxt<'tcx>>>
Implementations
§impl<I, V> Canonical<I, V>where
I: Interner,
impl<I, V> Canonical<I, V>where
I: Interner,
pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<I, W>
pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<I, W>
Allows you to map the value
of a canonical while keeping the
same set of bound variables.
WARNING: This function is very easy to mis-use, hence the
name! In particular, the new value W
must use all the
same type/region variables in precisely the same order
as the original! (The ordering is defined by the
TypeFoldable
implementation of the type in question.)
An example of a correct use of this:
let a: Canonical<I, T> = ...;
let b: Canonical<I, (T,)> = a.unchecked_map(|v| (v, ));
An example of an incorrect use of this:
let a: Canonical<I, T> = ...;
let ty: Ty<I> = ...;
let b: Canonical<I, (T, Ty<I>)> = a.unchecked_map(|v| (v, ty));
Trait Implementations§
Source§impl<'tcx, V> CanonicalExt<'tcx, V> for Canonical<'tcx, V>
impl<'tcx, V> CanonicalExt<'tcx, V> for Canonical<'tcx, V>
Source§fn instantiate(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
) -> Vwhere
V: TypeFoldable<TyCtxt<'tcx>>,
fn instantiate(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
) -> Vwhere
V: TypeFoldable<TyCtxt<'tcx>>,
Instantiate the wrapped value, replacing each canonical value
with the value given in var_values
.
Source§fn instantiate_projected<T>(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> T,
) -> Twhere
T: TypeFoldable<TyCtxt<'tcx>>,
fn instantiate_projected<T>(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> T,
) -> Twhere
T: TypeFoldable<TyCtxt<'tcx>>,
Allows one to apply a instantiation to some subset of
self.value
. Invoke projection_fn
with self.value
to get
a value V that is expressed in terms of the same canonical
variables bound in self
(usually this extracts from subset
of self
). Apply the instantiation var_values
to this value
V, replacing each of the canonical variables.
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, ()>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, ()>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, ()>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, ()>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, ()>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Binder<TyCtxt<'tcx>, FnSig<TyCtxt<'tcx>>>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Binder<TyCtxt<'tcx>, FnSig<TyCtxt<'tcx>>>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Binder<TyCtxt<'tcx>, FnSig<TyCtxt<'tcx>>>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Binder<TyCtxt<'tcx>, FnSig<TyCtxt<'tcx>>>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Binder<TyCtxt<'tcx>, FnSig<TyCtxt<'tcx>>>>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Clause<'tcx>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Clause<'tcx>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Clause<'tcx>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Clause<'tcx>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Clause<'tcx>>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, FnSig<TyCtxt<'tcx>>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, FnSig<TyCtxt<'tcx>>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, FnSig<TyCtxt<'tcx>>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, FnSig<TyCtxt<'tcx>>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, FnSig<TyCtxt<'tcx>>>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, NormalizationResult<'tcx>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, NormalizationResult<'tcx>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, NormalizationResult<'tcx>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, NormalizationResult<'tcx>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, NormalizationResult<'tcx>>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Ty<'tcx>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Ty<'tcx>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Ty<'tcx>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Ty<'tcx>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Ty<'tcx>>>]
Source§impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>
impl<'tcx> ArenaAllocatable<'tcx> for Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>
fn allocate_on( self, arena: &'tcx Arena<'tcx>, ) -> &'tcx mut Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>>, ) -> &'tcx mut [Canonical<TyCtxt<'tcx>, QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>]
§impl<I, V, __CTX> HashStable<__CTX> for Canonical<I, V>
impl<I, V, __CTX> HashStable<__CTX> for Canonical<I, V>
fn hash_stable( &self, __hcx: &mut __CTX, __hasher: &mut StableHasher<SipHasher128>, )
Source§impl<'tcx> IsIdentity for Canonical<TyCtxt<'tcx>, UserType<'tcx>>
impl<'tcx> IsIdentity for Canonical<TyCtxt<'tcx>, UserType<'tcx>>
Source§fn is_identity(&self) -> bool
fn is_identity(&self) -> bool
Returns true
if this represents the generic parameters of the form [?0, ?1, ?2]
,
i.e., each thing is mapped to a canonical variable with the same index.
§impl<I, V> TypeFoldable<I> for Canonical<I, V>
impl<I, V> TypeFoldable<I> for Canonical<I, V>
§fn try_fold_with<__F>(
self,
__folder: &mut __F,
) -> Result<Canonical<I, V>, <__F as FallibleTypeFolder<I>>::Error>where
__F: FallibleTypeFolder<I>,
fn try_fold_with<__F>(
self,
__folder: &mut __F,
) -> Result<Canonical<I, V>, <__F as FallibleTypeFolder<I>>::Error>where
__F: FallibleTypeFolder<I>,
§fn fold_with<F>(self, folder: &mut F) -> Selfwhere
F: TypeFolder<I>,
fn fold_with<F>(self, folder: &mut F) -> Selfwhere
F: TypeFolder<I>,
try_fold_with
for use with infallible
folders. Do not override this method, to ensure coherence with
try_fold_with
.§impl<I, V> TypeVisitable<I> for Canonical<I, V>
impl<I, V> TypeVisitable<I> for Canonical<I, V>
§fn visit_with<__V>(
&self,
__visitor: &mut __V,
) -> <__V as TypeVisitor<I>>::Resultwhere
__V: TypeVisitor<I>,
fn visit_with<__V>(
&self,
__visitor: &mut __V,
) -> <__V as TypeVisitor<I>>::Resultwhere
__V: TypeVisitor<I>,
impl<I, V> Copy for Canonical<I, V>
impl<I, V> Eq for Canonical<I, V>
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.