From ae999e9c8f063eb62c867eafdd86729acd798044 Mon Sep 17 00:00:00 2001
From: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
Date: Sun, 6 Mar 2016 15:54:44 +0300
Subject: [PATCH] Address review comments

---
 src/librustc/hir/mod.rs                 | 6 ++++--
 src/librustc/middle/expr_use_visitor.rs | 7 +------
 src/libsyntax/ast.rs                    | 6 ++++--
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index bf3d003f51c..c36c88c7990 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -540,8 +540,10 @@ pub enum PatKind {
     /// Such pattern can be resolved to a unit struct/variant or a constant.
     Path(Path),
 
-    /// A path pattern written in qualified form, i.e. `<T as Trait>::CONST` or `<T>::CONST`.
-    /// Such patterns can only refer to associated constants at the moment.
+    /// An associated const named using the qualified path `<T>::CONST` or
+    /// `<T as Trait>::CONST`. Associated consts from inherent impls can be
+    /// referred to as simply `T::CONST`, in which case they will end up as
+    /// PatKind::Path, and the resolver will have to sort that out.
     QPath(QSelf, Path),
 
     /// A tuple pattern `(a, b)`.
diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs
index cf07493fa7b..48b5420dd6b 100644
--- a/src/librustc/middle/expr_use_visitor.rs
+++ b/src/librustc/middle/expr_use_visitor.rs
@@ -1043,11 +1043,6 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
                 PatKind::Struct(..) | PatKind::TupleStruct(..) |
                 PatKind::Path(..) | PatKind::QPath(..) => {
                     match def_map.get(&pat.id).map(|d| d.full_def()) {
-                        None => {
-                            // no definition found: pat is not a
-                            // struct or enum pattern.
-                        }
-
                         Some(Def::Variant(enum_did, variant_did)) => {
                             let downcast_cmt =
                                 if tcx.lookup_adt_def(enum_did).is_univariant() {
@@ -1083,7 +1078,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
                             // `matched_pat` call.
                         }
 
-                        Some(def) => {
+                        def => {
                             // An enum type should never be in a pattern.
                             // Remaining cases are e.g. Def::Fn, to
                             // which identifiers within patterns
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index be8d296dab0..488d8ed2e5e 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -635,8 +635,10 @@ pub enum PatKind {
     /// Such pattern can be resolved to a unit struct/variant or a constant.
     Path(Path),
 
-    /// A path pattern written in qualified form, i.e. `<T as Trait>::CONST` or `<T>::CONST`.
-    /// Such patterns can only refer to associated constants at the moment.
+    /// An associated const named using the qualified path `<T>::CONST` or
+    /// `<T as Trait>::CONST`. Associated consts from inherent impls can be
+    /// referred to as simply `T::CONST`, in which case they will end up as
+    /// PatKind::Path, and the resolver will have to sort that out.
     QPath(QSelf, Path),
 
     /// A tuple pattern `(a, b)`.