Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up E0769 #76103

Merged
merged 1 commit into from
Sep 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
```