Skip to content

Commit 25f1d82

Browse files
authored
Rollup merge of rust-lang#147202 - jdonszelmann:swap-order, r=lcnr
Swap order of `resolve_coroutine_interiors` and `handle_opaque_type_uses` r? ```@BoxyUwU``` if the comment says x should be last, it helps if it's actually last hehe :P Fixes rust-lang/trait-system-refactor-initiative#239
2 parents 1feb547 + 0435b16 commit 25f1d82

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-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
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/239
2+
//@edition: 2024
3+
//@ check-pass
4+
//@ revisions: current next
5+
//@ ignore-compare-mode-next-solver (explicit revisions)
6+
//@[next] compile-flags: -Znext-solver
7+
8+
fn foo<'a>() -> impl Send {
9+
if false {
10+
foo();
11+
}
12+
async {}
13+
}
14+
15+
fn main() {}

0 commit comments

Comments
 (0)