about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/check_match.rs5
-rw-r--r--src/test/compile-fail/issue-30302.rs26
2 files changed, 29 insertions, 2 deletions
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index 04f907af70b..ba4bdccb20b 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -250,14 +250,15 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
                             variant.name == ident.node.unhygienic_name
                                 && variant.kind() == VariantKind::Unit
                         ) {
+                            let ty_path = cx.tcx.item_path_str(edef.did);
                             span_warn!(cx.tcx.sess, p.span, E0170,
                                 "pattern binding `{}` is named the same as one \
                                  of the variants of the type `{}`",
-                                ident.node, pat_ty);
+                                ident.node, ty_path);
                             fileline_help!(cx.tcx.sess, p.span,
                                 "if you meant to match on a variant, \
                                  consider making the path in the pattern qualified: `{}::{}`",
-                                pat_ty, ident.node);
+                                ty_path, ident.node);
                         }
                     }
                 }
diff --git a/src/test/compile-fail/issue-30302.rs b/src/test/compile-fail/issue-30302.rs
new file mode 100644
index 00000000000..26508a47224
--- /dev/null
+++ b/src/test/compile-fail/issue-30302.rs
@@ -0,0 +1,26 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+enum Stack<T> {
+    Nil,
+    Cons(T, Box<Stack<T>>)
+}
+
+fn is_empty<T>(s: Stack<T>) -> bool {
+    match s {
+        Nil => true,
+//~^ WARN pattern binding `Nil` is named the same as one of the variants of the type `Stack`
+//~| HELP consider making the path in the pattern qualified: `Stack::Nil`
+        _ => false
+//~^ ERROR unreachable pattern
+    }
+}
+
+fn main() {}