Skip to content

Commit 15f9bab

Browse files
committed
add otherwise into targets
1 parent de27790 commit 15f9bab

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/rustc_smir/src/rustc_smir/convert/mir.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,10 @@ impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> {
579579
mir::TerminatorKind::SwitchInt { discr, targets } => TerminatorKind::SwitchInt {
580580
discr: discr.stable(tables),
581581
targets: {
582-
let (value_vec, target_vec) =
582+
let (value_vec, mut target_vec): (Vec<_>, Vec<_>) =
583583
targets.iter().map(|(value, target)| (value, target.as_usize())).unzip();
584+
// We need to push otherwise as last element to ensure it's same as in MIR.
585+
target_vec.push(targets.otherwise().as_usize());
584586
stable_mir::mir::SwitchTargets { value: value_vec, targets: target_vec }
585587
},
586588
otherwise: targets.otherwise().as_usize(),

compiler/stable_mir/src/mir/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub fn pretty_terminator<W: io::Write>(terminator: &TerminatorKind, w: &mut W) -
107107
if i > 0 {
108108
write!(w, ", ")?;
109109
}
110-
write!(w, "{}: {:?}", labels[i], target)?;
110+
write!(w, "{}: bb{:?}", labels[i], target)?;
111111
}
112112
if show_unwind {
113113
write!(w, ", ")?;
@@ -126,7 +126,7 @@ pub fn pretty_terminator_head(terminator: &TerminatorKind) -> String {
126126
match terminator {
127127
Goto { .. } => format!(" goto"),
128128
SwitchInt { discr, .. } => {
129-
format!(" switch({})", pretty_operand(discr))
129+
format!(" switchInt(_{})", pretty_operand(discr))
130130
}
131131
Resume => format!(" resume"),
132132
Abort => format!(" abort"),

0 commit comments

Comments
 (0)