forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#81897 - vandenheuvel:match_exhaustive_diagn…
…ostics_regression_test, r=Mark-Simulacrum Add match pattern diagnostics regression test Closes rust-lang#72377 by adding a regression test. This test case fails on stable but now works on beta and nightly. It *should* have worked already for years, the crucial point whether it is mentioned that some uncovered patterns are not explicitly mentioned.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#[derive(PartialEq, Eq)] | ||
enum X { A, B, C, } | ||
|
||
fn main() { | ||
let x = X::A; | ||
let y = Some(X::A); | ||
|
||
match (x, y) { | ||
//~^ ERROR non-exhaustive patterns: `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 | ||
//~| more not covered | ||
(_, None) => false, | ||
(v, Some(w)) if v == w => true, | ||
(X::B, Some(X::C)) => false, | ||
(X::B, Some(X::A)) => false, | ||
(X::A, Some(X::C)) | (X::C, Some(X::A)) => false, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0004]: non-exhaustive patterns: `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered | ||
--> $DIR/issue-72377.rs:8:11 | ||
| | ||
LL | match (x, y) { | ||
| ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered | ||
| | ||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
= note: the matched value is of type `(X, Option<X>)` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0004`. |