about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/constructor.rs
diff options
context:
space:
mode:
authorThe Miri Conjob Bot <miri@cron.bot>2024-01-26 05:09:55 +0000
committerThe Miri Conjob Bot <miri@cron.bot>2024-01-26 05:09:55 +0000
commitb07da7103f0693484affede39264f2a80ad660b2 (patch)
tree75ab5da8f5f8ec79a6ff7333396b9bcd2c56f95b /compiler/rustc_pattern_analysis/src/constructor.rs
parent88e1620760413f43b2ae44684cb2ace869a15b1c (diff)
parentdd2559e08e1530806740931037d6bb83ef956161 (diff)
downloadrust-b07da7103f0693484affede39264f2a80ad660b2.tar.gz
rust-b07da7103f0693484affede39264f2a80ad660b2.zip
Merge from rustc
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/constructor.rs')
-rw-r--r--compiler/rustc_pattern_analysis/src/constructor.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs
index eba71a23435..e94a0373c79 100644
--- a/compiler/rustc_pattern_analysis/src/constructor.rs
+++ b/compiler/rustc_pattern_analysis/src/constructor.rs
@@ -391,12 +391,18 @@ impl IntRange {
 /// first.
 impl fmt::Debug for IntRange {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        if let Finite(lo) = self.lo {
+        if self.is_singleton() {
+            // Only finite ranges can be singletons.
+            let Finite(lo) = self.lo else { unreachable!() };
             write!(f, "{lo}")?;
-        }
-        write!(f, "{}", RangeEnd::Excluded)?;
-        if let Finite(hi) = self.hi {
-            write!(f, "{hi}")?;
+        } else {
+            if let Finite(lo) = self.lo {
+                write!(f, "{lo}")?;
+            }
+            write!(f, "{}", RangeEnd::Excluded)?;
+            if let Finite(hi) = self.hi {
+                write!(f, "{hi}")?;
+            }
         }
         Ok(())
     }