diff options
| author | bors <bors@rust-lang.org> | 2024-02-15 21:30:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-15 21:30:25 +0000 |
| commit | a4472498d7e88041f6206faf4503eb1f246fd427 (patch) | |
| tree | 52b833134cbb686e203a046d8adeaef3f17527db | |
| parent | b656f5171bfecfe748ef365c80c3935abe189141 (diff) | |
| parent | 5f4e4baddb104ee3e63d1db24a4c2a73e1a703cf (diff) | |
| download | rust-a4472498d7e88041f6206faf4503eb1f246fd427.tar.gz rust-a4472498d7e88041f6206faf4503eb1f246fd427.zip | |
Auto merge of #121133 - tmiasko:skip-coroutines, r=cjgillot
Skip coroutines in jump threading to avoid query cycles Fixes #121094
| -rw-r--r-- | compiler/rustc_mir_transform/src/jump_threading.rs | 6 | ||||
| -rw-r--r-- | tests/ui/mir/mir_query_cycle.rs | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 78ba166ba43..ad8f21ffbda 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -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); diff --git a/tests/ui/mir/mir_query_cycle.rs b/tests/ui/mir/mir_query_cycle.rs new file mode 100644 index 00000000000..22d1ccb6c6e --- /dev/null +++ b/tests/ui/mir/mir_query_cycle.rs @@ -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; + } +} |
