about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhyd-dev <yd-huang@outlook.com>2021-05-22 21:05:59 +0800
committerhyd-dev <yd-huang@outlook.com>2021-05-23 21:15:59 +0800
commitb98d6228dbf818ba68c9d99ccd77b0204e9735e8 (patch)
treeb7c899b5a28bf77f7d1d4b6a9dabda398e76a09c
parente743eeb743b4e23ecf3cec67cdcd88f6ce056e79 (diff)
downloadrust-b98d6228dbf818ba68c9d99ccd77b0204e9735e8.tar.gz
rust-b98d6228dbf818ba68c9d99ccd77b0204e9735e8.zip
`Cleanup(Option<_>)` -> `Cleanup(BasicBlock), Skip`
-rw-r--r--compiler/rustc_mir/src/interpret/eval_context.rs7
-rw-r--r--compiler/rustc_mir/src/interpret/terminator.rs8
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_mir/src/interpret/eval_context.rs b/compiler/rustc_mir/src/interpret/eval_context.rs
index 8c61d4c0895..b683aca9f05 100644
--- a/compiler/rustc_mir/src/interpret/eval_context.rs
+++ b/compiler/rustc_mir/src/interpret/eval_context.rs
@@ -138,7 +138,9 @@ pub struct FrameInfo<'tcx> {
 #[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)]
 pub enum StackPopUnwind {
     /// The cleanup block.
-    Cleanup(Option<mir::BasicBlock>),
+    Cleanup(mir::BasicBlock),
+    /// No cleanup needs to be done.
+    Skip,
     /// Unwinding is not allowed (UB).
     NotAllowed,
 }
@@ -820,7 +822,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             (StackPopCleanup::Goto { unwind, .. }, true) => (
                 true,
                 Some(match unwind {
-                    StackPopUnwind::Cleanup(unwind) => unwind,
+                    StackPopUnwind::Cleanup(unwind) => Some(unwind),
+                    StackPopUnwind::Skip => None,
                     StackPopUnwind::NotAllowed => {
                         throw_ub_format!("unwind past a frame that does not allow unwinding")
                     }
diff --git a/compiler/rustc_mir/src/interpret/terminator.rs b/compiler/rustc_mir/src/interpret/terminator.rs
index 2564ea95e43..27b2716c5bd 100644
--- a/compiler/rustc_mir/src/interpret/terminator.rs
+++ b/compiler/rustc_mir/src/interpret/terminator.rs
@@ -316,10 +316,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                     ret.map(|p| p.0),
                     StackPopCleanup::Goto {
                         ret: ret.map(|p| p.1),
-                        unwind: if can_unwind {
-                            StackPopUnwind::Cleanup(unwind)
-                        } else {
-                            StackPopUnwind::NotAllowed
+                        unwind: match (unwind, can_unwind) {
+                            (Some(unwind), true) => StackPopUnwind::Cleanup(unwind),
+                            (None, true) => StackPopUnwind::Skip,
+                            (_, false) => StackPopUnwind::NotAllowed,
                         },
                     },
                 )?;