Skip to content

Commit

Permalink
Rollup merge of #76103 - GuillaumeGomez:cleanup-e0769, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Clean up E0769

r? @pickfire

cc @Dylan-DPC
  • Loading branch information
tmandry authored Sep 1, 2020
2 parents 5033203 + f3ae96e commit 4f27620
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions compiler/rustc_error_codes/src/error_codes/E0769.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
A tuple struct or tuple variant was used in a pattern as if it were a
struct or struct variant.
A tuple struct or tuple variant was used in a pattern as if it were a struct or
struct variant.

Erroneous code example:

```compile_fail,E0769
enum E {
A(i32),
}
let e = E::A(42);
match e {
E::A { number } => println!("{}", x),
E::A { number } => { // error!
println!("{}", number);
}
}
```

Expand All @@ -21,19 +25,23 @@ To fix this error, you can use the tuple pattern:
# }
# let e = E::A(42);
match e {
E::A(number) => println!("{}", number),
E::A(number) => { // ok!
println!("{}", number);
}
}
```

Alternatively, you can also use the struct pattern by using the correct
field names and binding them to new identifiers:
Alternatively, you can also use the struct pattern by using the correct field
names and binding them to new identifiers:

```
# enum E {
# A(i32),
# }
# let e = E::A(42);
match e {
E::A { 0: number } => println!("{}", number),
E::A { 0: number } => { // ok!
println!("{}", number);
}
}
```

0 comments on commit 4f27620

Please sign in to comment.