Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 66bf67d

Browse files
lcnrcompiler-errors
authored andcommitted
using opt_values may mean we don't have infer vars
1 parent 3176c63 commit 66bf67d

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
@@ -370,13 +370,14 @@ where
370370
if let Some(v) = opt_values[ty::BoundVar::from_usize(index)] {
371371
if let CanonicalVarKind::Ty { universe: _, sub_root } = info.kind {
372372
if let Some(prev) = var_values.get(sub_root.as_usize()) {
373-
let ty::Infer(ty::TyVar(vid)) = v.expect_ty().kind() else {
374-
unreachable!("expected `sub_root` to be an inference variable");
375-
};
376-
let ty::Infer(ty::TyVar(sub_root)) = prev.expect_ty().kind() else {
377-
unreachable!("expected `sub_root` to be an inference variable");
378-
};
379-
delegate.sub_ty_vids_raw(vid, sub_root);
373+
let v = delegate.shallow_resolve(v.expect_ty());
374+
let prev = delegate.shallow_resolve(prev.expect_ty());
375+
match (v.kind(), prev.kind()) {
376+
(ty::Infer(ty::TyVar(vid)), ty::Infer(ty::TyVar(sub_root))) => {
377+
delegate.sub_ty_vids_raw(vid, sub_root)
378+
}
379+
_ => {}
380+
}
380381
}
381382
}
382383
v

0 commit comments

Comments
 (0)