diff options
| -rw-r--r-- | src/librustc_mir/hair/pattern/_match.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 69416b4e6b5..7f77e2b0c88 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -1357,6 +1357,10 @@ impl<'tcx> IntRange<'tcx> { remaining_ranges } + fn is_subrange(&self, other: &Self) -> bool { + other.range.start() <= self.range.start() && self.range.end() <= other.range.end() + } + fn intersection(&self, tcx: TyCtxt<'tcx>, other: &Self) -> Option<Self> { let ty = self.ty; let (lo, hi) = self.boundaries(); @@ -1370,7 +1374,7 @@ impl<'tcx> IntRange<'tcx> { } } else { // If the range should not be treated exhaustively, fallback to checking for inclusion. - if other_lo <= lo && hi <= other_hi { Some(self.clone()) } else { None } + if self.is_subrange(other) { Some(self.clone()) } else { None } } } @@ -2236,9 +2240,7 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>( Some(pat) => ctor.intersection(cx.tcx, &pat).map(|_| { // Constructor splitting should ensure that all intersections we encounter // are actually inclusions. - let (pat_lo, pat_hi) = pat.boundaries(); - let (ctor_lo, ctor_hi) = ctor.boundaries(); - assert!(pat_lo <= ctor_lo && ctor_hi <= pat_hi); + assert!(ctor.is_subrange(&pat)); PatStack::default() }), _ => None, |
