Skip to content

Commit 20c49fc

Browse files
authored
Rollup merge of rust-lang#68211 - GuillaumeGomez:add-failing-example-e0170, r=Dylan-DPC
Add failing example for E0170 explanation r? @Dylan-DPC
2 parents be1ecce + 6801cf4 commit 20c49fc

File tree

1 file changed

+21
-0
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+21
-0
lines changed

src/librustc_error_codes/error_codes/E0170.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
A pattern binding is using the same name as one of the variants of a type.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0170
6+
# #![deny(warnings)]
7+
enum Method {
8+
GET,
9+
POST,
10+
}
11+
12+
fn is_empty(s: Method) -> bool {
13+
match s {
14+
GET => true,
15+
_ => false
16+
}
17+
}
18+
19+
fn main() {}
20+
```
21+
122
Enum variants are qualified by default. For example, given this type:
223

324
```

0 commit comments

Comments
 (0)