diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-01-24 20:09:30 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-01-24 20:09:30 +0100 |
| commit | 354b45f52854d4534aaf4bf860d539a9657a596f (patch) | |
| tree | 56ce38bce13ceba70fe5e6c7357a75e6165b5043 /compiler/rustc_pattern_analysis/src/constructor.rs | |
| parent | bdab21399372bee9127b5e6641c8a54034005138 (diff) | |
| download | rust-354b45f52854d4534aaf4bf860d539a9657a596f.tar.gz rust-354b45f52854d4534aaf4bf860d539a9657a596f.zip | |
Improve `Range: Debug` impl
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/constructor.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/constructor.rs | 16 |
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(()) } |
