Skip to content

Commit 3fb529e

Browse files
authored
Rollup merge of #123888 - oli-obk:define_opaque_types4, r=compiler-errors
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 r? ``@compiler-errors``
2 parents 360f9ed + c6a4f81 commit 3fb529e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
561561

562562
// Unify `interior` with `witness` and collect all the resulting obligations.
563563
let span = self.tcx.hir().body(body_id).value.span;
564+
let ty::Infer(ty::InferTy::TyVar(_)) = interior.kind() else {
565+
span_bug!(span, "coroutine interior witness not infer: {:?}", interior.kind())
566+
};
564567
let ok = self
565568
.at(&self.misc(span), self.param_env)
566-
.eq(DefineOpaqueTypes::No, interior, witness)
569+
// Will never define opaque types, as all we do is instantiate a type variable.
570+
.eq(DefineOpaqueTypes::Yes, interior, witness)
567571
.expect("Failed to unify coroutine interior type");
568572
let mut obligations = ok.obligations;
569573

compiler/rustc_type_ir/src/ty_kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ pub enum TyKind<I: Interner> {
181181
/// Looking at the following example, the witness for this coroutine
182182
/// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
183183
///
184-
/// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
184+
/// ```
185185
/// #![feature(coroutines)]
186-
/// |a| {
186+
/// static |a| {
187187
/// let x = &vec![3];
188188
/// yield a;
189189
/// yield x[0];

0 commit comments

Comments
 (0)