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

This commit is contained in:
hyd-dev 2021-05-22 21:05:59 +08:00
parent e743eeb743
commit b98d6228db
No known key found for this signature in database
GPG Key ID: 74FA7FD5B8DA14B8
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)]
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")
}

View File

@ -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,
},
},
)?;