Non-exhaustive structs may be empty · rust-lang/rust@6f6a6bc (original) (raw)
1
``
`` -
error[E0004]: non-exhaustive patterns: type UninhabitedEnum
is non-empty
``
2
``
`-
--> $DIR/match.rs:19:11
`
``
1
`` +
error[E0004]: non-exhaustive patterns: type uninhabited::UninhabitedEnum
is non-empty
``
``
2
`+
--> $DIR/match.rs:14:11
`
3
3
` |
`
4
4
`LL | match x {}
`
5
5
` | ^
`
6
6
` |
`
7
``
`` -
note: UninhabitedEnum
defined here
``
``
7
`` +
note: uninhabited::UninhabitedEnum
defined here
``
8
8
` --> $DIR/auxiliary/uninhabited.rs:5:1
`
9
9
` |
`
10
10
`LL | pub enum UninhabitedEnum {
`
11
11
` | ^^^^^^^^^^^^^^^^^^^^^^^^
`
12
``
`` -
= note: the matched value is of type UninhabitedEnum
, which is marked as non-exhaustive
``
``
12
`` +
= note: the matched value is of type uninhabited::UninhabitedEnum
, which is marked as non-exhaustive
``
13
13
`help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
`
14
14
` |
`
15
15
`LL ~ match x {
`
16
16
`LL + _ => todo!(),
`
17
17
`LL ~ }
`
18
18
` |
`
19
19
``
20
``
`` -
error[E0004]: non-exhaustive patterns: type UninhabitedStruct
is non-empty
``
21
``
`-
--> $DIR/match.rs:23:11
`
``
20
`` +
error[E0004]: non-exhaustive patterns: type uninhabited::PrivatelyUninhabitedStruct
is non-empty
``
``
21
`+
--> $DIR/match.rs:22:11
`
22
22
` |
`
23
23
`LL | match x {}
`
24
24
` | ^
`
25
25
` |
`
26
``
`` -
note: UninhabitedStruct
defined here
``
27
``
`-
--> $DIR/auxiliary/uninhabited.rs:9:1
`
``
26
`` +
note: uninhabited::PrivatelyUninhabitedStruct
defined here
``
``
27
`+
--> $DIR/auxiliary/uninhabited.rs:15:1
`
28
28
` |
`
29
``
`-
LL | pub struct UninhabitedStruct {
`
30
``
`-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`
31
``
`` -
= note: the matched value is of type UninhabitedStruct
``
``
29
`+
LL | pub struct PrivatelyUninhabitedStruct {
`
``
30
`+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`
``
31
`` +
= note: the matched value is of type uninhabited::PrivatelyUninhabitedStruct
``
32
32
`help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
`
33
33
` |
`
34
34
`LL ~ match x {
`
35
35
`LL + _ => todo!(),
`
36
36
`LL ~ }
`
37
37
` |
`
38
38
``
39
``
`` -
error[E0004]: non-exhaustive patterns: type UninhabitedTupleStruct
is non-empty
``
40
``
`-
--> $DIR/match.rs:27:11
`
41
``
`-
|
`
42
``
`-
LL | match x {}
`
43
``
`-
| ^
`
44
``
`-
|
`
45
``
`` -
note: UninhabitedTupleStruct
defined here
``
46
``
`-
--> $DIR/auxiliary/uninhabited.rs:14:1
`
47
``
`-
|
`
48
``
`-
LL | pub struct UninhabitedTupleStruct(!);
`
49
``
`-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`
50
``
`` -
= note: the matched value is of type UninhabitedTupleStruct
``
51
``
`-
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
`
52
``
`-
|
`
53
``
`-
LL ~ match x {
`
54
``
`-
LL + _ => todo!(),
`
55
``
`-
LL ~ }
`
56
``
`-
|
`
57
``
-
58
``
`` -
error[E0004]: non-exhaustive patterns: UninhabitedVariants::Tuple(_)
and UninhabitedVariants::Struct { .. }
not covered
``
59
``
`-
--> $DIR/match.rs:31:11
`
60
``
`-
|
`
61
``
`-
LL | match x {}
`
62
``
`` -
| ^ patterns UninhabitedVariants::Tuple(_)
and UninhabitedVariants::Struct { .. }
not covered
``
63
``
`-
|
`
64
``
`` -
note: UninhabitedVariants
defined here
``
65
``
`-
--> $DIR/auxiliary/uninhabited.rs:16:1
`
66
``
`-
|
`
67
``
`-
LL | pub enum UninhabitedVariants {
`
68
``
`-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`
69
``
`-
LL | #[non_exhaustive] Tuple(!),
`
70
``
`-
| ----- not covered
`
71
``
`-
LL | #[non_exhaustive] Struct { x: ! }
`
72
``
`-
| ------ not covered
`
73
``
`` -
= note: the matched value is of type UninhabitedVariants
``
74
``
`-
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
`
75
``
`-
|
`
76
``
`-
LL ~ match x {
`
77
``
`-
LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(),
`
78
``
`-
LL ~ }
`
79
``
`-
|
`
80
``
-
81
``
`-
error: aborting due to 4 previous errors
`
``
39
`+
error: aborting due to 2 previous errors
`
82
40
``
83
41
`` For more information about this error, try rustc --explain E0004
.
``