about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/constructor.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-26 06:59:26 +0000
committerbors <bors@rust-lang.org>2024-01-26 06:59:26 +0000
commitfae15df5c60ccf0f9eaa96651c869d2c2001fddb (patch)
treeb452546913281a644984fff0862defd7ec76890e /compiler/rustc_pattern_analysis/src/constructor.rs
parent9f4d1a41a6dccf00caace1e9fd20011d586d8b69 (diff)
parent2318b0825cc2892a388b307d38389658f09ac3b6 (diff)
downloadrust-fae15df5c60ccf0f9eaa96651c869d2c2001fddb.tar.gz
rust-fae15df5c60ccf0f9eaa96651c869d2c2001fddb.zip
Auto merge of #3280 - rust-lang:rustup-2024-01-26, r=RalfJung
Automatic Rustup
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(())
     }