Skip to content

Commit c89d439

Browse files
committed
Be consistent about linting singletons
1 parent d1a50ff commit c89d439

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl IntRange {
161161
// 2 -------- // 2 -------
162162
let (lo, hi) = self.boundaries();
163163
let (other_lo, other_hi) = other.boundaries();
164-
lo == other_hi || hi == other_lo
164+
(lo == other_hi || hi == other_lo) && !self.is_singleton() && !other.is_singleton()
165165
}
166166

167167
fn to_pat<'tcx>(&self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Pat<'tcx> {

src/test/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ fn main() {
2929
m!(0u8, 20..=30, 25);
3030
m!(0u8, 20..=30, 30);
3131
m!(0u8, 20.. 30, 29);
32-
m!(0u8, 20, 20..=30); //~ ERROR multiple patterns overlap on their endpoints
32+
m!(0u8, 20, 20..=30);
3333
m!(0u8, 25, 20..=30);
34-
m!(0u8, 30, 20..=30); //~ ERROR multiple patterns overlap on their endpoints
34+
m!(0u8, 30, 20..=30);
3535

3636
match 0u8 {
3737
0..=10 => {}

src/test/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr

+1-17
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,6 @@ LL | m!(0u8, 20..=30, 19..=20);
4444
| |
4545
| this range overlaps on `20_u8`
4646

47-
error: multiple patterns overlap on their endpoints
48-
--> $DIR/overlapping_range_endpoints.rs:32:17
49-
|
50-
LL | m!(0u8, 20, 20..=30);
51-
| -- ^^^^^^^ overlapping range endpoints
52-
| |
53-
| this range overlaps on `20_u8`
54-
55-
error: multiple patterns overlap on their endpoints
56-
--> $DIR/overlapping_range_endpoints.rs:34:17
57-
|
58-
LL | m!(0u8, 30, 20..=30);
59-
| -- ^^^^^^^ overlapping range endpoints
60-
| |
61-
| this range overlaps on `30_u8`
62-
6347
error: multiple patterns overlap on their endpoints
6448
--> $DIR/overlapping_range_endpoints.rs:39:9
6549
|
@@ -86,5 +70,5 @@ LL | Some(0..=10) => {}
8670
LL | Some(10..20) => {}
8771
| ^^^^^^ overlapping range endpoints
8872

89-
error: aborting due to 10 previous errors
73+
error: aborting due to 8 previous errors
9074

0 commit comments

Comments
 (0)