Skip to content

Commit 68a1fdf

Browse files
committed
Add a comment explaining unification w/ universes
1 parent 4ac9717 commit 68a1fdf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc/infer/type_variable.rs

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

0 commit comments

Comments
 (0)