about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorChris Wong <lambda.fairy@gmail.com>2015-04-15 20:51:30 +1200
committerSteve Klabnik <steve@steveklabnik.com>2015-04-16 22:23:36 -0400
commit77e8ddfaf342a94a7d3c3167c31199bf26b04f1f (patch)
tree9e7e8bd400c66075caec5a66a7d14017b5f0ccb1 /src
parentaaf92f04d1c9b90f05c586ed811e6b185743018d (diff)
downloadrust-77e8ddfaf342a94a7d3c3167c31199bf26b04f1f.tar.gz
rust-77e8ddfaf342a94a7d3c3167c31199bf26b04f1f.zip
rustc: Add long diagnostics for E0170
Diffstat (limited to 'src')
-rw-r--r--src/librustc/diagnostics.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 15bad7aa5e5..222ebb09f91 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