about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_const_eval/check_match.rs9
-rw-r--r--src/test/ui/const-pattern-irrefutable.stderr6
2 files changed, 11 insertions, 4 deletions
diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs
index e6a04c9c57a..98ed8d99fda 100644
--- a/src/librustc_const_eval/check_match.rs
+++ b/src/librustc_const_eval/check_match.rs
@@ -260,7 +260,14 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
                 "refutable pattern in {}: `{}` not covered",
                 origin, pattern_string
             );
-            diag.span_label(pat.span, format!("pattern `{}` not covered", pattern_string));
+            let label_msg = match pat.node {
+                PatKind::Path(hir::QPath::Resolved(None, ref path))
+                        if path.segments.len() == 1 && path.segments[0].parameters.is_none() => {
+                    format!("interpreted as a {} pattern, not new variable", path.def.kind_name())
+                }
+                _ => format!("pattern `{}` not covered", pattern_string),
+            };
+            diag.span_label(pat.span, label_msg);
             diag.emit();
         });
     }
diff --git a/src/test/ui/const-pattern-irrefutable.stderr b/src/test/ui/const-pattern-irrefutable.stderr
index 1f23eec43ef..af48b773638 100644
--- a/src/test/ui/const-pattern-irrefutable.stderr
+++ b/src/test/ui/const-pattern-irrefutable.stderr
@@ -2,19 +2,19 @@ error[E0005]: refutable pattern in local binding: `_` not covered
   --> $DIR/const-pattern-irrefutable.rs:22:9
    |
 22 |     let a = 4; //~ ERROR refutable pattern in local binding: `_` not covered
-   |         ^ pattern `_` not covered
+   |         ^ interpreted as a constant pattern, not new variable
 
 error[E0005]: refutable pattern in local binding: `_` not covered
   --> $DIR/const-pattern-irrefutable.rs:23:9
    |
 23 |     let c = 4; //~ ERROR refutable pattern in local binding: `_` not covered
-   |         ^ pattern `_` not covered
+   |         ^ interpreted as a constant pattern, not new variable
 
 error[E0005]: refutable pattern in local binding: `_` not covered
   --> $DIR/const-pattern-irrefutable.rs:24:9
    |
 24 |     let d = 4; //~ ERROR refutable pattern in local binding: `_` not covered
-   |         ^ pattern `_` not covered
+   |         ^ interpreted as a constant pattern, not new variable
 
 error: aborting due to 3 previous errors