about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-21 18:54:29 +0000
committerbors <bors@rust-lang.org>2025-06-21 18:54:29 +0000
commitd4e1159b8c97478778b09a4cc1c7adce5653b8bf (patch)
tree5b30910b66c51467b03d70720091e96e07551995 /compiler
parentea34650916887b5075812d0f11c1d3209e7f94ab (diff)
parent89b079d844454d0288fbce1160dab129987a4921 (diff)
downloadrust-d4e1159b8c97478778b09a4cc1c7adce5653b8bf.tar.gz
rust-d4e1159b8c97478778b09a4cc1c7adce5653b8bf.zip
Auto merge of #142546 - cjgillot:reachable-jump, r=compiler-errors
Only traverse reachable blocks in JumpThreading.

Fixes https://github.com/rust-lang/rust/issues/131451

We only compute loop headers for reachable blocks. We shouldn't try to perform an opt on unreachable blocks anyway.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_transform/src/jump_threading.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs
index 48db536c122..b45bff2af44 100644
--- a/compiler/rustc_mir_transform/src/jump_threading.rs
+++ b/compiler/rustc_mir_transform/src/jump_threading.rs
@@ -89,7 +89,7 @@ impl<'tcx> crate::MirPass<'tcx> for JumpThreading {
             opportunities: Vec::new(),
         };
 
-        for bb in body.basic_blocks.indices() {
+        for (bb, _) in traversal::preorder(body) {
             finder.start_from_switch(bb);
         }