Skip to content

Commit d8ff397

Browse files
committed
check stalled coroutine obligations eagerly
1 parent be4794c commit d8ff397

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

compiler/rustc_borrowck/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ fn mir_borrowck(
121121
let (input_body, _) = tcx.mir_promoted(def);
122122
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
123123

124+
// We should eagerly check stalled coroutine obligations from HIR typeck.
125+
// Not doing so leads to silent normalization failures later, which will
126+
// fail to register opaque types in the next solver.
127+
tcx.check_coroutine_obligations(def)?;
128+
124129
let input_body: &Body<'_> = &input_body.borrow();
125130
if let Some(guar) = input_body.tainted_by_errors {
126131
debug!("Skipping borrowck because of tainted body");

compiler/rustc_interface/src/passes.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,18 +1116,14 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
11161116
{
11171117
tcx.ensure_ok().mir_drops_elaborated_and_const_checked(def_id);
11181118
}
1119-
if tcx.is_coroutine(def_id.to_def_id()) {
1120-
tcx.ensure_ok().mir_coroutine_witnesses(def_id);
1121-
let _ = tcx.ensure_ok().check_coroutine_obligations(
1122-
tcx.typeck_root_def_id(def_id.to_def_id()).expect_local(),
1119+
if tcx.is_coroutine(def_id.to_def_id())
1120+
&& (!tcx.is_async_drop_in_place_coroutine(def_id.to_def_id()))
1121+
{
1122+
// Eagerly check the unsubstituted layout for cycles.
1123+
tcx.ensure_ok().layout_of(
1124+
ty::TypingEnv::post_analysis(tcx, def_id.to_def_id())
1125+
.as_query_input(tcx.type_of(def_id).instantiate_identity()),
11231126
);
1124-
if !tcx.is_async_drop_in_place_coroutine(def_id.to_def_id()) {
1125-
// Eagerly check the unsubstituted layout for cycles.
1126-
tcx.ensure_ok().layout_of(
1127-
ty::TypingEnv::post_analysis(tcx, def_id.to_def_id())
1128-
.as_query_input(tcx.type_of(def_id).instantiate_identity()),
1129-
);
1130-
}
11311127
}
11321128
});
11331129
});

0 commit comments

Comments
 (0)