From 5076a3efc707436c20c62f90e5df47e78052ed2d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 14 Jan 2020 14:04:03 +0100 Subject: [PATCH 1/2] Add failing example for E0170 explanation --- src/librustc_error_codes/error_codes/E0170.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/librustc_error_codes/error_codes/E0170.md b/src/librustc_error_codes/error_codes/E0170.md index 4b870dbf22155..56e1b5aa241d2 100644 --- a/src/librustc_error_codes/error_codes/E0170.md +++ b/src/librustc_error_codes/error_codes/E0170.md @@ -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: ``` From 6801cf436bf3549db72c364a912da43ac38d0e79 Mon Sep 17 00:00:00 2001 From: Dylan DPC Date: Wed, 15 Jan 2020 11:52:21 +0530 Subject: [PATCH 2/2] Update E0170.md --- src/librustc_error_codes/error_codes/E0170.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0170.md b/src/librustc_error_codes/error_codes/E0170.md index 56e1b5aa241d2..9678cd173b7ca 100644 --- a/src/librustc_error_codes/error_codes/E0170.md +++ b/src/librustc_error_codes/error_codes/E0170.md @@ -1,4 +1,4 @@ -A pattern binding is using the same name as one of the variants a type. +A pattern binding is using the same name as one of the variants of a type. Erroneous code example: