File tree 1 file changed +15
-7
lines changed
compiler/rustc_error_codes/src/error_codes
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.
3
3
4
4
Erroneous code example:
5
5
6
6
``` compile_fail,E0769
7
7
enum E {
8
8
A(i32),
9
9
}
10
+
10
11
let e = E::A(42);
12
+
11
13
match e {
12
- E::A { number } => println!("{}", x),
14
+ E::A { number } => { // error!
15
+ println!("{}", number);
16
+ }
13
17
}
14
18
```
15
19
@@ -21,19 +25,23 @@ To fix this error, you can use the tuple pattern:
21
25
# }
22
26
# let e = E::A(42);
23
27
match e {
24
- E::A(number) => println!("{}", number),
28
+ E::A(number) => { // ok!
29
+ println!("{}", number);
30
+ }
25
31
}
26
32
```
27
33
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:
30
36
31
37
```
32
38
# enum E {
33
39
# A(i32),
34
40
# }
35
41
# let e = E::A(42);
36
42
match e {
37
- E::A { 0: number } => println!("{}", number),
43
+ E::A { 0: number } => { // ok!
44
+ println!("{}", number);
45
+ }
38
46
}
39
47
```
You can’t perform that action at this time.
0 commit comments