]> git.lizzy.rs Git - rust.git/commitdiff
Un-remove E0001, put a notice on it instead
authorAndrew Cann <shum@canndrew.org>
Thu, 5 Jan 2017 15:48:02 +0000 (23:48 +0800)
committerAndrew Cann <shum@canndrew.org>
Thu, 5 Jan 2017 15:48:02 +0000 (23:48 +0800)
src/librustc_const_eval/diagnostics.rs
src/test/compile-fail/feature-gate-rustc-diagnostic-macros.rs

index c809eef917fe528757c4f4a07f7b026ebe6d0e67..ff0976afc0ce744d06e8cf9ac8caea0d36bde420 100644 (file)
 // In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use `:set tw=0` to disable.
 register_long_diagnostics! {
 
+E0001: r##"
+## Note: this error code is no longer emitted by the compiler.
+
+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 preceding patterns will match.
+
+This means that perhaps some of the preceding patterns are too general, this
+one is too specific or the ordering is incorrect.
+
+For example, the following `match` block has too many arms:
+
+```compile_fail,E0001
+match Some(0) {
+    Some(bar) => {/* ... */}
+    x => {/* ... */} // This handles the `None` case
+    _ => {/* ... */} // All possible cases have already been handled
+}
+```
+
+`match` blocks have their patterns matched in order, so, for example, putting
+a wildcard arm above a more specific arm will make the latter arm irrelevant.
+
+Ensure the ordering of the match arm is correct and remove any superfluous
+arms.
+"##,
+
 E0002: r##"
 ## Note: this error code is no longer emitted by the compiler.
 
index 04e95584407aa943ec067817f587a18eb67115df..8286d833e8d22cd2000af6243629feee8c87df95 100644 (file)
 // Test that diagnostic macros are gated by `rustc_diagnostic_macros` feature
 // gate
 
-__register_diagnostic!(E0002);
+__register_diagnostic!(E0001);
 //~^ ERROR macro undefined: '__register_diagnostic!'
 
 fn main() {
-    __diagnostic_used!(E0002);
+    __diagnostic_used!(E0001);
     //~^ ERROR macro undefined: '__diagnostic_used!'
 }