diff options
| author | hyd-dev <yd-huang@outlook.com> | 2021-05-26 00:51:51 +0800 |
|---|---|---|
| committer | hyd-dev <yd-huang@outlook.com> | 2021-05-26 00:51:51 +0800 |
| commit | 0777f1bbafbf8edc1d09fa5239dc4dddb2de31dd (patch) | |
| tree | db44ae86bb3124a2fd0aef9340f2139d956141c5 | |
| parent | 38472e0d5c70596fef584a0e45c4bfadfface4b9 (diff) | |
| download | rust-0777f1bbafbf8edc1d09fa5239dc4dddb2de31dd.tar.gz rust-0777f1bbafbf8edc1d09fa5239dc4dddb2de31dd.zip | |
Use `match` instead of `.map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup)`
| -rw-r--r-- | compiler/rustc_mir/src/interpret/terminator.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_mir/src/interpret/terminator.rs b/compiler/rustc_mir/src/interpret/terminator.rs index 1ee56ca3fc5..a5bdeb55e78 100644 --- a/compiler/rustc_mir/src/interpret/terminator.rs +++ b/compiler/rustc_mir/src/interpret/terminator.rs @@ -110,10 +110,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { abi, &args[..], ret, - if caller_can_unwind { - cleanup.map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup) - } else { - StackPopUnwind::NotAllowed + match (cleanup, caller_can_unwind) { + (Some(cleanup), true) => StackPopUnwind::Cleanup(*cleanup), + (None, true) => StackPopUnwind::Skip, + (_, false) => StackPopUnwind::NotAllowed, }, )?; // 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> { Abi::Rust, &[arg.into()], Some((&dest.into(), target)), - unwind.map_or(StackPopUnwind::Skip, StackPopUnwind::Cleanup), + match unwind { + Some(cleanup) => StackPopUnwind::Cleanup(cleanup), + None => StackPopUnwind::Skip, + }, ) } } |
