diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index bf3d003f51cb5..c36c88c7990d3 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. `::CONST` or `::CONST`. - /// Such patterns can only refer to associated constants at the moment. + /// An associated const named using the qualified path `::CONST` or + /// `::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 cf07493fa7b60..48b5420dd6be7 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 be8d296dab09b..488d8ed2e5e35 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. `::CONST` or `::CONST`. - /// Such patterns can only refer to associated constants at the moment. + /// An associated const named using the qualified path `::CONST` or + /// `::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)`.