]> git.lizzy.rs Git - rust.git/blob - src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr
Suggest `if let`/`let_else` for refutable pat in `let`
[rust.git] / src / test / ui / uninhabited / uninhabited-matches-feature-gated.stderr
1 error[E0004]: non-exhaustive patterns: `Err(_)` not covered
2   --> $DIR/uninhabited-matches-feature-gated.rs:6:19
3    |
4 LL |     let _ = match x {
5    |                   ^ pattern `Err(_)` not covered
6    |
7 note: `Result<u32, &Void>` defined here
8   --> $SRC_DIR/core/src/result.rs:LL:COL
9    |
10 LL | / pub enum Result<T, E> {
11 LL | |     /// Contains the success value
12 LL | |     #[lang = "Ok"]
13 LL | |     #[stable(feature = "rust1", since = "1.0.0")]
14 ...  |
15 LL | |     Err(#[stable(feature = "rust1", since = "1.0.0")] E),
16    | |     ^^^ not covered
17 LL | | }
18    | |_-
19    = note: the matched value is of type `Result<u32, &Void>`
20 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
21    |
22 LL ~         Ok(n) => n,
23 LL ~         Err(_) => todo!(),
24    |
25
26 error[E0004]: non-exhaustive patterns: type `&Void` is non-empty
27   --> $DIR/uninhabited-matches-feature-gated.rs:15:19
28    |
29 LL |     let _ = match x {};
30    |                   ^
31    |
32 note: `Void` defined here
33   --> $DIR/uninhabited-matches-feature-gated.rs:2:6
34    |
35 LL | enum Void {}
36    |      ^^^^
37    = note: the matched value is of type `&Void`
38    = note: references are always considered inhabited
39 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
40    |
41 LL ~     let _ = match x {
42 LL +         _ => todo!(),
43 LL ~     };
44    |
45
46 error[E0004]: non-exhaustive patterns: type `(Void,)` is non-empty
47   --> $DIR/uninhabited-matches-feature-gated.rs:18:19
48    |
49 LL |     let _ = match x {};
50    |                   ^
51    |
52    = note: the matched value is of type `(Void,)`
53 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
54    |
55 LL ~     let _ = match x {
56 LL +         _ => todo!(),
57 LL ~     };
58    |
59
60 error[E0004]: non-exhaustive patterns: type `[Void; 1]` is non-empty
61   --> $DIR/uninhabited-matches-feature-gated.rs:21:19
62    |
63 LL |     let _ = match x {};
64    |                   ^
65    |
66    = note: the matched value is of type `[Void; 1]`
67 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
68    |
69 LL ~     let _ = match x {
70 LL +         _ => todo!(),
71 LL ~     };
72    |
73
74 error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
75   --> $DIR/uninhabited-matches-feature-gated.rs:24:19
76    |
77 LL |     let _ = match x {
78    |                   ^ pattern `&[_, ..]` not covered
79    |
80    = note: the matched value is of type `&[Void]`
81 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
82    |
83 LL ~         &[] => (),
84 LL ~         &[_, ..] => todo!(),
85    |
86
87 error[E0004]: non-exhaustive patterns: `Err(_)` not covered
88   --> $DIR/uninhabited-matches-feature-gated.rs:32:19
89    |
90 LL |     let _ = match x {
91    |                   ^ pattern `Err(_)` not covered
92    |
93 note: `Result<u32, Void>` defined here
94   --> $SRC_DIR/core/src/result.rs:LL:COL
95    |
96 LL | / pub enum Result<T, E> {
97 LL | |     /// Contains the success value
98 LL | |     #[lang = "Ok"]
99 LL | |     #[stable(feature = "rust1", since = "1.0.0")]
100 ...  |
101 LL | |     Err(#[stable(feature = "rust1", since = "1.0.0")] E),
102    | |     ^^^ not covered
103 LL | | }
104    | |_-
105    = note: the matched value is of type `Result<u32, Void>`
106 help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
107    |
108 LL ~         Ok(x) => x,
109 LL ~         Err(_) => todo!(),
110    |
111
112 error[E0005]: refutable pattern in local binding: `Err(_)` not covered
113   --> $DIR/uninhabited-matches-feature-gated.rs:37:9
114    |
115 LL |     let Ok(x) = x;
116    |         ^^^^^ pattern `Err(_)` not covered
117    |
118    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
119    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
120 note: `Result<u32, Void>` defined here
121   --> $SRC_DIR/core/src/result.rs:LL:COL
122    |
123 LL | / pub enum Result<T, E> {
124 LL | |     /// Contains the success value
125 LL | |     #[lang = "Ok"]
126 LL | |     #[stable(feature = "rust1", since = "1.0.0")]
127 ...  |
128 LL | |     Err(#[stable(feature = "rust1", since = "1.0.0")] E),
129    | |     ^^^ not covered
130 LL | | }
131    | |_-
132    = note: the matched value is of type `Result<u32, Void>`
133 help: you might want to use `if let` to ignore the variant that isn't matched
134    |
135 LL |     let x = if let Ok(x) = x { x } else { todo!() };
136    |     ++++++++++               ++++++++++++++++++++++
137 help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variant that isn't matched
138    |
139 LL |     let Ok(x) = x else { todo!() };
140    |                   ++++++++++++++++
141
142 error: aborting due to 7 previous errors
143
144 Some errors have detailed explanations: E0004, E0005.
145 For more information about an error, try `rustc --explain E0004`.