Skip to content

Commit

Permalink
Auto merge of rust-lang#121133 - tmiasko:skip-coroutines, r=cjgillot
Browse files Browse the repository at this point in the history
Skip coroutines in jump threading to avoid query cycles

Fixes rust-lang#121094
  • Loading branch information
bors committed Feb 15, 2024
2 parents b656f51 + 5f4e4ba commit a447249
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_mir_transform/src/jump_threading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ impl<'tcx> MirPass<'tcx> for JumpThreading {
let def_id = body.source.def_id();
debug!(?def_id);

// Optimizing coroutines creates query cycles.
if tcx.is_coroutine(def_id) {
trace!("Skipped for coroutine {:?}", def_id);
return;
}

let param_env = tcx.param_env_reveal_all_normalized(def_id);
let map = Map::new(tcx, body, Some(MAX_PLACES));
let loop_headers = loop_headers(body);
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/mir/mir_query_cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Regression test for #121094.
// build-pass
// compile-flags: -O --crate-type=lib
// edition: 2021
use std::{future::Future, pin::Pin};

pub async fn foo(count: u32) {
if count == 0 {
return
} else {
let fut: Pin<Box<dyn Future<Output = ()>>> = Box::pin(foo(count - 1));
fut.await;
}
}

0 comments on commit a447249

Please sign in to comment.