Skip to content

Commit d18d85f

Browse files
committed
using opt_values may mean we don't have infer vars
1 parent 18f6382 commit d18d85f

File tree

1 file changed

+8
-7
lines changed
  • compiler/rustc_next_trait_solver/src/solve/eval_ctxt

1 file changed

+8
-7
lines changed

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,14 @@ where
373373
if let Some(v) = opt_values[ty::BoundVar::from_usize(index)] {
374374
if let CanonicalVarKind::Ty { universe: _, sub_root } = info.kind {
375375
if let Some(prev) = var_values.get(sub_root.as_usize()) {
376-
let ty::Infer(ty::TyVar(vid)) = v.expect_ty().kind() else {
377-
unreachable!("expected `sub_root` to be an inference variable");
378-
};
379-
let ty::Infer(ty::TyVar(sub_root)) = prev.expect_ty().kind() else {
380-
unreachable!("expected `sub_root` to be an inference variable");
381-
};
382-
delegate.sub_ty_vids_raw(vid, sub_root);
376+
let v = delegate.shallow_resolve(v.expect_ty());
377+
let prev = delegate.shallow_resolve(prev.expect_ty());
378+
match (v.kind(), prev.kind()) {
379+
(ty::Infer(ty::TyVar(vid)), ty::Infer(ty::TyVar(sub_root))) => {
380+
delegate.sub_ty_vids_raw(vid, sub_root)
381+
}
382+
_ => {}
383+
}
383384
}
384385
}
385386
v

0 commit comments

Comments
 (0)