Skip to content

Commit

Permalink
Correctly generalize inference variables in nll_relate
Browse files Browse the repository at this point in the history
  • Loading branch information
scalexm committed Nov 29, 2018
1 parent c805e81 commit 1fce415
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/librustc/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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={:?}",
Expand Down

0 comments on commit 1fce415

Please sign in to comment.