Skip to content

Commit c643dd2

Browse files
committed
Auto merge of #79243 - Nadrieril:consolidate-tests, r=varkor
Consolidate exhaustiveness-related tests I hunted for tests that only exercised the match exhaustiveness algorithm and regrouped them. I also improved integer-range tests since I had found them lacking while hacking around. The interest is mainly so that one can pass `--test-args patterns` and catch most relevant tests. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2 parents 52e3cf1 + 3213efc commit c643dd2

File tree

71 files changed

+908
-665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+908
-665
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! - ui/or-patterns
44
//! - ui/consts/const_in_pattern
55
//! - ui/rfc-2008-non-exhaustive
6+
//! - ui/half-open-range-patterns
67
//! - probably many others
78
//! I (Nadrieril) prefer to put new tests in `ui/pattern/usefulness` unless there's a specific
89
//! reason not to, for example if they depend on a particular feature like or_patterns.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
#![feature(exclusive_range_pattern)]
2-
3-
use std::usize::MAX;
1+
use std::{isize, usize};
42

53
fn main() {
6-
match 0usize { //~ERROR non-exhaustive patterns: `_` not covered
7-
0..=MAX => {}
4+
match 0usize {
5+
//~^ ERROR non-exhaustive patterns: `_` not covered
6+
//~| NOTE pattern `_` not covered
7+
//~| NOTE the matched value is of type `usize`
8+
//~| NOTE `usize` does not have a fixed maximum value
9+
0..=usize::MAX => {}
810
}
911

10-
match 0isize { //~ERROR non-exhaustive patterns: `_` not covered
11-
1..=20 => {}
12-
-5..3 => {}
12+
match 0isize {
13+
//~^ ERROR non-exhaustive patterns: `_` not covered
14+
//~| NOTE pattern `_` not covered
15+
//~| NOTE the matched value is of type `isize`
16+
//~| NOTE `isize` does not have a fixed maximum value
17+
isize::MIN..=isize::MAX => {}
1318
}
1419
}

src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0004]: non-exhaustive patterns: `_` not covered
2-
--> $DIR/feature-gate-precise_pointer_size_matching.rs:6:11
2+
--> $DIR/feature-gate-precise_pointer_size_matching.rs:4:11
33
|
44
LL | match 0usize {
55
| ^^^^^^ pattern `_` not covered
@@ -10,7 +10,7 @@ LL | match 0usize {
1010
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
1111

1212
error[E0004]: non-exhaustive patterns: `_` not covered
13-
--> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11
13+
--> $DIR/feature-gate-precise_pointer_size_matching.rs:12:11
1414
|
1515
LL | match 0isize {
1616
| ^^^^^^ pattern `_` not covered

src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs

-172
This file was deleted.

src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr

-146
This file was deleted.

src/test/ui/pattern/usefulness/non-exhaustive-float-range-match.rs src/test/ui/pattern/usefulness/floats.rs

+6
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ fn main() {
1010
match 0.0 { //~ ERROR non-exhaustive patterns
1111
0.0..=1.0 => {}
1212
}
13+
14+
match 1.0f64 {
15+
0.01f64 ..= 6.5f64 => {}
16+
0.02f64 => {} //~ ERROR unreachable pattern
17+
_ => {}
18+
};
1319
}

0 commit comments

Comments
 (0)