mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Rollup merge of #68211 - GuillaumeGomez:add-failing-example-e0170, r=Dylan-DPC
Add failing example for E0170 explanation r? @Dylan-DPC
This commit is contained in:
@@ -1,3 +1,24 @@
|
||||
A pattern binding is using the same name as one of the variants of a type.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0170
|
||||
# #![deny(warnings)]
|
||||
enum Method {
|
||||
GET,
|
||||
POST,
|
||||
}
|
||||
|
||||
fn is_empty(s: Method) -> bool {
|
||||
match s {
|
||||
GET => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
|
||||
Enum variants are qualified by default. For example, given this type:
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user