Skip to content

Commit 1fce415

Browse files
committed
Correctly generalize inference variables in nll_relate
1 parent c805e81 commit 1fce415

File tree

1 file changed

+6
-11
lines changed
  • src/librustc/infer/nll_relate

1 file changed

+6
-11
lines changed

src/librustc/infer/nll_relate/mod.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -762,23 +762,18 @@ where
762762
drop(variables);
763763
self.relate(&u, &u)
764764
}
765-
TypeVariableValue::Unknown { universe } => {
766-
if self.universe.cannot_name(universe) {
767-
debug!(
768-
"TypeGeneralizer::tys: root universe {:?} cannot name\
769-
variable in universe {:?}",
770-
self.universe,
771-
universe
772-
);
773-
return Err(TypeError::Mismatch);
774-
}
775-
765+
TypeVariableValue::Unknown { universe: _universe } => {
776766
if self.ambient_variance == ty::Bivariant {
777767
// FIXME: we may need a WF predicate (related to #54105).
778768
}
779769

780770
let origin = *variables.var_origin(vid);
771+
772+
// Replacing with a new variable in the universe `self.universe`,
773+
// it will be unified later with the original type variable in
774+
// the universe `_universe`.
781775
let new_var_id = variables.new_var(self.universe, false, origin);
776+
782777
let u = self.tcx().mk_var(new_var_id);
783778
debug!(
784779
"generalize: replacing original vid={:?} with new={:?}",

0 commit comments

Comments
 (0)