about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2024-02-16 03:55:00 +0100
committerNadrieril <nadrieril+git@gmail.com>2024-02-17 20:21:57 +0100
commita11abc634385bbaac00718cf095e92a55b8ce272 (patch)
tree4be2c668e977eab87554e3d9b92c886292396a96
parenta0fa2874e64438f61875f6c2538fb7f2eee7d4ba (diff)
downloadrust-a11abc634385bbaac00718cf095e92a55b8ce272.tar.gz
rust-a11abc634385bbaac00718cf095e92a55b8ce272.zip
Simplify return block computation
-rw-r--r--compiler/rustc_mir_build/src/build/matches/mod.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs
index 97e45b74332..5a5daa949b0 100644
--- a/compiler/rustc_mir_build/src/build/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/build/matches/mod.rs
@@ -1315,7 +1315,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
         let mut next_prebinding = start_block;
         let mut reachable = true;
-        let mut last_reachable_candidate = None;
+        let mut return_block = None;
 
         for candidate in matched_candidates.iter_mut() {
             assert!(candidate.otherwise_block.is_none());
@@ -1327,19 +1327,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     // pre-binding block for the next candidate.
                     next_prebinding = self.cfg.start_new_block();
                     candidate.otherwise_block = Some(next_prebinding);
+                    return_block = Some(next_prebinding);
                 } else {
                     reachable = false;
+                    return_block = Some(self.cfg.start_new_block());
                 }
-                last_reachable_candidate = Some(candidate);
             } else {
                 candidate.pre_binding_block = Some(self.cfg.start_new_block());
             }
         }
 
-        last_reachable_candidate
-            .unwrap()
-            .otherwise_block
-            .unwrap_or_else(|| self.cfg.start_new_block())
+        return_block.unwrap()
     }
 
     /// Tests a candidate where there are only or-patterns left to test, or