File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 1- A tuple struct or tuple variant was used in a pattern as if it were a
2- struct or struct variant.
1+ A tuple struct or tuple variant was used in a pattern as if it were a struct or
2+ struct variant.
33
44Erroneous code example:
55
66``` compile_fail,E0769
77enum E {
88 A(i32),
99}
10+
1011let e = E::A(42);
12+
1113match e {
12- E::A { number } => println!("{}", x),
14+ E::A { number } => { // error!
15+ println!("{}", number);
16+ }
1317}
1418```
1519
@@ -21,19 +25,23 @@ To fix this error, you can use the tuple pattern:
2125# }
2226# let e = E::A(42);
2327match e {
24- E::A(number) => println!("{}", number),
28+ E::A(number) => { // ok!
29+ println!("{}", number);
30+ }
2531}
2632```
2733
28- Alternatively, you can also use the struct pattern by using the correct
29- field names and binding them to new identifiers:
34+ Alternatively, you can also use the struct pattern by using the correct field
35+ names and binding them to new identifiers:
3036
3137```
3238# enum E {
3339# A(i32),
3440# }
3541# let e = E::A(42);
3642match e {
37- E::A { 0: number } => println!("{}", number),
43+ E::A { 0: number } => { // ok!
44+ println!("{}", number);
45+ }
3846}
3947```
You can’t perform that action at this time.
0 commit comments