Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b98d622

Browse files
author
hyd-dev
committed
Cleanup(Option<_>) -> Cleanup(BasicBlock), Skip
1 parent e743eeb commit b98d622

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

compiler/rustc_mir/src/interpret/eval_context.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ pub struct FrameInfo<'tcx> {
138138
#[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)]
139139
pub enum StackPopUnwind {
140140
/// The cleanup block.
141-
Cleanup(Option<mir::BasicBlock>),
141+
Cleanup(mir::BasicBlock),
142+
/// No cleanup needs to be done.
143+
Skip,
142144
/// Unwinding is not allowed (UB).
143145
NotAllowed,
144146
}
@@ -820,7 +822,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
820822
(StackPopCleanup::Goto { unwind, .. }, true) => (
821823
true,
822824
Some(match unwind {
823-
StackPopUnwind::Cleanup(unwind) => unwind,
825+
StackPopUnwind::Cleanup(unwind) => Some(unwind),
826+
StackPopUnwind::Skip => None,
824827
StackPopUnwind::NotAllowed => {
825828
throw_ub_format!("unwind past a frame that does not allow unwinding")
826829
}

compiler/rustc_mir/src/interpret/terminator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
316316
ret.map(|p| p.0),
317317
StackPopCleanup::Goto {
318318
ret: ret.map(|p| p.1),
319-
unwind: if can_unwind {
320-
StackPopUnwind::Cleanup(unwind)
321-
} else {
322-
StackPopUnwind::NotAllowed
319+
unwind: match (unwind, can_unwind) {
320+
(Some(unwind), true) => StackPopUnwind::Cleanup(unwind),
321+
(None, true) => StackPopUnwind::Skip,
322+
(_, false) => StackPopUnwind::NotAllowed,
323323
},
324324
},
325325
)?;

0 commit comments

Comments
 (0)