]> git.proxmox.com Git - rustc.git/blob - src/librustc_error_codes/error_codes/E0532.md
New upstream version 1.41.1+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0532.md
1 Pattern arm did not match expected kind.
2
3 Erroneous code example:
4
5 ```compile_fail,E0532
6 enum State {
7 Succeeded,
8 Failed(String),
9 }
10
11 fn print_on_failure(state: &State) {
12 match *state {
13 // error: expected unit struct, unit variant or constant, found tuple
14 // variant `State::Failed`
15 State::Failed => println!("Failed"),
16 _ => ()
17 }
18 }
19 ```
20
21 To fix this error, ensure the match arm kind is the same as the expression
22 matched.
23
24 Fixed example:
25
26 ```
27 enum State {
28 Succeeded,
29 Failed(String),
30 }
31
32 fn print_on_failure(state: &State) {
33 match *state {
34 State::Failed(ref msg) => println!("Failed with {}", msg),
35 _ => ()
36 }
37 }
38 ```