about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Sproul <micsproul@gmail.com>2015-01-17 17:20:24 -0800
committerBrian Anderson <banderson@mozilla.com>2015-01-20 11:27:51 -0800
commit9a4401fe828f2f29c359bc3c83f6f3b7eed27d83 (patch)
tree51e15a8b3a157c986bf21c5e86c20f45f635b952
parent9f59f7e0525ad44a11fb0614ef1626274ddaa918 (diff)
downloadrust-9a4401fe828f2f29c359bc3c83f6f3b7eed27d83.tar.gz
rust-9a4401fe828f2f29c359bc3c83f6f3b7eed27d83.zip
Add some extended errors.
-rw-r--r--src/librustc/diagnostics.rs40
-rw-r--r--src/libsyntax/diagnostics/macros.rs6
2 files changed, 40 insertions, 6 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 1dbd6eb4e8d..b48df36a679 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -10,21 +10,49 @@
 
 #![allow(non_snake_case)]
 
-register_diagnostic! { E0001, r##"
+register_long_diagnostics! {
+    E0001: r##"
     This error suggests that the expression arm corresponding to the noted pattern
     will never be reached as for all possible values of the expression being matched,
     one of the preceeding patterns will match.
 
     This means that perhaps some of the preceeding patterns are too general, this
     one is too specific or the ordering is incorrect.
-"## }
+"##,
+
+    E0003: r##"
+    Not-a-Number (NaN) values can not be compared for equality and hence can never match
+    the input to a match expression. To match against NaN values, you should instead use
+    the `is_nan` method in a guard, as in: x if x.is_nan() => ...
+"##,
+
+    E0004: r##"
+    This error indicates that the compiler can not guarantee a matching pattern for one
+    or more possible inputs to a match expression. Guaranteed matches are required in order
+    to assign values to match expressions, or alternatively, determine the flow of execution.
+
+    If you encounter this error you must alter your patterns so that every possible value of
+    the input type is matched. For types with a small number of variants (like enums) you
+    should probably cover all cases explicitly. Alternatively, the underscore `_` wildcard
+    pattern can be added after all other patterns to match "anything else".
+"##,
+
+    // FIXME: Remove duplication here?
+    E0005: r##"
+    Patterns used to bind names must be irrefutable, that is, they must guarantee that a
+    name will be extracted in all cases. If you encounter this error you probably need
+    to use a `match` or `if let` to deal with the possibility of failure.
+"##,
+
+    E0006: r##"
+    Patterns used to bind names must be irrefutable, that is, they must guarantee that a
+    name will be extracted in all cases. If you encounter this error you probably need
+    to use a `match` or `if let` to deal with the possibility of failure.
+"##
+}
 
 register_diagnostics! {
     E0002,
-    E0003,
-    E0004,
-    E0005,
-    E0006,
     E0007,
     E0008,
     E0009,
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index 5bd683c86ae..9321d3ca3df 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -59,3 +59,9 @@ macro_rules! register_diagnostics {
     )
 }
 
+#[macro_export]
+macro_rules! register_long_diagnostics {
+    ($($code:tt: $description:tt),*) => (
+        $(register_diagnostic! { $code, $description })*
+    )
+}