Skip to content

Commit

Permalink
Add a comment explaining unification w/ universes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrif committed May 2, 2018
1 parent 4ac9717 commit 68a1fdf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc/infer/type_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down

0 comments on commit 68a1fdf

Please sign in to comment.