Skip to content

Commit

Permalink
Auto merge of rust-lang#79243 - Nadrieril:consolidate-tests, r=varkor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 22, 2020
2 parents 52e3cf1 + 3213efc commit c643dd2
Show file tree
Hide file tree
Showing 71 changed files with 908 additions and 665 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_mir_build/src/thir/pattern/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! - ui/or-patterns
//! - ui/consts/const_in_pattern
//! - ui/rfc-2008-non-exhaustive
//! - ui/half-open-range-patterns
//! - probably many others
//! I (Nadrieril) prefer to put new tests in `ui/pattern/usefulness` unless there's a specific
//! reason not to, for example if they depend on a particular feature like or_patterns.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#![feature(exclusive_range_pattern)]

use std::usize::MAX;
use std::{isize, usize};

fn main() {
match 0usize { //~ERROR non-exhaustive patterns: `_` not covered
0..=MAX => {}
match 0usize {
//~^ ERROR non-exhaustive patterns: `_` not covered
//~| NOTE pattern `_` 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
1..=20 => {}
-5..3 => {}
match 0isize {
//~^ ERROR non-exhaustive patterns: `_` not covered
//~| NOTE pattern `_` not covered
//~| NOTE the matched value is of type `isize`
//~| NOTE `isize` does not have a fixed maximum value
isize::MIN..=isize::MAX => {}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/feature-gate-precise_pointer_size_matching.rs:6:11
--> $DIR/feature-gate-precise_pointer_size_matching.rs:4:11
|
LL | match 0usize {
| ^^^^^^ pattern `_` not covered
Expand All @@ -10,7 +10,7 @@ LL | match 0usize {
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching

error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11
--> $DIR/feature-gate-precise_pointer_size_matching.rs:12:11
|
LL | match 0isize {
| ^^^^^^ pattern `_` not covered
Expand Down
File renamed without changes.
172 changes: 0 additions & 172 deletions src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs

This file was deleted.

146 changes: 0 additions & 146 deletions src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ fn main() {
match 0.0 { //~ ERROR non-exhaustive patterns
0.0..=1.0 => {}
}

match 1.0f64 {
0.01f64 ..= 6.5f64 => {}
0.02f64 => {} //~ ERROR unreachable pattern
_ => {}
};
}
Loading

0 comments on commit c643dd2

Please sign in to comment.