about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-09-04 18:09:16 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-09-04 18:09:16 +0200
commitec4ba272b00c7a7cae537a73d52f692a1a943e1b (patch)
tree4929cefea07f6f81a1d96b671af6d7773ef7c309
parent94ddfc77072d99b16a5cc779d2b1f8d69e0d6850 (diff)
downloadrust-ec4ba272b00c7a7cae537a73d52f692a1a943e1b.tar.gz
rust-ec4ba272b00c7a7cae537a73d52f692a1a943e1b.zip
Add span_help for E0002
-rw-r--r--src/librustc/diagnostics.rs2
-rw-r--r--src/librustc/middle/check_match.rs3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 696b38219f4..61cc63fa317 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -44,7 +44,7 @@ E0002: r##"
 This error indicates that an empty match expression is invalid because the type
 it is matching on is non-empty (there exist values of this type). In safe code
 it is impossible to create an instance of an empty type, so empty match
-expressions are almost never desired.  This error is typically fixed by adding
+expressions are almost never desired. This error is typically fixed by adding
 one or more cases to the match expression.
 
 An example of an empty type is `enum Empty { }`. So, the following will work:
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index d0111860b44..767eab69733 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -218,6 +218,9 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
                     span_err!(cx.tcx.sess, ex.span, E0002,
                               "non-exhaustive patterns: type {} is non-empty",
                               pat_ty);
+                    span_help!(cx.tcx.sess, ex.span,
+                        "Please ensure that all possible cases are being handled; \
+                         possibly adding wildcards or more match arms.");
                 }
                 // If the type *is* empty, it's vacuously exhaustive
                 return;