From 7f720304218da4d671bcbc332c0342f9405962c8 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 21 May 2018 20:50:40 +0100 Subject: [PATCH] Fix range splitting --- src/librustc_mir/hair/pattern/_match.rs | 4 ++-- src/test/ui/exhaustive_integer_patterns.stderr | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 4a94030e876..eae2bd7a404 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -725,8 +725,8 @@ fn ranges_subtract_pattern<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, } else { // The pattern intersects the middle of the subrange, // so we create two ranges either side of the intersection.) - remaining_ranges.push((subrange_lo, pat_interval.lo)); - remaining_ranges.push((pat_interval.hi, subrange_hi)); + remaining_ranges.push((subrange_lo, pat_interval.lo - 1)); + remaining_ranges.push((pat_interval.hi + 1, subrange_hi)); } } // Convert the remaining ranges from pairs to inclusive `ConstantRange`s. diff --git a/src/test/ui/exhaustive_integer_patterns.stderr b/src/test/ui/exhaustive_integer_patterns.stderr index 5a0bdebde1f..85f12dad047 100644 --- a/src/test/ui/exhaustive_integer_patterns.stderr +++ b/src/test/ui/exhaustive_integer_patterns.stderr @@ -16,11 +16,11 @@ error[E0004]: non-exhaustive patterns: `128u8...255u8` not covered LL | match x { //~ ERROR non-exhaustive patterns: `128u8...255u8` not covered | ^ pattern `128u8...255u8` not covered -error[E0004]: non-exhaustive patterns: `11u8...20u8`, `30u8...35u8`, `35u8...70u8` and 1 more not covered +error[E0004]: non-exhaustive patterns: `11u8...19u8`, `31u8...34u8`, `36u8...69u8` and 1 more not covered --> $DIR/exhaustive_integer_patterns.rs:42:11 | LL | match x { //~ ERROR non-exhaustive patterns - | ^ patterns `11u8...20u8`, `30u8...35u8`, `35u8...70u8` and 1 more not covered + | ^ patterns `11u8...19u8`, `31u8...34u8`, `36u8...69u8` and 1 more not covered error: unreachable pattern --> $DIR/exhaustive_integer_patterns.rs:53:9 @@ -28,11 +28,11 @@ error: unreachable pattern LL | -2..=20 => {} //~ ERROR unreachable pattern | ^^^^^^^ -error[E0004]: non-exhaustive patterns: `-128i8...-5i8`, `120i8...121i8` and `121i8...127i8` not covered +error[E0004]: non-exhaustive patterns: `-128i8...-6i8` and `122i8...127i8` not covered --> $DIR/exhaustive_integer_patterns.rs:50:11 | LL | match x { //~ ERROR non-exhaustive patterns - | ^ patterns `-128i8...-5i8`, `120i8...121i8` and `121i8...127i8` not covered + | ^ patterns `-128i8...-6i8` and `122i8...127i8` not covered error: aborting due to 5 previous errors