about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-07-23 12:28:01 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-07-23 12:28:01 +0200
commitd6b9e0bed95fb747d40c81f53f8c5015f2df97be (patch)
tree05028ed17adb6fb9b09f1fb43bc5008bf59add6c
parent8d91bbd90afeaf2e4b262cd48db7d29e9b8d1f49 (diff)
downloadrust-d6b9e0bed95fb747d40c81f53f8c5015f2df97be.tar.gz
rust-d6b9e0bed95fb747d40c81f53f8c5015f2df97be.zip
Add E0417 error explanation
-rw-r--r--src/librustc_resolve/diagnostics.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 5a941c757fc..9edddec946d 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -397,6 +397,33 @@ impl Bar {
 ```
 "##,
 
+E0417: r##"
+A static variable was referenced in a pattern. Example of erroneous code:
+
+```
+static FOO : i32 = 0;
+
+match 0 {
+    FOO => {} // error: static variables cannot be referenced in a
+              //        pattern, use a `const` instead
+    _ => {}
+}
+```
+
+Compiler needs to know the pattern value at compile's time, which is
+not possible with a `static` variable. So please verify you didn't
+misspell the variable's name or use a `const` instead. Example:
+
+```
+const FOO : i32 = 0;
+
+match 0 {
+    FOO => {} // ok!
+    _ => {}
+}
+```
+"##,
+
 E0428: r##"
 A type or module has been defined more than once. Example of erroneous
 code:
@@ -448,8 +475,6 @@ register_diagnostics! {
     E0414, // only irrefutable patterns allowed here
     E0415, // identifier is bound more than once in this parameter list
     E0416, // identifier is bound more than once in the same pattern
-    E0417, // static variables cannot be referenced in a pattern, use a
-           // `const` instead
     E0418, // is not an enum variant, struct or const
     E0419, // unresolved enum variant, struct or const
     E0420, // is not an associated const