Type Alias rustc_middle::ty::CanonicalUserType
source · pub type CanonicalUserType<'tcx> = Canonical<'tcx, UserType<'tcx>>;
Expand description
Canonical user type annotation.
Aliased Type§
struct CanonicalUserType<'tcx> {
pub value: UserType<'tcx>,
pub max_universe: UniverseIndex,
pub variables: &'tcx List<CanonicalVarInfo<'tcx>>,
}
Fields§
§value: UserType<'tcx>
§max_universe: UniverseIndex
§variables: &'tcx List<CanonicalVarInfo<'tcx>>
Implementations§
source§impl<'tcx> CanonicalUserType<'tcx>
impl<'tcx> CanonicalUserType<'tcx>
sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true
if this represents a substitution of the form [?0, ?1, ?2]
,
i.e., each thing is mapped to a canonical variable with the same index.
source§impl<'tcx, V> Canonical<'tcx, V>
impl<'tcx, V> Canonical<'tcx, V>
sourcepub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, W>
pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, 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<'_, T> = ...;
let b: Canonical<'_, (T,)> = a.unchecked_map(|v| (v, ));
An example of an incorrect use of this:
let a: Canonical<'tcx, T> = ...;
let ty: Ty<'tcx> = ...;
let b: Canonical<'tcx, (T, Ty<'tcx>)> = a.unchecked_map(|v| (v, ty));
sourcepub fn unchecked_rebind<W>(self, value: W) -> Canonical<'tcx, W>
pub fn unchecked_rebind<W>(self, value: W) -> Canonical<'tcx, 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! See the comment of Canonical::unchecked_map for more details.
Trait Implementations§
source§impl<'tcx, V, __D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<__D> for Canonical<'tcx, V>where
V: Decodable<__D>,
impl<'tcx, V, __D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<__D> for Canonical<'tcx, V>where V: Decodable<__D>,
source§impl<'tcx, V, __E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<__E> for Canonical<'tcx, V>where
V: Encodable<__E>,
impl<'tcx, V, __E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<__E> for Canonical<'tcx, V>where V: Encodable<__E>,
source§impl<'tcx, '__ctx, V> HashStable<StableHashingContext<'__ctx>> for Canonical<'tcx, V>where
V: HashStable<StableHashingContext<'__ctx>>,
impl<'tcx, '__ctx, V> HashStable<StableHashingContext<'__ctx>> for Canonical<'tcx, V>where V: HashStable<StableHashingContext<'__ctx>>,
fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher )
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.
type CacheSelector = DefaultCacheSelector<Canonical<'tcx, T>>
source§fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span
self
, what span should we use?source§fn key_as_def_id(&self) -> Option<DefId>
fn key_as_def_id(&self) -> Option<DefId>
fn ty_adt_id(&self) -> Option<DefId>
source§impl<'tcx, V: PartialEq> PartialEq<Canonical<'tcx, V>> for Canonical<'tcx, V>
impl<'tcx, V: PartialEq> PartialEq<Canonical<'tcx, V>> for Canonical<'tcx, V>
source§impl<'tcx, V> TypeFoldable<TyCtxt<'tcx>> for Canonical<'tcx, V>where
V: TypeFoldable<TyCtxt<'tcx>>,
impl<'tcx, V> TypeFoldable<TyCtxt<'tcx>> for Canonical<'tcx, V>where V: TypeFoldable<TyCtxt<'tcx>>,
source§fn try_fold_with<__F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
__folder: &mut __F
) -> Result<Self, __F::Error>
fn try_fold_with<__F: FallibleTypeFolder<TyCtxt<'tcx>>>( self, __folder: &mut __F ) -> Result<Self, __F::Error>
source§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
.source§impl<'tcx, V> TypeVisitable<TyCtxt<'tcx>> for Canonical<'tcx, V>where
V: TypeVisitable<TyCtxt<'tcx>>,
impl<'tcx, V> TypeVisitable<TyCtxt<'tcx>> for Canonical<'tcx, V>where V: TypeVisitable<TyCtxt<'tcx>>,
source§fn visit_with<__V: TypeVisitor<TyCtxt<'tcx>>>(
&self,
__visitor: &mut __V
) -> ControlFlow<__V::BreakTy>
fn visit_with<__V: TypeVisitor<TyCtxt<'tcx>>>( &self, __visitor: &mut __V ) -> ControlFlow<__V::BreakTy>
impl<'tcx, V: Copy> Copy for Canonical<'tcx, V>
impl<'tcx, V: Eq> Eq for Canonical<'tcx, V>
impl<'tcx, V> StructuralEq for Canonical<'tcx, V>
impl<'tcx, V> StructuralPartialEq for Canonical<'tcx, V>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes