Skip to content

Commit 4b1f392

Browse files
committed
Avoid query cycles in DataflowConstProp
* Avoid query cycles in DataflowConstProp * Add -Zmir-opt-level=0 to the test
1 parent e8e4541 commit 4b1f392

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ impl<'tcx> crate::MirPass<'tcx> for DataflowConstProp {
4141

4242
#[instrument(skip_all level = "debug")]
4343
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
44+
// Avoid query cycles from coroutines.
45+
if body.coroutine.is_some() {
46+
return;
47+
}
48+
4449
debug!(def_id = ?body.source.def_id());
4550
if tcx.sess.mir_opt_level() < 4 && body.basic_blocks.len() > BLOCK_LIMIT {
4651
debug!("aborted dataflow const prop due too many basic blocks");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Ensure DataflowConstProp doesn't cause an error with async recursion as in #155376.
2+
3+
//@ edition:2018
4+
//@ check-pass
5+
//@ compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+DataflowConstProp --crate-type=lib
6+
7+
pub async fn foo(n: usize) {
8+
if n > 0 {
9+
Box::pin(foo(n - 1)).await;
10+
}
11+
}

0 commit comments

Comments
 (0)