Avoid query cycles in DataflowConstProp

* Avoid query cycles in DataflowConstProp
* Add -Zmir-opt-level=0 to the test
This commit is contained in:
Ben Kimock
2026-04-24 03:04:03 +00:00
parent e8e4541ff1
commit 4b1f3926de
2 changed files with 16 additions and 0 deletions
@@ -41,6 +41,11 @@ fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
#[instrument(skip_all level = "debug")]
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// Avoid query cycles from coroutines.
if body.coroutine.is_some() {
return;
}
debug!(def_id = ?body.source.def_id());
if tcx.sess.mir_opt_level() < 4 && body.basic_blocks.len() > BLOCK_LIMIT {
debug!("aborted dataflow const prop due too many basic blocks");
@@ -0,0 +1,11 @@
//! Ensure DataflowConstProp doesn't cause an error with async recursion as in #155376.
//@ edition:2018
//@ check-pass
//@ compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+DataflowConstProp --crate-type=lib
pub async fn foo(n: usize) {
if n > 0 {
Box::pin(foo(n - 1)).await;
}
}