From e32ec45c02d890e46e55af86163a6d1ba10a4b41 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Fri, 4 Oct 2024 20:26:41 +0000 Subject: MatchBranchSimplification: Consider empty-unreachable otherwise branch --- compiler/rustc_middle/src/mir/terminator.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'compiler/rustc_middle') diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index b919f5726db..473b817aed0 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -67,6 +67,17 @@ impl SwitchTargets { &mut self.targets } + /// Returns a slice with all considered values (not including the fallback). + #[inline] + pub fn all_values(&self) -> &[Pu128] { + &self.values + } + + #[inline] + pub fn all_values_mut(&mut self) -> &mut [Pu128] { + &mut self.values + } + /// Finds the `BasicBlock` to which this `SwitchInt` will branch given the /// specific value. This cannot fail, as it'll return the `otherwise` /// branch if there's not a specific match for the value. -- cgit 1.4.1-3-g733a5