Struct rustc_infer::infer::nll_relate::TypeGeneralizer [−][src]
The “type generalizer” is used when handling inference variables.
The basic strategy for handling a constraint like ?A <: B is to
apply a “generalization strategy” to the type B – this replaces
all the lifetimes in the type B with fresh inference
variables. (You can read more about the strategy in this blog
post.)
As an example, if we had ?A <: &'x u32, we would generalize &'x u32 to &'0 u32 where '0 is a fresh variable. This becomes the
value of A. Finally, we relate &'0 u32 <: &'x u32, which
establishes '0: 'x as a constraint.
As a side-effect of this generalization procedure, we also replace all the bound regions that we have traversed with concrete values, so that the resulting generalized type is independent from the scopes.
Fields
infcx: &'me InferCtxt<'me, 'tcx>delegate: &'me mut Dambient_variance: VarianceAfter we generalize this type, we are going to relative it to some other type. What will be the variance at this point?
first_free_index: DebruijnIndexfor_vid_sub_root: TyVidThe vid of the type variable that is in the process of being instantiated. If we find this within the value we are folding, that means we would have created a cyclic value.
universe: UniverseIndexThe universe of the type variable that is in the process of being instantiated. If we find anything that this universe cannot name, we reject the relation.
Trait Implementations
impl<D, 'tcx, 'me> TypeRelation<'tcx> for TypeGeneralizer<'me, 'tcx, D> where
D: TypeRelatingDelegate<'tcx>, [src]
D: TypeRelatingDelegate<'tcx>,
fn tcx(&self) -> TyCtxt<'tcx>[src]
fn param_env(&self) -> ParamEnv<'tcx>[src]
fn tag(&self) -> &'static str[src]
fn a_is_expected(&self) -> bool[src]
fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
variance: Variance,
a: T,
b: T
) -> RelateResult<'tcx, T>[src]
&mut self,
variance: Variance,
a: T,
b: T
) -> RelateResult<'tcx, T>
fn tys(&mut self, a: Ty<'tcx>, _: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>>[src]
fn regions(
&mut self,
a: Region<'tcx>,
_: Region<'tcx>
) -> RelateResult<'tcx, Region<'tcx>>[src]
&mut self,
a: Region<'tcx>,
_: Region<'tcx>
) -> RelateResult<'tcx, Region<'tcx>>
fn consts(
&mut self,
a: &'tcx Const<'tcx>,
_: &'tcx Const<'tcx>
) -> RelateResult<'tcx, &'tcx Const<'tcx>>[src]
&mut self,
a: &'tcx Const<'tcx>,
_: &'tcx Const<'tcx>
) -> RelateResult<'tcx, &'tcx Const<'tcx>>
fn binders<T>(
&mut self,
a: Binder<T>,
_: Binder<T>
) -> RelateResult<'tcx, Binder<T>> where
T: Relate<'tcx>, [src]
&mut self,
a: Binder<T>,
_: Binder<T>
) -> RelateResult<'tcx, Binder<T>> where
T: Relate<'tcx>,
pub fn visit_ct_substs(&self) -> bool[src]
pub fn with_cause<F, R>(&mut self, _cause: Cause, f: F) -> R where
F: FnOnce(&mut Self) -> R, [src]
F: FnOnce(&mut Self) -> R,
pub fn relate<T>(&mut self, a: T, b: T) -> Result<T, TypeError<'tcx>> where
T: Relate<'tcx>, [src]
T: Relate<'tcx>,
pub fn relate_item_substs(
&mut self,
item_def_id: DefId,
a_subst: &'tcx List<GenericArg<'tcx>>,
b_subst: &'tcx List<GenericArg<'tcx>>
) -> Result<&'tcx List<GenericArg<'tcx>>, TypeError<'tcx>>[src]
&mut self,
item_def_id: DefId,
a_subst: &'tcx List<GenericArg<'tcx>>,
b_subst: &'tcx List<GenericArg<'tcx>>
) -> Result<&'tcx List<GenericArg<'tcx>>, TypeError<'tcx>>
Auto Trait Implementations
impl<'me, 'tcx, D> !RefUnwindSafe for TypeGeneralizer<'me, 'tcx, D>
impl<'me, 'tcx, D> !Send for TypeGeneralizer<'me, 'tcx, D>
impl<'me, 'tcx, D> !Sync for TypeGeneralizer<'me, 'tcx, D>
impl<'me, 'tcx, D> Unpin for TypeGeneralizer<'me, 'tcx, D> where
'tcx: 'me,
'tcx: 'me,
impl<'me, 'tcx, D> !UnwindSafe for TypeGeneralizer<'me, 'tcx, D>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.