Correctly generalize inference variables in nll_relate

This commit is contained in:
scalexm 2018-11-29 20:50:16 +01:00
parent c805e817a9
commit 1fce415649

View file

@ -762,23 +762,18 @@ where
drop(variables);
self.relate(&u, &u)
}
TypeVariableValue::Unknown { universe } => {
if self.universe.cannot_name(universe) {
debug!(
"TypeGeneralizer::tys: root universe {:?} cannot name\
variable in universe {:?}",
self.universe,
universe
);
return Err(TypeError::Mismatch);
}
TypeVariableValue::Unknown { universe: _universe } => {
if self.ambient_variance == ty::Bivariant {
// FIXME: we may need a WF predicate (related to #54105).
}
let origin = *variables.var_origin(vid);
// Replacing with a new variable in the universe `self.universe`,
// it will be unified later with the original type variable in
// the universe `_universe`.
let new_var_id = variables.new_var(self.universe, false, origin);
let u = self.tcx().mk_var(new_var_id);
debug!(
"generalize: replacing original vid={:?} with new={:?}",