Skip to content

Commit 7f72030

Browse files
committed
Fix range splitting
1 parent a20cb10 commit 7f72030

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ fn ranges_subtract_pattern<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
725725
} else {
726726
// The pattern intersects the middle of the subrange,
727727
// so we create two ranges either side of the intersection.)
728-
remaining_ranges.push((subrange_lo, pat_interval.lo));
729-
remaining_ranges.push((pat_interval.hi, subrange_hi));
728+
remaining_ranges.push((subrange_lo, pat_interval.lo - 1));
729+
remaining_ranges.push((pat_interval.hi + 1, subrange_hi));
730730
}
731731
}
732732
// Convert the remaining ranges from pairs to inclusive `ConstantRange`s.

src/test/ui/exhaustive_integer_patterns.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ error[E0004]: non-exhaustive patterns: `128u8...255u8` not covered
1616
LL | match x { //~ ERROR non-exhaustive patterns: `128u8...255u8` not covered
1717
| ^ pattern `128u8...255u8` not covered
1818

19-
error[E0004]: non-exhaustive patterns: `11u8...20u8`, `30u8...35u8`, `35u8...70u8` and 1 more not covered
19+
error[E0004]: non-exhaustive patterns: `11u8...19u8`, `31u8...34u8`, `36u8...69u8` and 1 more not covered
2020
--> $DIR/exhaustive_integer_patterns.rs:42:11
2121
|
2222
LL | match x { //~ ERROR non-exhaustive patterns
23-
| ^ patterns `11u8...20u8`, `30u8...35u8`, `35u8...70u8` and 1 more not covered
23+
| ^ patterns `11u8...19u8`, `31u8...34u8`, `36u8...69u8` and 1 more not covered
2424

2525
error: unreachable pattern
2626
--> $DIR/exhaustive_integer_patterns.rs:53:9
2727
|
2828
LL | -2..=20 => {} //~ ERROR unreachable pattern
2929
| ^^^^^^^
3030

31-
error[E0004]: non-exhaustive patterns: `-128i8...-5i8`, `120i8...121i8` and `121i8...127i8` not covered
31+
error[E0004]: non-exhaustive patterns: `-128i8...-6i8` and `122i8...127i8` not covered
3232
--> $DIR/exhaustive_integer_patterns.rs:50:11
3333
|
3434
LL | match x { //~ ERROR non-exhaustive patterns
35-
| ^ patterns `-128i8...-5i8`, `120i8...121i8` and `121i8...127i8` not covered
35+
| ^ patterns `-128i8...-6i8` and `122i8...127i8` not covered
3636

3737
error: aborting due to 5 previous errors
3838

0 commit comments

Comments
 (0)