Skip to content

Commit 4f27620

Browse files
authored
Rollup merge of #76103 - GuillaumeGomez:cleanup-e0769, r=Dylan-DPC
Clean up E0769 r? @pickfire cc @Dylan-DPC
2 parents 5033203 + f3ae96e commit 4f27620

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 numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
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

44
Erroneous code example:
55

66
```compile_fail,E0769
77
enum E {
88
A(i32),
99
}
10+
1011
let e = E::A(42);
12+
1113
match 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);
2327
match 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);
3642
match e {
37-
E::A { 0: number } => println!("{}", number),
43+
E::A { 0: number } => { // ok!
44+
println!("{}", number);
45+
}
3846
}
3947
```

0 commit comments

Comments
 (0)