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 { mir::TerminatorKind::SwitchInt { discr, targets } => TerminatorKind::SwitchInt {
discr: discr.stable(tables), discr: discr.stable(tables),
targets: { targets: {
let (value_vec, target_vec) = let (value_vec, mut target_vec): (Vec<_>, Vec<_>) =
targets.iter().map(|(value, target)| (value, target.as_usize())).unzip(); 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 } stable_mir::mir::SwitchTargets { value: value_vec, targets: target_vec }
}, },
otherwise: targets.otherwise().as_usize(), otherwise: targets.otherwise().as_usize(),

View file

@ -107,7 +107,7 @@ pub fn pretty_terminator<W: io::Write>(terminator: &TerminatorKind, w: &mut W) -
if i > 0 { if i > 0 {
write!(w, ", ")?; write!(w, ", ")?;
} }
write!(w, "{}: {:?}", labels[i], target)?; write!(w, "{}: bb{:?}", labels[i], target)?;
} }
if show_unwind { if show_unwind {
write!(w, ", ")?; write!(w, ", ")?;
@ -126,7 +126,7 @@ pub fn pretty_terminator_head(terminator: &TerminatorKind) -> String {
match terminator { match terminator {
Goto { .. } => format!(" goto"), Goto { .. } => format!(" goto"),
SwitchInt { discr, .. } => { SwitchInt { discr, .. } => {
format!(" switch({})", pretty_operand(discr)) format!(" switchInt(_{})", pretty_operand(discr))
} }
Resume => format!(" resume"), Resume => format!(" resume"),
Abort => format!(" abort"), Abort => format!(" abort"),