summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness/integer-ranges
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/ui/pattern/usefulness/integer-ranges
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/pattern/usefulness/integer-ranges')
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs20
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr53
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr2
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr140
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs6
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs10
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr18
7 files changed, 149 insertions, 100 deletions
diff --git a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
index 5ea92b070..33c1dfd39 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
@@ -8,7 +8,7 @@ macro_rules! m {
$t2 => {}
_ => {}
}
- }
+ };
}
fn main() {
@@ -16,9 +16,9 @@ fn main() {
m!(0u8, 30..=40, 20..=30); //~ ERROR multiple patterns overlap on their endpoints
m!(0u8, 20..=30, 31..=40);
m!(0u8, 20..=30, 29..=40);
- m!(0u8, 20.. 30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints
- m!(0u8, 20.. 30, 28..=40);
- m!(0u8, 20.. 30, 30..=40);
+ m!(0u8, 20..30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints
+ m!(0u8, 20..30, 28..=40);
+ m!(0u8, 20..30, 30..=40);
m!(0u8, 20..=30, 30..=30);
m!(0u8, 20..=30, 30..=31); //~ ERROR multiple patterns overlap on their endpoints
m!(0u8, 20..=30, 29..=30);
@@ -28,7 +28,7 @@ fn main() {
m!(0u8, 20..=30, 20);
m!(0u8, 20..=30, 25);
m!(0u8, 20..=30, 30);
- m!(0u8, 20.. 30, 29);
+ m!(0u8, 20..30, 29);
m!(0u8, 20, 20..=30);
m!(0u8, 25, 20..=30);
m!(0u8, 30, 20..=30);
@@ -36,19 +36,21 @@ fn main() {
match 0u8 {
0..=10 => {}
20..=30 => {}
- 10..=20 => {} //~ ERROR multiple patterns overlap on their endpoints
+ 10..=20 => {}
+ //~^ ERROR multiple patterns overlap on their endpoints
+ //~| ERROR multiple patterns overlap on their endpoints
_ => {}
}
match (0u8, true) {
(0..=10, true) => {}
- (10..20, true) => {} // not detected
- (10..20, false) => {}
+ (10..20, true) => {} //~ ERROR multiple patterns overlap on their endpoints
+ (10..20, false) => {} //~ ERROR multiple patterns overlap on their endpoints
_ => {}
}
match (true, 0u8) {
(true, 0..=10) => {}
(true, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
- (false, 10..20) => {}
+ (false, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
_ => {}
}
match Some(0u8) {
diff --git a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr
index ea0e8f6e4..a87205d76 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr
@@ -24,10 +24,10 @@ LL | m!(0u8, 30..=40, 20..=30);
= note: you likely meant to write mutually exclusive ranges
error: multiple patterns overlap on their endpoints
- --> $DIR/overlapping_range_endpoints.rs:19:22
+ --> $DIR/overlapping_range_endpoints.rs:19:21
|
-LL | m!(0u8, 20.. 30, 29..=40);
- | ------- ^^^^^^^ ... with this range
+LL | m!(0u8, 20..30, 29..=40);
+ | ------ ^^^^^^^ ... with this range
| |
| this range overlaps on `29_u8`...
|
@@ -59,6 +59,15 @@ error: multiple patterns overlap on their endpoints
LL | 0..=10 => {}
| ------ this range overlaps on `10_u8`...
LL | 20..=30 => {}
+LL | 10..=20 => {}
+ | ^^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:39:9
+ |
+LL | 20..=30 => {}
| ------- this range overlaps on `20_u8`...
LL | 10..=20 => {}
| ^^^^^^^ ... with this range
@@ -66,7 +75,28 @@ LL | 10..=20 => {}
= note: you likely meant to write mutually exclusive ranges
error: multiple patterns overlap on their endpoints
- --> $DIR/overlapping_range_endpoints.rs:50:16
+ --> $DIR/overlapping_range_endpoints.rs:46:10
+ |
+LL | (0..=10, true) => {}
+ | ------ this range overlaps on `10_u8`...
+LL | (10..20, true) => {}
+ | ^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:47:10
+ |
+LL | (0..=10, true) => {}
+ | ------ this range overlaps on `10_u8`...
+LL | (10..20, true) => {}
+LL | (10..20, false) => {}
+ | ^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:52:16
|
LL | (true, 0..=10) => {}
| ------ this range overlaps on `10_u8`...
@@ -76,7 +106,18 @@ LL | (true, 10..20) => {}
= note: you likely meant to write mutually exclusive ranges
error: multiple patterns overlap on their endpoints
- --> $DIR/overlapping_range_endpoints.rs:56:14
+ --> $DIR/overlapping_range_endpoints.rs:53:17
+ |
+LL | (true, 0..=10) => {}
+ | ------ this range overlaps on `10_u8`...
+LL | (true, 10..20) => {}
+LL | (false, 10..20) => {}
+ | ^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:58:14
|
LL | Some(0..=10) => {}
| ------ this range overlaps on `10_u8`...
@@ -85,5 +126,5 @@ LL | Some(10..20) => {}
|
= note: you likely meant to write mutually exclusive ranges
-error: aborting due to 8 previous errors
+error: aborting due to 12 previous errors
diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
index 9f277fa1e..7f26c93aa 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
- --> $DIR/pointer-sized-int.rs:48:11
+ --> $DIR/pointer-sized-int.rs:54:11
|
LL | match 7usize {}
| ^^^^^^
diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
index df330c60b..d16ec5412 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
@@ -1,162 +1,162 @@
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:12:11
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:14:11
|
LL | match 0usize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ 0 ..= usize::MAX => {},
-LL + _ => todo!()
+LL + usize::MAX.. => todo!()
|
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:17:11
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:19:11
|
LL | match 0isize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ isize::MIN ..= isize::MAX => {},
-LL + _ => todo!()
+LL + ..isize::MIN | isize::MAX.. => todo!()
|
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:22:8
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:25:8
|
LL | m!(0usize, 0..=usize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL | match $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
+ | +++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:24:8
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:27:8
|
LL | m!(0usize, 0..5 | 5..=usize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL | match $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
+ | +++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:26:8
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:29:8
|
LL | m!(0usize, 0..usize::MAX | usize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL | match $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
+ | +++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `(_, _)` not covered
- --> $DIR/pointer-sized-int.rs:28:8
+error[E0004]: non-exhaustive patterns: `(usize::MAX.., _)` not covered
+ --> $DIR/pointer-sized-int.rs:31:8
|
LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
- | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+ | ^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered
|
= note: the matched value is of type `(usize, bool)`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL | match $s { $($t)+ => {}, (_, _) => todo!() }
- | +++++++++++++++++++
+LL | match $s { $($t)+ => {}, (usize::MAX.., _) => todo!() }
+ | ++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:31:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:36:8
|
LL | m!(0isize, isize::MIN..=isize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
-LL | match $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:33:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:38:8
|
LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
-LL | match $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:35:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:40:8
|
LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
-LL | match $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `(_, _)` not covered
- --> $DIR/pointer-sized-int.rs:37:8
+error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
+ --> $DIR/pointer-sized-int.rs:42:8
|
LL | m!((0isize, true), (isize::MIN..5, true)
- | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+ | ^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
|
= note: the matched value is of type `(isize, bool)`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
-LL | match $s { $($t)+ => {}, (_, _) => todo!() }
- | +++++++++++++++++++
+LL | match $s { $($t)+ => {}, (..isize::MIN, _) | (isize::MAX.., _) => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:41:11
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:47:11
|
LL | match 0isize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ 1 ..= isize::MAX => {},
-LL + _ => todo!()
+LL + ..isize::MIN | isize::MAX.. => todo!()
|
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
- --> $DIR/pointer-sized-int.rs:48:11
+ --> $DIR/pointer-sized-int.rs:54:11
|
LL | match 7usize {}
| ^^^^^^
diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs
index 1ed18c267..20a3cbe12 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs
@@ -1,6 +1,7 @@
// revisions: allow deny
#![feature(exclusive_range_pattern)]
#![cfg_attr(allow, feature(precise_pointer_size_matching))]
+#![allow(overlapping_range_endpoints)]
macro_rules! m {
($s:expr, $($t:tt)+) => {
@@ -8,6 +9,7 @@ macro_rules! m {
}
}
+#[rustfmt::skip]
fn main() {
match 0usize {
//[deny]~^ ERROR non-exhaustive patterns
@@ -19,6 +21,7 @@ fn main() {
isize::MIN ..= isize::MAX => {}
}
+ m!(0usize, 0..);
m!(0usize, 0..=usize::MAX);
//[deny]~^ ERROR non-exhaustive patterns
m!(0usize, 0..5 | 5..=usize::MAX);
@@ -27,7 +30,9 @@ fn main() {
//[deny]~^ ERROR non-exhaustive patterns
m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
//[deny]~^ ERROR non-exhaustive patterns
+ m!(0usize, 0..=usize::MAX | usize::MAX..);
+ m!(0isize, ..0 | 0..);
m!(0isize, isize::MIN..=isize::MAX);
//[deny]~^ ERROR non-exhaustive patterns
m!(0isize, isize::MIN..5 | 5..=isize::MAX);
@@ -37,6 +42,7 @@ fn main() {
m!((0isize, true), (isize::MIN..5, true)
| (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false));
//[deny]~^^ ERROR non-exhaustive patterns
+ m!(0isize, ..=isize::MIN | isize::MIN..=isize::MAX | isize::MAX..);
match 0isize {
//[deny]~^ ERROR non-exhaustive patterns
diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs
index a2aa655ca..d60f479c0 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs
@@ -1,18 +1,18 @@
// This tests that the lint message explains the reason for the error.
fn main() {
match 0usize {
- //~^ ERROR non-exhaustive patterns: `_` not covered
- //~| NOTE pattern `_` not covered
+ //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered
+ //~| NOTE pattern `usize::MAX..` not covered
//~| NOTE the matched value is of type `usize`
//~| NOTE `usize` does not have a fixed maximum value
0..=usize::MAX => {}
}
match 0isize {
- //~^ ERROR non-exhaustive patterns: `_` not covered
- //~| NOTE pattern `_` not covered
+ //~^ ERROR non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ //~| NOTE patterns `..isize::MIN` and `isize::MAX..` not covered
//~| NOTE the matched value is of type `isize`
- //~| NOTE `isize` does not have a fixed maximum value
+ //~| NOTE `isize` does not have fixed minimum and maximum values
isize::MIN..=isize::MAX => {}
}
}
diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr
index b80411b26..a7f93648e 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr
@@ -1,31 +1,31 @@
-error[E0004]: non-exhaustive patterns: `_` not covered
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
--> $DIR/precise_pointer_matching-message.rs:3:11
|
LL | match 0usize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ 0..=usize::MAX => {},
-LL + _ => todo!()
+LL + usize::MAX.. => todo!()
|
-error[E0004]: non-exhaustive patterns: `_` not covered
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
--> $DIR/precise_pointer_matching-message.rs:11:11
|
LL | match 0isize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
LL ~ isize::MIN..=isize::MAX => {},
-LL + _ => todo!()
+LL + ..isize::MIN | isize::MAX.. => todo!()
|
error: aborting due to 2 previous errors