Skip to content

Commit ae999e9

Browse files
committed
Address review comments
1 parent cf46820 commit ae999e9

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/librustc/hir/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,10 @@ pub enum PatKind {
540540
/// Such pattern can be resolved to a unit struct/variant or a constant.
541541
Path(Path),
542542

543-
/// A path pattern written in qualified form, i.e. `<T as Trait>::CONST` or `<T>::CONST`.
544-
/// Such patterns can only refer to associated constants at the moment.
543+
/// An associated const named using the qualified path `<T>::CONST` or
544+
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
545+
/// referred to as simply `T::CONST`, in which case they will end up as
546+
/// PatKind::Path, and the resolver will have to sort that out.
545547
QPath(QSelf, Path),
546548

547549
/// A tuple pattern `(a, b)`.

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,11 +1043,6 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
10431043
PatKind::Struct(..) | PatKind::TupleStruct(..) |
10441044
PatKind::Path(..) | PatKind::QPath(..) => {
10451045
match def_map.get(&pat.id).map(|d| d.full_def()) {
1046-
None => {
1047-
// no definition found: pat is not a
1048-
// struct or enum pattern.
1049-
}
1050-
10511046
Some(Def::Variant(enum_did, variant_did)) => {
10521047
let downcast_cmt =
10531048
if tcx.lookup_adt_def(enum_did).is_univariant() {
@@ -1083,7 +1078,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
10831078
// `matched_pat` call.
10841079
}
10851080

1086-
Some(def) => {
1081+
def => {
10871082
// An enum type should never be in a pattern.
10881083
// Remaining cases are e.g. Def::Fn, to
10891084
// which identifiers within patterns

src/libsyntax/ast.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,10 @@ pub enum PatKind {
635635
/// Such pattern can be resolved to a unit struct/variant or a constant.
636636
Path(Path),
637637

638-
/// A path pattern written in qualified form, i.e. `<T as Trait>::CONST` or `<T>::CONST`.
639-
/// Such patterns can only refer to associated constants at the moment.
638+
/// An associated const named using the qualified path `<T>::CONST` or
639+
/// `<T as Trait>::CONST`. Associated consts from inherent impls can be
640+
/// referred to as simply `T::CONST`, in which case they will end up as
641+
/// PatKind::Path, and the resolver will have to sort that out.
640642
QPath(QSelf, Path),
641643

642644
/// A tuple pattern `(a, b)`.

0 commit comments

Comments
 (0)