about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-13 07:26:47 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-04-13 07:26:47 +0000
commitc6a4f810d926d00a176de40ae78288c145f3843d (patch)
treede7589253c3ac35747dcebfdc387e0db8ef7d2cd /compiler
parentc9889b02b92d28ab4b97bd3c57f4fd06e801697d (diff)
downloadrust-c6a4f810d926d00a176de40ae78288c145f3843d.tar.gz
rust-c6a4f810d926d00a176de40ae78288c145f3843d.zip
Replace a `DefiningOpaqueTypes::No` with `Yes` by asserting that one side of the comparison is a type variable.
Thus there will never be an opaque type involved in a way that constrains its hidden type, as the other side of the comparison is always a generator witness type
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index da46ed07690..2580179ce5b 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -561,9 +561,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
             // Unify `interior` with `witness` and collect all the resulting obligations.
             let span = self.tcx.hir().body(body_id).value.span;
+            let ty::Infer(ty::InferTy::TyVar(_)) = interior.kind() else {
+                span_bug!(span, "coroutine interior witness not infer: {:?}", interior.kind())
+            };
             let ok = self
                 .at(&self.misc(span), self.param_env)
-                .eq(DefineOpaqueTypes::No, interior, witness)
+                // Will never define opaque types, as all we do is instantiate a type variable.
+                .eq(DefineOpaqueTypes::Yes, interior, witness)
                 .expect("Failed to unify coroutine interior type");
             let mut obligations = ok.obligations;