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
This commit is contained in:
Oli Scherer 2024-04-13 07:26:47 +00:00
parent c9889b02b9
commit c6a4f810d9

View File

@ -561,9 +561,13 @@ pub(in super::super) fn resolve_coroutine_interiors(&self) {
// Unify `interior` with `witness` and collect all the resulting obligations. // Unify `interior` with `witness` and collect all the resulting obligations.
let span = self.tcx.hir().body(body_id).value.span; 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 let ok = self
.at(&self.misc(span), self.param_env) .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"); .expect("Failed to unify coroutine interior type");
let mut obligations = ok.obligations; let mut obligations = ok.obligations;