From 534426d0f3d12b735b0018bcf268b08a09cc09b8 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 10 Aug 2022 03:36:05 +0000 Subject: [PATCH] Delay a bug if we try and fail to relate an opaque to itself in TypeRelating --- compiler/rustc_infer/src/infer/nll_relate/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_infer/src/infer/nll_relate/mod.rs b/compiler/rustc_infer/src/infer/nll_relate/mod.rs index 324aef9c01f..e7e93116a66 100644 --- a/compiler/rustc_infer/src/infer/nll_relate/mod.rs +++ b/compiler/rustc_infer/src/infer/nll_relate/mod.rs @@ -599,6 +599,10 @@ fn tys(&mut self, a: Ty<'tcx>, mut b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> (&ty::Opaque(a_def_id, _), &ty::Opaque(b_def_id, _)) if a_def_id == b_def_id => { infcx.commit_if_ok(|_| infcx.super_combine_tys(self, a, b)).or_else(|err| { + self.tcx().sess.delay_span_bug( + self.delegate.span(), + "failure to relate an opaque to itself should result in an error later on", + ); if a_def_id.is_local() { self.relate_opaques(a, b) } else { Err(err) } }) }