about summary refs log tree commit diff
path: root/src/test/ui/pattern/usefulness
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2019-12-02 17:10:20 +0000
committerNadrieril <nadrieril+git@gmail.com>2019-12-04 16:43:21 +0000
commit5628d4a7c336bb567d5e1ccf2da02b528f3b230d (patch)
tree4ff5f02c1cf54a7d889ff8ee48f6e03fffe46747 /src/test/ui/pattern/usefulness
parent1c77a049b9595bbc857317ff8a7713c76ddbd8af (diff)
downloadrust-5628d4a7c336bb567d5e1ccf2da02b528f3b230d.tar.gz
rust-5628d4a7c336bb567d5e1ccf2da02b528f3b230d.zip
Make empty match lint more consistent under exhaustive_patterns
Diffstat (limited to 'src/test/ui/pattern/usefulness')
-rw-r--r--src/test/ui/pattern/usefulness/always-inhabited-union-ref.rs2
-rw-r--r--src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr14
-rw-r--r--src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs22
-rw-r--r--src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr45
4 files changed, 58 insertions, 25 deletions
diff --git a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.rs b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.rs
index 11eae2af9c9..b568057ed1e 100644
--- a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.rs
+++ b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.rs
@@ -25,7 +25,7 @@ fn match_on_uninhab() {
     }
 
     match uninhab_union() {
-        //~^ ERROR non-exhaustive patterns: type `Foo` is non-empty
+        //~^ ERROR non-exhaustive patterns: pattern `Foo` of type `Foo` is not handled
     }
 }
 
diff --git a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr
index 792ab6f59a4..acf926e9a83 100644
--- a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr
+++ b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr
@@ -6,11 +6,19 @@ LL |     match uninhab_ref() {
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: type `Foo` is non-empty
+error[E0004]: non-exhaustive patterns: pattern `Foo` of type `Foo` is not handled
   --> $DIR/always-inhabited-union-ref.rs:27:11
    |
-LL |     match uninhab_union() {
-   |           ^^^^^^^^^^^^^^^
+LL |   pub union Foo {
+   |   -         --- variant not covered
+   |  _|
+   | |
+LL | |     foo: !,
+LL | | }
+   | |_- `Foo` defined here
+...
+LL |       match uninhab_union() {
+   |             ^^^^^^^^^^^^^^^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs
index 3d01c31f036..01671eb5ce3 100644
--- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs
+++ b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs
@@ -3,15 +3,15 @@
 #![deny(unreachable_patterns)]
 enum Foo {}
 
-struct NonEmptyStruct(bool);
-enum NonEmptyEnum1 {
-    Foo(bool),
+struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here
+enum NonEmptyEnum1 { //~ `NonEmptyEnum1` defined here
+    Foo(bool), //~ variant not covered
 }
-enum NonEmptyEnum2 {
-    Foo(bool),
-    Bar,
+enum NonEmptyEnum2 { //~ `NonEmptyEnum2` defined here
+    Foo(bool), //~ variant not covered
+    Bar, //~ variant not covered
 }
-enum NonEmptyEnum5 {
+enum NonEmptyEnum5 { //~ `NonEmptyEnum5` defined here
     V1, V2, V3, V4, V5,
 }
 
@@ -35,11 +35,11 @@ fn main() {
     match 0u8 {}
     //~^ ERROR type `u8` is non-empty
     match NonEmptyStruct(true) {}
-    //~^ ERROR type `NonEmptyStruct` is non-empty
+    //~^ ERROR pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled
     match NonEmptyEnum1::Foo(true) {}
-    //~^ ERROR type `NonEmptyEnum1` is non-empty
+    //~^ ERROR pattern `Foo` of type `NonEmptyEnum1` is not handled
     match NonEmptyEnum2::Foo(true) {}
-    //~^ ERROR type `NonEmptyEnum2` is non-empty
+    //~^ ERROR multiple patterns of type `NonEmptyEnum2` are not handled
     match NonEmptyEnum5::V1 {}
-    //~^ ERROR type `NonEmptyEnum5` is non-empty
+    //~^ ERROR multiple patterns of type `NonEmptyEnum5` are not handled
 }
diff --git a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr
index 19c16dba000..d126b9185d1 100644
--- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr
+++ b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr
@@ -30,35 +30,60 @@ LL |     match 0u8 {}
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty
+error[E0004]: non-exhaustive patterns: pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled
   --> $DIR/match-empty-exhaustive_patterns.rs:37:11
    |
+LL | struct NonEmptyStruct(bool);
+   | ----------------------------
+   | |      |
+   | |      variant not covered
+   | `NonEmptyStruct` defined here
+...
 LL |     match NonEmptyStruct(true) {}
    |           ^^^^^^^^^^^^^^^^^^^^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: type `NonEmptyEnum1` is non-empty
+error[E0004]: non-exhaustive patterns: pattern `Foo` of type `NonEmptyEnum1` is not handled
   --> $DIR/match-empty-exhaustive_patterns.rs:39:11
    |
-LL |     match NonEmptyEnum1::Foo(true) {}
-   |           ^^^^^^^^^^^^^^^^^^^^^^^^
+LL | / enum NonEmptyEnum1 {
+LL | |     Foo(bool),
+   | |     --- variant not covered
+LL | | }
+   | |_- `NonEmptyEnum1` defined here
+...
+LL |       match NonEmptyEnum1::Foo(true) {}
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: type `NonEmptyEnum2` is non-empty
+error[E0004]: non-exhaustive patterns: multiple patterns of type `NonEmptyEnum2` are not handled
   --> $DIR/match-empty-exhaustive_patterns.rs:41:11
    |
-LL |     match NonEmptyEnum2::Foo(true) {}
-   |           ^^^^^^^^^^^^^^^^^^^^^^^^
+LL | / enum NonEmptyEnum2 {
+LL | |     Foo(bool),
+   | |     --- variant not covered
+LL | |     Bar,
+   | |     --- variant not covered
+LL | | }
+   | |_- `NonEmptyEnum2` defined here
+...
+LL |       match NonEmptyEnum2::Foo(true) {}
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: type `NonEmptyEnum5` is non-empty
+error[E0004]: non-exhaustive patterns: multiple patterns of type `NonEmptyEnum5` are not handled
   --> $DIR/match-empty-exhaustive_patterns.rs:43:11
    |
-LL |     match NonEmptyEnum5::V1 {}
-   |           ^^^^^^^^^^^^^^^^^
+LL | / enum NonEmptyEnum5 {
+LL | |     V1, V2, V3, V4, V5,
+LL | | }
+   | |_- `NonEmptyEnum5` defined here
+...
+LL |       match NonEmptyEnum5::V1 {}
+   |             ^^^^^^^^^^^^^^^^^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms