Refactor match
+ if
This commit is contained in:
parent
da0abad492
commit
835405199a
1 changed files with 9 additions and 12 deletions
|
@ -143,7 +143,7 @@ pub enum StackPopUnwind {
|
||||||
NotAllowed,
|
NotAllowed,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Debug, HashStable)] // Miri debug-prints these
|
#[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)] // Miri debug-prints these
|
||||||
pub enum StackPopCleanup {
|
pub enum StackPopCleanup {
|
||||||
/// Jump to the next block in the caller, or cause UB if None (that's a function
|
/// Jump to the next block in the caller, or cause UB if None (that's a function
|
||||||
/// that may never return). Also store layout of return place so
|
/// that may never return). Also store layout of return place so
|
||||||
|
@ -815,21 +815,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
|
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
|
||||||
// In that case, we return early. We also avoid validation in that case,
|
// In that case, we return early. We also avoid validation in that case,
|
||||||
// because this is CTFE and the final value will be thoroughly validated anyway.
|
// because this is CTFE and the final value will be thoroughly validated anyway.
|
||||||
let (cleanup, next_block) = match frame.return_to_block {
|
let (cleanup, next_block) = match (frame.return_to_block, unwinding) {
|
||||||
StackPopCleanup::Goto { ret, unwind } => (
|
(StackPopCleanup::Goto { ret, .. }, false) => (true, Some(ret)),
|
||||||
|
(StackPopCleanup::Goto { unwind, .. }, true) => (
|
||||||
true,
|
true,
|
||||||
Some(if unwinding {
|
Some(match unwind {
|
||||||
match unwind {
|
StackPopUnwind::Cleanup(unwind) => unwind,
|
||||||
StackPopUnwind::Cleanup(unwind) => unwind,
|
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")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ret
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
StackPopCleanup::None { cleanup, .. } => (cleanup, None),
|
(StackPopCleanup::None { cleanup, .. }, _) => (cleanup, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !cleanup {
|
if !cleanup {
|
||||||
|
|
Loading…
Add table
Reference in a new issue