mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Avoid query cycles in DataflowConstProp
* Avoid query cycles in DataflowConstProp * Add -Zmir-opt-level=0 to the test
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user