[−][src]Struct rustc_infer::infer::nll_relate::TypeGeneralizer

pub(in infer::nll_relate) struct TypeGeneralizer<'me, 'tcx, D> where
    D: TypeRelatingDelegate<'tcx>, 
{ infcx: &'me InferCtxt<'me, 'tcx>, delegate: &'me mut D, ambient_variance: Variance, first_free_index: DebruijnIndex, for_vid_sub_root: TyVid, universe: UniverseIndex, }

The "type generalize" 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: Variance

After 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: TyVid

The 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: UniverseIndex

The 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]

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, 

impl<'me, 'tcx, D> !UnwindSafe for TypeGeneralizer<'me, 'tcx, D>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]