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, }
Expand description

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: Variance

After we generalize this type, we are going to relate 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

Returns a static string we can use for printouts.
Returns true if the value a is the “expected” type in the relation. Just affects error messages. Read more
Switch variance for the purpose of relating a and b.
Generic relation routine suitable for most anything.
Relate the two substitutions for the given item. The default is to look up the variance for the item and proceed accordingly. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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: 32 bytes