about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-05 16:12:57 +0200
committerGitHub <noreply@github.com>2016-08-05 16:12:57 +0200
commit8038c17da541ff22e7c7a0ed83e8b1fc8066ed49 (patch)
tree442ba6db1a9a0b1352b3e21f8ce42d5f5e441c61 /src
parent7a3164010a464cd67c12d8cc325f70c27a1c6bae (diff)
parent034e6594112114897b243cb2cc2944c91c28d529 (diff)
downloadrust-8038c17da541ff22e7c7a0ed83e8b1fc8066ed49.tar.gz
rust-8038c17da541ff22e7c7a0ed83e8b1fc8066ed49.zip
Rollup merge of #35297 - saml:e0001-label, r=jonathandturner
Set label for unreachable pattern

Part of #35233
Fixes #35190

r? @jonathandturner
Diffstat (limited to 'src')
-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..d148d2a0885 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 an 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..4997a6fee19 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 an unreachable pattern
     };
     match &s {
         &Var1 => (),
@@ -29,6 +30,7 @@ fn main() {
         //~^ NOTE this pattern matches any value
         &Var2 => (),
         //~^ ERROR unreachable pattern
+        //~^^ NOTE this is an 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 an 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 an unreachable pattern
     };
 }