about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsaml <skynare@gmail.com>2016-08-04 10:42:01 -0400
committersaml <skynare@gmail.com>2016-08-04 10:42:01 -0400
commiteeda69fcca2c554bd60072476292b37fccb01a61 (patch)
treedcecf18b49d73b15d3c0d6ecd3032e6df1de26d6
parente804a3cf256106c097d44f6e0212cd183122da07 (diff)
downloadrust-eeda69fcca2c554bd60072476292b37fccb01a61.tar.gz
rust-eeda69fcca2c554bd60072476292b37fccb01a61.zip
Set label for unreachable pattern
Part of #35233
Fixes #35190

r? @jonathandturner
-rw-r--r--src/librustc_const_eval/check_match.rs1
-rw-r--r--src/test/compile-fail/issue-31221.rs4
2 files changed, 5 insertions, 0 deletions
diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs
index d3952de2fbe..6528525a610 100644
--- a/src/librustc_const_eval/check_match.rs
+++ b/src/librustc_const_eval/check_match.rs
@@ -335,6 +335,7 @@ fn check_arms(cx: &MatchCheckCtxt,
                         hir::MatchSource::Normal => {
                             let mut err = struct_span_err!(cx.tcx.sess, pat.span, E0001,
                                                            "unreachable pattern");
+                            err.span_label(pat.span, &format!("this is unreachable pattern"));
                             // if we had a catchall pattern, hint at that
                             for row in &seen.0 {
                                 if pat_is_catchall(&cx.tcx.def_map.borrow(), row[0].0) {
diff --git a/src/test/compile-fail/issue-31221.rs b/src/test/compile-fail/issue-31221.rs
index 2b3df9ad1d8..85eac907105 100644
--- a/src/test/compile-fail/issue-31221.rs
+++ b/src/test/compile-fail/issue-31221.rs
@@ -22,6 +22,7 @@ fn main() {
         //~^ NOTE this pattern matches any value
         Var2 => (),
         //~^ ERROR unreachable pattern
+        //~^^ NOTE this is unreachable pattern
     };
     match &s {
         &Var1 => (),
@@ -29,6 +30,7 @@ fn main() {
         //~^ NOTE this pattern matches any value
         &Var2 => (),
         //~^ ERROR unreachable pattern
+        //~^^ NOTE this is unreachable pattern
     };
     let t = (Var1, Var1);
     match t {
@@ -37,6 +39,7 @@ fn main() {
         //~^ NOTE this pattern matches any value
         anything => ()
         //~^ ERROR unreachable pattern
+        //~^^ NOTE this is unreachable pattern
     };
     // `_` need not emit a note, it is pretty obvious already.
     let t = (Var1, Var1);
@@ -45,5 +48,6 @@ fn main() {
         _ => (),
         anything => ()
         //~^ ERROR unreachable pattern
+        //~^^ NOTE this is unreachable pattern
     };
 }