Skip to content

Commit

Permalink
Fix SwitchTarget pretty print
Browse files Browse the repository at this point in the history
We currently rely on the order of successors to be conditional branches
first, followed by the otherwise target.
  • Loading branch information
celinval committed Nov 30, 2023
1 parent 3e0b2fa commit 9d2c923
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions compiler/stable_mir/src/mir/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,7 @@ pub struct SwitchTargets {
impl SwitchTargets {
/// All possible targets including the `otherwise` target.
pub fn all_targets(&self) -> Successors {
Some(self.otherwise)
.into_iter()
.chain(self.branches.iter().map(|(_, target)| *target))
.collect()
self.branches.iter().map(|(_, target)| *target).chain(Some(self.otherwise)).collect()
}

/// The `otherwise` branch target.
Expand Down

0 comments on commit 9d2c923

Please sign in to comment.