Skip to content

Commit 34cdeae

Browse files
committed
Fix SwitchTarget pretty print
We currently rely on the order of successors to be conditional branches first, followed by the otherwise target.
1 parent 9242c5e commit 34cdeae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/stable_mir/src/mir/body.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -672,19 +672,19 @@ pub struct SwitchTargets {
672672
impl SwitchTargets {
673673
/// All possible targets including the `otherwise` target.
674674
pub fn all_targets(&self) -> Successors {
675-
Some(self.otherwise)
676-
.into_iter()
677-
.chain(self.branches.iter().map(|(_, target)| *target))
675+
self.branches.iter().map(|(_, target)| *target).chain(Some(self.otherwise))
678676
.collect()
679677
}
680678

681679
/// The `otherwise` branch target.
682680
pub fn otherwise(&self) -> BasicBlockIdx {
681+
eprintln!("Otherwise: {:?}", self.otherwise);
683682
self.otherwise
684683
}
685684

686685
/// The conditional targets which are only taken if the pattern matches the given value.
687686
pub fn branches(&self) -> impl Iterator<Item = (u128, BasicBlockIdx)> + '_ {
687+
eprintln!("Branches: {:?}", self.branches);
688688
self.branches.iter().copied()
689689
}
690690

@@ -695,6 +695,7 @@ impl SwitchTargets {
695695

696696
/// Create a new SwitchTargets from the given branches and `otherwise` target.
697697
pub fn new(branches: Vec<(u128, BasicBlockIdx)>, otherwise: BasicBlockIdx) -> SwitchTargets {
698+
eprintln!("Branches: {branches:?} -- otherwise: {otherwise:?}");
698699
SwitchTargets { branches, otherwise }
699700
}
700701
}

0 commit comments

Comments
 (0)