]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/check_match.rs
Add part of new error codes in librustc
[rust.git] / src / librustc / middle / check_match.rs
index d0111860b44066f3893a2415133edf69a7fd7263..bf2d2fee20e5b5ee7f1c2fc5a776ccdaacabf321 100644 (file)
@@ -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;
@@ -279,9 +282,9 @@ fn check_for_static_nan(cx: &MatchCheckCtxt, pat: &Pat) {
 
                 Err(err) => {
                     let subspan = p.span.lo <= err.span.lo && err.span.hi <= p.span.hi;
-                    cx.tcx.sess.span_err(err.span,
-                                         &format!("constant evaluation error: {}",
-                                                  err.description()));
+                    span_err!(cx.tcx.sess, err.span, E0471,
+                              "constant evaluation error: {}",
+                              err.description());
                     if !subspan {
                         cx.tcx.sess.span_note(p.span,
                                               "in pattern here")
@@ -664,7 +667,7 @@ fn is_useful(cx: &MatchCheckCtxt,
 
         match real_pat.node {
             hir::PatIdent(hir::BindByRef(..), _, _) => {
-                left_ty.builtin_deref(false).unwrap().ty
+                left_ty.builtin_deref(false, NoPreference).unwrap().ty
             }
             _ => left_ty,
         }