mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Add tests
This commit is contained in:
parent
5628d4a7c3
commit
2099dd1aa2
@ -4,6 +4,13 @@
|
||||
enum Foo {}
|
||||
|
||||
struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here
|
||||
union NonEmptyUnion1 {
|
||||
foo: (),
|
||||
}
|
||||
union NonEmptyUnion2 {
|
||||
foo: (),
|
||||
bar: (),
|
||||
}
|
||||
enum NonEmptyEnum1 { //~ `NonEmptyEnum1` defined here
|
||||
Foo(bool), //~ variant not covered
|
||||
}
|
||||
@ -36,6 +43,10 @@ fn main() {
|
||||
//~^ ERROR type `u8` is non-empty
|
||||
match NonEmptyStruct(true) {}
|
||||
//~^ ERROR pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled
|
||||
match (NonEmptyUnion1 { foo: () }) {}
|
||||
//~^ ERROR pattern `NonEmptyUnion1` of type `NonEmptyUnion1` is not handled
|
||||
match (NonEmptyUnion2 { foo: () }) {}
|
||||
//~^ ERROR pattern `NonEmptyUnion2` of type `NonEmptyUnion2` is not handled
|
||||
match NonEmptyEnum1::Foo(true) {}
|
||||
//~^ ERROR pattern `Foo` of type `NonEmptyEnum1` is not handled
|
||||
match NonEmptyEnum2::Foo(true) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:21:9
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:28:9
|
||||
|
|
||||
LL | _ => {},
|
||||
| ^
|
||||
@ -11,19 +11,19 @@ LL | #![deny(unreachable_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:28:9
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:35:9
|
||||
|
|
||||
LL | Some(_) => {}
|
||||
| ^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:32:9
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:39:9
|
||||
|
|
||||
LL | Some(_) => {}
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:35:11
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:42:11
|
||||
|
|
||||
LL | match 0u8 {}
|
||||
| ^^^
|
||||
@ -31,7 +31,7 @@ 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
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:37:11
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:44:11
|
||||
|
|
||||
LL | struct NonEmptyStruct(bool);
|
||||
| ----------------------------
|
||||
@ -44,8 +44,41 @@ 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
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:46:11
|
||||
|
|
||||
LL | union NonEmptyUnion1 {
|
||||
| - -------------- variant not covered
|
||||
| _|
|
||||
| |
|
||||
LL | | foo: (),
|
||||
LL | | }
|
||||
| |_- `NonEmptyUnion1` defined here
|
||||
...
|
||||
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
|
||||
--> $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: () }) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= 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 `NonEmptyEnum1` is not handled
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:39:11
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:50:11
|
||||
|
|
||||
LL | / enum NonEmptyEnum1 {
|
||||
LL | | Foo(bool),
|
||||
@ -59,7 +92,7 @@ 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: multiple patterns of type `NonEmptyEnum2` are not handled
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:41:11
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:52:11
|
||||
|
|
||||
LL | / enum NonEmptyEnum2 {
|
||||
LL | | Foo(bool),
|
||||
@ -75,7 +108,7 @@ 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: multiple patterns of type `NonEmptyEnum5` are not handled
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:43:11
|
||||
--> $DIR/match-empty-exhaustive_patterns.rs:54:11
|
||||
|
|
||||
LL | / enum NonEmptyEnum5 {
|
||||
LL | | V1, V2, V3, V4, V5,
|
||||
@ -87,6 +120,6 @@ LL | match NonEmptyEnum5::V1 {}
|
||||
|
|
||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
|
@ -3,6 +3,13 @@
|
||||
enum Foo {}
|
||||
|
||||
struct NonEmptyStruct(bool); //~ `NonEmptyStruct` defined here
|
||||
union NonEmptyUnion1 {
|
||||
foo: (),
|
||||
}
|
||||
union NonEmptyUnion2 {
|
||||
foo: (),
|
||||
bar: (),
|
||||
}
|
||||
enum NonEmptyEnum1 { //~ `NonEmptyEnum1` defined here
|
||||
Foo(bool), //~ variant not covered
|
||||
}
|
||||
@ -20,7 +27,7 @@ fn foo1(x: Foo) {
|
||||
|
||||
fn foo2(x: Foo) {
|
||||
match x {
|
||||
_ => {}, // FIXME: should be unreachable
|
||||
_ => {}, // Not detected as unreachable, see #55123.
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +46,10 @@ fn main() {
|
||||
//~^ ERROR type `u8` is non-empty
|
||||
match NonEmptyStruct(true) {}
|
||||
//~^ ERROR pattern `NonEmptyStruct` of type `NonEmptyStruct` is not handled
|
||||
match (NonEmptyUnion1 { foo: () }) {}
|
||||
//~^ ERROR pattern `NonEmptyUnion1` of type `NonEmptyUnion1` is not handled
|
||||
match (NonEmptyUnion2 { foo: () }) {}
|
||||
//~^ ERROR pattern `NonEmptyUnion2` of type `NonEmptyUnion2` is not handled
|
||||
match NonEmptyEnum1::Foo(true) {}
|
||||
//~^ ERROR pattern `Foo` of type `NonEmptyEnum1` is not handled
|
||||
match NonEmptyEnum2::Foo(true) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
|
||||
--> $DIR/match-empty.rs:38:11
|
||||
--> $DIR/match-empty.rs:45:11
|
||||
|
|
||||
LL | match 0u8 {}
|
||||
| ^^^
|
||||
@ -7,7 +7,7 @@ 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
|
||||
--> $DIR/match-empty.rs:40:11
|
||||
--> $DIR/match-empty.rs:47:11
|
||||
|
|
||||
LL | struct NonEmptyStruct(bool);
|
||||
| ----------------------------
|
||||
@ -20,8 +20,41 @@ 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
|
||||
--> $DIR/match-empty.rs:49:11
|
||||
|
|
||||
LL | union NonEmptyUnion1 {
|
||||
| - -------------- variant not covered
|
||||
| _|
|
||||
| |
|
||||
LL | | foo: (),
|
||||
LL | | }
|
||||
| |_- `NonEmptyUnion1` defined here
|
||||
...
|
||||
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
|
||||
--> $DIR/match-empty.rs:51:11
|
||||
|
|
||||
LL | union NonEmptyUnion2 {
|
||||
| - -------------- variant not covered
|
||||
| _|
|
||||
| |
|
||||
LL | | foo: (),
|
||||
LL | | bar: (),
|
||||
LL | | }
|
||||
| |_- `NonEmptyUnion2` defined here
|
||||
...
|
||||
LL | match (NonEmptyUnion2 { foo: () }) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= 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 `NonEmptyEnum1` is not handled
|
||||
--> $DIR/match-empty.rs:42:11
|
||||
--> $DIR/match-empty.rs:53:11
|
||||
|
|
||||
LL | / enum NonEmptyEnum1 {
|
||||
LL | | Foo(bool),
|
||||
@ -35,7 +68,7 @@ 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: multiple patterns of type `NonEmptyEnum2` are not handled
|
||||
--> $DIR/match-empty.rs:44:11
|
||||
--> $DIR/match-empty.rs:55:11
|
||||
|
|
||||
LL | / enum NonEmptyEnum2 {
|
||||
LL | | Foo(bool),
|
||||
@ -51,7 +84,7 @@ 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: multiple patterns of type `NonEmptyEnum5` are not handled
|
||||
--> $DIR/match-empty.rs:46:11
|
||||
--> $DIR/match-empty.rs:57:11
|
||||
|
|
||||
LL | / enum NonEmptyEnum5 {
|
||||
LL | | V1, V2, V3, V4, V5,
|
||||
@ -63,6 +96,6 @@ LL | match NonEmptyEnum5::V1 {}
|
||||
|
|
||||
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
|
Loading…
Reference in New Issue
Block a user