]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #68211 - GuillaumeGomez:add-failing-example-e0170, r=Dylan-DPC
authorYuki Okushi <huyuumi.dev@gmail.com>
Wed, 15 Jan 2020 12:51:48 +0000 (21:51 +0900)
committerGitHub <noreply@github.com>
Wed, 15 Jan 2020 12:51:48 +0000 (21:51 +0900)
Add failing example for E0170 explanation

r? @Dylan-DPC

src/librustc_error_codes/error_codes/E0170.md

index 4b870dbf22155cc38fc676c8bbd4a7c6d2a63d1a..9678cd173b7cac28f51164f0317689a46cccc356 100644 (file)
@@ -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:
 
 ```