Module rustc_trait_selection::solve::alias_relate
source · Expand description
Implements the AliasRelate goal, which is used when unifying aliases.
Doing this via a separate goal is called “deferred alias relation” and part
of our more general approach to “lazy normalization”.
This is done by first normalizing both sides of the goal, ending up in either a concrete type, rigid projection, opaque, or an infer variable. These are related further according to the rules below:
(1.) If we end up with a rigid projection and a rigid projection, then we relate those projections structurally.
(2.) If we end up with a rigid projection and an alias, then the opaque will have its hidden type defined to be that rigid projection.
(3.) If we end up with an opaque and an opaque, then we assemble two candidates, one defining the LHS to be the hidden type of the RHS, and vice versa.
(4.) If we end up with an infer var and an opaque or rigid projection, then we assign the alias to the infer var.
(5.) If we end up with an opaque and a rigid (non-projection) type, then we define the hidden type of the opaque to be the rigid type.
(6.) Otherwise, if we end with two rigid (non-projection) or infer types, relate them structurally.