Skip to content

Commit a447249

Browse files
committed
Auto merge of rust-lang#121133 - tmiasko:skip-coroutines, r=cjgillot
Skip coroutines in jump threading to avoid query cycles Fixes rust-lang#121094
2 parents b656f51 + 5f4e4ba commit a447249

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

compiler/rustc_mir_transform/src/jump_threading.rs

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ impl<'tcx> MirPass<'tcx> for JumpThreading {
6868
let def_id = body.source.def_id();
6969
debug!(?def_id);
7070

71+
// Optimizing coroutines creates query cycles.
72+
if tcx.is_coroutine(def_id) {
73+
trace!("Skipped for coroutine {:?}", def_id);
74+
return;
75+
}
76+
7177
let param_env = tcx.param_env_reveal_all_normalized(def_id);
7278
let map = Map::new(tcx, body, Some(MAX_PLACES));
7379
let loop_headers = loop_headers(body);

tests/ui/mir/mir_query_cycle.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for #121094.
2+
// build-pass
3+
// compile-flags: -O --crate-type=lib
4+
// edition: 2021
5+
use std::{future::Future, pin::Pin};
6+
7+
pub async fn foo(count: u32) {
8+
if count == 0 {
9+
return
10+
} else {
11+
let fut: Pin<Box<dyn Future<Output = ()>>> = Box::pin(foo(count - 1));
12+
fut.await;
13+
}
14+
}

0 commit comments

Comments
 (0)