Rollup merge of #67026 - Nadrieril:improve-usefulness-empty, r=varkor,Centril,estebank

Improve diagnostics and code for exhaustiveness of empty matches

There was a completely separate check and diagnostics for the case of an empty match. This led to slightly different error messages and duplicated code.
This improves code reuse and generally clarifies what happens for empty matches. This also clarifies the action of the `exhaustive_patterns` feature, and ensures that this feature doesn't change diagnostics in places it doesn't need to.
This commit is contained in:
Mazdak Farrokhzad 2019-12-13 20:35:28 +01:00 committed by GitHub
commit df9e491fb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 889 additions and 182 deletions

View file

@ -1,8 +1,8 @@
error[E0004]: non-exhaustive patterns: multiple patterns of type `std::option::Option<i32>` are not handled
error[E0004]: non-exhaustive patterns: `None` and `Some(_)` not covered
--> $DIR/E0004-2.rs:4:11
|
LL | match x { }
| ^
| ^ patterns `None` and `Some(_)` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms