Skip to content

Commit 0435b16

Browse files
committed
swap order of resolve_coroutine_interiors and handle_opaque_type_uses
1 parent c131805 commit 0435b16

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -611,19 +611,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
611611
typeck_results.rvalue_scopes = rvalue_scopes;
612612
}
613613

614-
/// Unify the inference variables corresponding to coroutine witnesses, and save all the
615-
/// predicates that were stalled on those inference variables.
616-
///
617-
/// This process allows to conservatively save all predicates that do depend on the coroutine
618-
/// interior types, for later processing by `check_coroutine_obligations`.
619-
///
620-
/// We must not attempt to select obligations after this method has run, or risk query cycle
621-
/// ICE.
614+
/// Drain all obligations that are stalled on coroutines defined in this body.
622615
#[instrument(level = "debug", skip(self))]
623-
pub(crate) fn resolve_coroutine_interiors(&self) {
624-
// Try selecting all obligations that are not blocked on inference variables.
625-
// Once we start unifying coroutine witnesses, trying to select obligations on them will
626-
// trigger query cycle ICEs, as doing so requires MIR.
616+
pub(crate) fn drain_stalled_coroutine_obligations(&self) {
617+
// Make as much inference progress as possible before
618+
// draining the stalled coroutine obligations as this may
619+
// change obligations from being stalled on infer vars to
620+
// being stalled on a coroutine.
627621
self.select_obligations_where_possible(|_| {});
628622

629623
let ty::TypingMode::Analysis { defining_opaque_types_and_generators } = self.typing_mode()

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,15 @@ fn typeck_with_inspect<'tcx>(
243243

244244
debug!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations());
245245

246-
// This must be the last thing before `report_ambiguity_errors`.
247-
fcx.resolve_coroutine_interiors();
248-
249-
debug!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations());
250-
251246
// We need to handle opaque types before emitting ambiguity errors as applying
252247
// defining uses may guide type inference.
253248
if fcx.next_trait_solver() {
254249
fcx.handle_opaque_type_uses_next();
255250
}
256251

257-
fcx.select_obligations_where_possible(|_| {});
252+
// This must be the last thing before `report_ambiguity_errors` below except `select_obligations_where_possible`.
253+
// So don't put anything after this.
254+
fcx.drain_stalled_coroutine_obligations();
258255
if fcx.infcx.tainted_by_errors().is_none() {
259256
fcx.report_ambiguity_errors();
260257
}

0 commit comments

Comments
 (0)