Skip to content

Commit

Permalink
Clean up E0769 explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 31, 2020
1 parent 6c44bcc commit f3ae96e
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 f3ae96e

Please sign in to comment.