about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Wong <lambda.fairy@gmail.com>2015-04-15 11:54:21 +1200
committerSteve Klabnik <steve@steveklabnik.com>2015-04-16 22:23:36 -0400
commitc08facfcfd010807d27d4b315c42537d981c3b5e (patch)
tree87c2dee678e795c2a682080f158fc6c7709e0b73
parent521ae488db40b6b136bc38b468fcdaf48033c8a4 (diff)
downloadrust-c08facfcfd010807d27d4b315c42537d981c3b5e.tar.gz
rust-c08facfcfd010807d27d4b315c42537d981c3b5e.zip
rustc: Add long diagnostics for E0158
-rw-r--r--src/librustc/diagnostics.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 19006578767..a13cb27f48c 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -126,6 +126,24 @@ attributes:
 See also https://doc.rust-lang.org/book/no-stdlib.html
 "##,
 
+E0158: r##"
+`const` and `static` mean different things. A `const` is a compile-time
+constant, an alias for a literal value. This property means you can match it
+directly within a pattern.
+
+The `static` keyword, on the other hand, guarantees a fixed location in memory.
+This does not always mean that the value is constant. For example, a global
+mutex can be declared `static` as well.
+
+If you want to match against a `static`, consider using a guard instead:
+
+static FORTY_TWO: i32 = 42;
+match Some(42) {
+    Some(x) if x == FORTY_TWO => ...
+    ...
+}
+"##,
+
 E0162: r##"
 An if-let pattern attempts to match the pattern, and enters the body if the
 match was succesful. If the match is irrefutable (when it cannot fail to match),
@@ -270,7 +288,6 @@ register_diagnostics! {
     E0137,
     E0138,
     E0139,
-    E0158,
     E0161,
     E0170,
     E0261, // use of undeclared lifetime name