diff options
| author | scalexm <alexandre@scalexm.fr> | 2018-11-29 20:50:16 +0100 |
|---|---|---|
| committer | scalexm <alexandre@scalexm.fr> | 2018-11-29 21:57:40 +0100 |
| commit | 1fce415649784ecaf3bcb3a6916e10284c0affec (patch) | |
| tree | 32f373ca6ef386fce75a36acfbfc827b9dae4226 | |
| parent | c805e817a93a641ef92e58900bc5b0876bbf51f1 (diff) | |
| download | rust-1fce415649784ecaf3bcb3a6916e10284c0affec.tar.gz rust-1fce415649784ecaf3bcb3a6916e10284c0affec.zip | |
Correctly generalize inference variables in `nll_relate`
| -rw-r--r-- | src/librustc/infer/nll_relate/mod.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index ce5aee81ef9..972ba16f7e2 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -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={:?}", |
