Skip to content

Commit 211518e

Browse files
committed
Auto merge of rust-lang#120614 - DianQK:simplify-switch-int, r=cjgillot
Transforms match into an assignment statement Fixes rust-lang#106459. We should be able to do some similar transformations, like `enum` to `enum`. r? mir-opt
2 parents 537aab7 + f440737 commit 211518e

16 files changed

+1092
-158
lines changed

compiler/rustc_middle/src/mir/terminator.rs

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ impl SwitchTargets {
8585
self.values.push(value);
8686
self.targets.insert(self.targets.len() - 1, bb);
8787
}
88+
89+
/// Returns true if all targets (including the fallback target) are distinct.
90+
#[inline]
91+
pub fn is_distinct(&self) -> bool {
92+
self.targets.iter().collect::<FxHashSet<_>>().len() == self.targets.len()
93+
}
8894
}
8995

9096
pub struct SwitchTargetsIter<'a> {

0 commit comments

Comments
 (0)