mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-17 06:26:55 +00:00
Add failing example for E0170 explanation
This commit is contained in:
parent
bf84eb538f
commit
5076a3efc7
@ -1,3 +1,24 @@
|
||||
A pattern binding is using the same name as one of the variants 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:
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user