From 68a1fdfee49eeca4d3379423879c5299b5d8e0b0 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Wed, 2 May 2018 15:02:11 -0600 Subject: [PATCH] Add a comment explaining unification w/ universes --- src/librustc/infer/type_variable.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustc/infer/type_variable.rs b/src/librustc/infer/type_variable.rs index a5c2191232e..d40e1b3760f 100644 --- a/src/librustc/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -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 }) }