about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2021-08-02 07:27:17 -0700
committerAlex Crichton <alex@alexcrichton.com>2021-08-03 07:06:19 -0700
commit0168dfec6d8ec4dcb037401ae0c9c9ec8efcc173 (patch)
tree582516ca9db761e7c2431ca43387caf82fc7b2c3
parent30bc5a936bf7dd57ba5dedaa5d2054f01d1eab2c (diff)
downloadrust-0168dfec6d8ec4dcb037401ae0c9c9ec8efcc173.tar.gz
rust-0168dfec6d8ec4dcb037401ae0c9c9ec8efcc173.zip
Use predefined helper instead of a new one
-rw-r--r--compiler/rustc_mir/src/transform/abort_unwinding_calls.rs15
1 files changed, 2 insertions, 13 deletions
diff --git a/compiler/rustc_mir/src/transform/abort_unwinding_calls.rs b/compiler/rustc_mir/src/transform/abort_unwinding_calls.rs
index 44287dbd608..aecb2373eaf 100644
--- a/compiler/rustc_mir/src/transform/abort_unwinding_calls.rs
+++ b/compiler/rustc_mir/src/transform/abort_unwinding_calls.rs
@@ -125,13 +125,13 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
             let abort_bb = body.basic_blocks_mut().push(bb);
 
             for bb in calls_to_terminate {
-                let cleanup = get_cleanup(body.basic_blocks_mut()[bb].terminator_mut());
+                let cleanup = body.basic_blocks_mut()[bb].terminator_mut().unwind_mut().unwrap();
                 *cleanup = Some(abort_bb);
             }
         }
 
         for id in cleanups_to_remove {
-            let cleanup = get_cleanup(body.basic_blocks_mut()[id].terminator_mut());
+            let cleanup = body.basic_blocks_mut()[id].terminator_mut().unwind_mut().unwrap();
             *cleanup = None;
         }
 
@@ -139,14 +139,3 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
         super::simplify::remove_dead_blocks(tcx, body);
     }
 }
-
-fn get_cleanup<'a>(t: &'a mut Terminator<'_>) -> &'a mut Option<BasicBlock> {
-    match &mut t.kind {
-        TerminatorKind::Call { cleanup, .. }
-        | TerminatorKind::Drop { unwind: cleanup, .. }
-        | TerminatorKind::DropAndReplace { unwind: cleanup, .. }
-        | TerminatorKind::Assert { cleanup, .. }
-        | TerminatorKind::FalseUnwind { unwind: cleanup, .. } => cleanup,
-        _ => unreachable!(),
-    }
-}