Skip to content

Commit 12f68e6

Browse files
committed
Account for const generalisation in combine
1 parent cc7294c commit 12f68e6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/librustc/infer/combine.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,21 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
605605
match c.val {
606606
ConstValue::Infer(InferConst::Var(vid)) => {
607607
let mut variable_table = self.infcx.const_unification_table.borrow_mut();
608-
match variable_table.probe_value(vid).val.known() {
609-
Some(u) => self.relate(&u, &u),
610-
None => Ok(c),
608+
let var_value = variable_table.probe_value(vid);
609+
match var_value.val {
610+
ConstVariableValue::Known { value: u } => self.relate(&u, &u),
611+
ConstVariableValue::Unknown { universe } => {
612+
if self.for_universe.can_name(universe) {
613+
Ok(c)
614+
} else {
615+
let new_var_id = variable_table.new_key(ConstVarValue {
616+
origin: var_value.origin,
617+
val: ConstVariableValue::Unknown { universe: self.for_universe },
618+
});
619+
let u = self.tcx().mk_const_var(new_var_id, c.ty);
620+
return Ok(u);
621+
}
622+
}
611623
}
612624
}
613625
_ => relate::super_relate_consts(self, c, c),

0 commit comments

Comments
 (0)