Cleanup(Option<_>) -> Cleanup(BasicBlock), Skip

This commit is contained in:
hyd-dev
2021-05-22 21:05:59 +08:00
parent e743eeb743
commit b98d6228db
2 changed files with 9 additions and 6 deletions

View File

@@ -138,7 +138,9 @@ pub struct FrameInfo<'tcx> {
#[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)] #[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)]
pub enum StackPopUnwind { pub enum StackPopUnwind {
/// The cleanup block. /// The cleanup block.
Cleanup(Option<mir::BasicBlock>), Cleanup(mir::BasicBlock),
/// No cleanup needs to be done.
Skip,
/// Unwinding is not allowed (UB). /// Unwinding is not allowed (UB).
NotAllowed, NotAllowed,
} }
@@ -820,7 +822,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
(StackPopCleanup::Goto { unwind, .. }, true) => ( (StackPopCleanup::Goto { unwind, .. }, true) => (
true, true,
Some(match unwind { Some(match unwind {
StackPopUnwind::Cleanup(unwind) => unwind, StackPopUnwind::Cleanup(unwind) => Some(unwind),
StackPopUnwind::Skip => None,
StackPopUnwind::NotAllowed => { StackPopUnwind::NotAllowed => {
throw_ub_format!("unwind past a frame that does not allow unwinding") throw_ub_format!("unwind past a frame that does not allow unwinding")
} }

View File

@@ -316,10 +316,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ret.map(|p| p.0), ret.map(|p| p.0),
StackPopCleanup::Goto { StackPopCleanup::Goto {
ret: ret.map(|p| p.1), ret: ret.map(|p| p.1),
unwind: if can_unwind { unwind: match (unwind, can_unwind) {
StackPopUnwind::Cleanup(unwind) (Some(unwind), true) => StackPopUnwind::Cleanup(unwind),
} else { (None, true) => StackPopUnwind::Skip,
StackPopUnwind::NotAllowed (_, false) => StackPopUnwind::NotAllowed,
}, },
}, },
)?; )?;