1
Fork 0

Add a comment explaining unification w/ universes

This commit is contained in:
Sean Griffin 2018-05-02 15:02:11 -06:00
parent 4ac9717a1f
commit 68a1fdfee4

View file

@ -442,6 +442,11 @@ impl<'tcx> ut::UnifyValue for TypeVariableValue<'tcx> {
// If both sides are *unknown*, it hardly matters, does it?
(&TypeVariableValue::Unknown { universe: universe1 },
&TypeVariableValue::Unknown { universe: universe2 }) => {
// If we unify two unbound variables, ?T and ?U, then whatever
// value they wind up taking (which must be the same value) must
// be nameable by both universes. Therefore, the resulting
// universe is the minimum of the two universes, because that is
// the one which contains the fewest names in scope.
let universe = cmp::min(universe1, universe2);
Ok(TypeVariableValue::Unknown { universe })
}