From 77e8ddfaf342a94a7d3c3167c31199bf26b04f1f Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Wed, 15 Apr 2015 20:51:30 +1200 Subject: [PATCH] rustc: Add long diagnostics for E0170 --- src/librustc/diagnostics.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 15bad7aa5e535..222ebb09f915b 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -191,6 +191,32 @@ loop { } "##, +E0170: r##" +Enum variants are qualified by default. For example, given this type: + +enum Method { + GET, + POST +} + +you would match it using: + +match m { + Method::GET => ... + Method::POST => ... +} + +If you don't qualify the names, the code will bind new variables named "GET" and +"POST" instead. This behavior is likely not what you want, so rustc warns when +that happens. + +Qualified names are good practice, and most code works well with them. But if +you prefer them unqualified, you can import the variants into scope: + +use Method::*; +enum Method { GET, POST } +"##, + E0297: r##" Patterns used to bind names must be irrefutable. That is, they must guarantee that a name will be extracted in all cases. Instead of pattern matching the @@ -296,7 +322,6 @@ register_diagnostics! { E0137, E0138, E0139, - E0170, E0261, // use of undeclared lifetime name E0262, // illegal lifetime parameter name E0263, // lifetime name declared twice in same scope