diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2019-12-03 14:08:14 +0000 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2019-12-04 16:43:21 +0000 |
| commit | c0f3c06c6da71dc1dc84bc7240d1b26c3ee7facb (patch) | |
| tree | 2f412493aae3a4da9643e3e77d2c0cf1666eabcf /src/test/ui/pattern/usefulness | |
| parent | 2099dd1aa27683240420eeb1ed5ee468a0d36007 (diff) | |
| download | rust-c0f3c06c6da71dc1dc84bc7240d1b26c3ee7facb.tar.gz rust-c0f3c06c6da71dc1dc84bc7240d1b26c3ee7facb.zip | |
Only warn about missing patterns in the case of an enum
Diffstat (limited to 'src/test/ui/pattern/usefulness')
6 files changed, 26 insertions, 80 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 b568057ed1e..11eae2af9c9 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: pattern `Foo` of type `Foo` is not handled + //~^ ERROR non-exhaustive patterns: type `Foo` is non-empty } } 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 acf926e9a83..792ab6f59a4 100644 --- a/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr +++ b/src/test/ui/pattern/usefulness/always-inhabited-union-ref.stderr @@ -6,19 +6,11 @@ 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: pattern `Foo` of type `Foo` is not handled +error[E0004]: non-exhaustive patterns: type `Foo` is non-empty --> $DIR/always-inhabited-union-ref.rs:27:11 | -LL | pub union Foo { - | - --- variant not covered - | _| - | | -LL | | foo: !, -LL | | } - | |_- `Foo` defined here -... -LL | match uninhab_union() { - | ^^^^^^^^^^^^^^^ +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 61072735e18..b55673a1322 100644 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs +++ b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.rs @@ -3,7 +3,7 @@ #![deny(unreachable_patterns)] enum Foo {} -struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here +struct NonEmptyStruct(bool); union NonEmptyUnion1 { foo: (), } @@ -42,11 +42,11 @@ fn main() { match 0u8 {} //~^ ERROR type `u8` is non-empty match NonEmptyStruct(true) {} - //~^ ERROR pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled + //~^ ERROR type `NonEmptyStruct` is non-empty match (NonEmptyUnion1 { foo: () }) {} - //~^ ERROR pattern `NonEmptyUnion1` of type `NonEmptyUnion1` is not handled + //~^ ERROR type `NonEmptyUnion1` is non-empty match (NonEmptyUnion2 { foo: () }) {} - //~^ ERROR pattern `NonEmptyUnion2` of type `NonEmptyUnion2` is not handled + //~^ ERROR type `NonEmptyUnion2` is non-empty match NonEmptyEnum1::Foo(true) {} //~^ ERROR pattern `Foo` of type `NonEmptyEnum1` is not handled match NonEmptyEnum2::Foo(true) {} 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 82be26cfd87..7b8bb4158e7 100644 --- a/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr +++ b/src/test/ui/pattern/usefulness/match-empty-exhaustive_patterns.stderr @@ -30,50 +30,27 @@ 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: pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled +error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty --> $DIR/match-empty-exhaustive_patterns.rs:44: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: pattern `NonEmptyUnion1` of type `NonEmptyUnion1` is not handled +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty --> $DIR/match-empty-exhaustive_patterns.rs:46:11 | -LL | union NonEmptyUnion1 { - | - -------------- variant not covered - | _| - | | -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match (NonEmptyUnion1 { foo: () }) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match (NonEmptyUnion1 { foo: () }) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms -error[E0004]: non-exhaustive patterns: pattern `NonEmptyUnion2` of type `NonEmptyUnion2` is not handled +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty --> $DIR/match-empty-exhaustive_patterns.rs:48:11 | -LL | union NonEmptyUnion2 { - | - -------------- variant not covered - | _| - | | -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match (NonEmptyUnion2 { foo: () }) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match (NonEmptyUnion2 { foo: () }) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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.rs b/src/test/ui/pattern/usefulness/match-empty.rs index ebbc1358cdb..3adbcb8cbbb 100644 --- a/src/test/ui/pattern/usefulness/match-empty.rs +++ b/src/test/ui/pattern/usefulness/match-empty.rs @@ -2,7 +2,7 @@ #![deny(unreachable_patterns)] enum Foo {} -struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here +struct NonEmptyStruct(bool); union NonEmptyUnion1 { foo: (), } @@ -45,11 +45,11 @@ fn main() { match 0u8 {} //~^ ERROR type `u8` is non-empty match NonEmptyStruct(true) {} - //~^ ERROR pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled + //~^ ERROR type `NonEmptyStruct` is non-empty match (NonEmptyUnion1 { foo: () }) {} - //~^ ERROR pattern `NonEmptyUnion1` of type `NonEmptyUnion1` is not handled + //~^ ERROR type `NonEmptyUnion1` is non-empty match (NonEmptyUnion2 { foo: () }) {} - //~^ ERROR pattern `NonEmptyUnion2` of type `NonEmptyUnion2` is not handled + //~^ ERROR type `NonEmptyUnion2` is non-empty match NonEmptyEnum1::Foo(true) {} //~^ ERROR pattern `Foo` of type `NonEmptyEnum1` is not handled match NonEmptyEnum2::Foo(true) {} diff --git a/src/test/ui/pattern/usefulness/match-empty.stderr b/src/test/ui/pattern/usefulness/match-empty.stderr index 4ba1c79b4b2..7446a8e4aee 100644 --- a/src/test/ui/pattern/usefulness/match-empty.stderr +++ b/src/test/ui/pattern/usefulness/match-empty.stderr @@ -6,50 +6,27 @@ 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: pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled +error[E0004]: non-exhaustive patterns: type `NonEmptyStruct` is non-empty --> $DIR/match-empty.rs:47: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: pattern `NonEmptyUnion1` of type `NonEmptyUnion1` is not handled +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty --> $DIR/match-empty.rs:49:11 | -LL | union NonEmptyUnion1 { - | - -------------- variant not covered - | _| - | | -LL | | foo: (), -LL | | } - | |_- `NonEmptyUnion1` defined here -... -LL | match (NonEmptyUnion1 { foo: () }) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match (NonEmptyUnion1 { foo: () }) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms -error[E0004]: non-exhaustive patterns: pattern `NonEmptyUnion2` of type `NonEmptyUnion2` is not handled +error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty --> $DIR/match-empty.rs:51:11 | -LL | union NonEmptyUnion2 { - | - -------------- variant not covered - | _| - | | -LL | | foo: (), -LL | | bar: (), -LL | | } - | |_- `NonEmptyUnion2` defined here -... -LL | match (NonEmptyUnion2 { foo: () }) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | match (NonEmptyUnion2 { foo: () }) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms |
