Skip to content

Commit 0777f1b

Browse files
author
hyd-dev
committed
Use match instead of .map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup)
1 parent 38472e0 commit 0777f1b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

compiler/rustc_mir/src/interpret/terminator.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
110110
abi,
111111
&args[..],
112112
ret,
113-
if caller_can_unwind {
114-
cleanup.map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup)
115-
} else {
116-
StackPopUnwind::NotAllowed
113+
match (cleanup, caller_can_unwind) {
114+
(Some(cleanup), true) => StackPopUnwind::Cleanup(*cleanup),
115+
(None, true) => StackPopUnwind::Skip,
116+
(_, false) => StackPopUnwind::NotAllowed,
117117
},
118118
)?;
119119
// Sanity-check that `eval_fn_call` either pushed a new frame or
@@ -511,7 +511,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
511511
Abi::Rust,
512512
&[arg.into()],
513513
Some((&dest.into(), target)),
514-
unwind.map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup),
514+
match unwind {
515+
Some(cleanup) => StackPopUnwind::Cleanup(cleanup),
516+
None => StackPopUnwind::Skip,
517+
},
515518
)
516519
}
517520
}

0 commit comments

Comments
 (0)