1
Fork 0

add otherwise into targets

This commit is contained in:
ouz-a 2023-11-27 21:26:11 +03:00
parent de2779077a
commit 15f9bab7ba
2 changed files with 5 additions and 3 deletions

View file

@ -579,8 +579,10 @@ impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> {
mir::TerminatorKind::SwitchInt { discr, targets } => TerminatorKind::SwitchInt {
discr: discr.stable(tables),
targets: {
let (value_vec, target_vec) =
let (value_vec, mut target_vec): (Vec<_>, Vec<_>) =
targets.iter().map(|(value, target)| (value, target.as_usize())).unzip();
// We need to push otherwise as last element to ensure it's same as in MIR.
target_vec.push(targets.otherwise().as_usize());
stable_mir::mir::SwitchTargets { value: value_vec, targets: target_vec }
},
otherwise: targets.otherwise().as_usize(),