Skip to content

Commit d848018

Browse files
committed
Eliminate PatKind::Path
1 parent 37cf874 commit d848018

File tree

27 files changed

+116
-102
lines changed

27 files changed

+116
-102
lines changed

Diff for: compiler/rustc_ast_lowering/src/expr.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
13841384
None,
13851385
);
13861386
// Destructure like a unit struct.
1387-
let unit_struct_pat = hir::PatKind::Path(qpath);
1387+
let unit_struct_pat = hir::PatKind::Lit(self.arena.alloc(hir::PatLit {
1388+
hir_id: self.lower_node_id(lhs.id),
1389+
span: lhs.span,
1390+
kind: hir::PatLitKind::Path(qpath),
1391+
}));
13881392
return self.pat_without_dbm(lhs.span, unit_struct_pat);
13891393
}
13901394
}

Diff for: compiler/rustc_ast_lowering/src/pat.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
7070
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
7171
None,
7272
);
73-
break hir::PatKind::Path(qpath);
73+
let kind = hir::PatLitKind::Path(qpath);
74+
let lit = hir::PatLit { hir_id: pat_hir_id, span: pattern.span, kind };
75+
let lit = self.arena.alloc(lit);
76+
return hir::Pat {
77+
hir_id: self.next_id(),
78+
kind: hir::PatKind::Lit(lit),
79+
span: pattern.span,
80+
default_binding_modes: true,
81+
};
7482
}
7583
PatKind::Struct(qself, path, fields, etc) => {
7684
let qpath = self.lower_qpath(
@@ -299,14 +307,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
299307
Some(res) => {
300308
let hir_id = self.next_id();
301309
let res = self.lower_res(res);
302-
hir::PatKind::Path(hir::QPath::Resolved(
310+
let kind = hir::PatLitKind::Path(hir::QPath::Resolved(
303311
None,
304312
self.arena.alloc(hir::Path {
305313
span: self.lower_span(ident.span),
306314
res,
307315
segments: arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), hir_id, res)],
308316
}),
309-
))
317+
));
318+
let lit = hir::PatLit { kind, hir_id: self.next_id(), span: ident.span };
319+
let lit = self.arena.alloc(lit);
320+
hir::PatKind::Lit(lit)
310321
}
311322
}
312323
}

Diff for: compiler/rustc_hir/src/hir.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ impl<'hir> Pat<'hir> {
11371137

11381138
use PatKind::*;
11391139
match self.kind {
1140-
Wild | Never | Lit(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => true,
1140+
Wild | Never | Lit(_) | Range(..) | Binding(.., None) | Err(_) => true,
11411141
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_short_(it),
11421142
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
11431143
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
@@ -1164,7 +1164,7 @@ impl<'hir> Pat<'hir> {
11641164

11651165
use PatKind::*;
11661166
match self.kind {
1167-
Wild | Never | Lit(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => {}
1167+
Wild | Never | Lit(_) | Range(..) | Binding(.., None) | Err(_) => {}
11681168
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_(it),
11691169
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
11701170
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
@@ -1317,9 +1317,6 @@ pub enum PatKind<'hir> {
13171317
/// A never pattern `!`.
13181318
Never,
13191319

1320-
/// A path pattern for a unit struct/variant or a (maybe-associated) constant.
1321-
Path(QPath<'hir>),
1322-
13231320
/// A tuple pattern (e.g., `(a, b)`).
13241321
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
13251322
/// `0 <= position <= subpats.len()`

Diff for: compiler/rustc_hir/src/intravisit.rs

-3
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,6 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V:
669669
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
670670
walk_list!(visitor, visit_pat, children);
671671
}
672-
PatKind::Path(ref qpath) => {
673-
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
674-
}
675672
PatKind::Struct(ref qpath, fields, _) => {
676673
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
677674
walk_list!(visitor, visit_pat_field, fields);

Diff for: compiler/rustc_hir/src/pat_util.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ impl hir::Pat<'_> {
106106
let mut variants = vec![];
107107
self.walk(|p| match &p.kind {
108108
PatKind::Or(_) => false,
109-
PatKind::Path(hir::QPath::Resolved(_, path))
109+
PatKind::Lit(hir::PatLit {
110+
kind: hir::PatLitKind::Path(hir::QPath::Resolved(_, path)),
111+
..
112+
})
110113
| PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..)
111114
| PatKind::Struct(hir::QPath::Resolved(_, path), ..) => {
112115
if let Res::Def(DefKind::Variant | DefKind::Ctor(CtorOf::Variant, ..), id) =

Diff for: compiler/rustc_hir_analysis/src/check/region.rs

-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ fn resolve_local<'tcx>(
700700
| PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), ..)
701701
| PatKind::Wild
702702
| PatKind::Never
703-
| PatKind::Path(_)
704703
| PatKind::Lit(_)
705704
| PatKind::Range(_, _, _)
706705
| PatKind::Err(_) => false,

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
3737
..
3838
})
3939
| hir::Node::Pat(hir::Pat {
40-
kind: hir::PatKind::Path(hir::QPath::TypeRelative(qself, _)),
40+
kind:
41+
hir::PatKind::Lit(hir::PatLit {
42+
kind: hir::PatLitKind::Path(hir::QPath::TypeRelative(qself, _)),
43+
..
44+
}),
4145
..
4246
}) if qself.hir_id == self_ty.hir_id => true,
4347
_ => false,

Diff for: compiler/rustc_hir_pretty/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1771,9 +1771,6 @@ impl<'a> State<'a> {
17711771
}
17721772
self.pclose();
17731773
}
1774-
PatKind::Path(ref qpath) => {
1775-
self.print_qpath(qpath, true);
1776-
}
17771774
PatKind::Struct(ref qpath, fields, etc) => {
17781775
self.print_qpath(qpath, true);
17791776
self.nbsp();

Diff for: compiler/rustc_hir_typeck/src/expr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
468468
hir::PatKind::Binding(_, _, _, _)
469469
| hir::PatKind::Struct(_, _, _)
470470
| hir::PatKind::TupleStruct(_, _, _)
471-
| hir::PatKind::Path(_)
472471
| hir::PatKind::Tuple(_, _)
473472
| hir::PatKind::Box(_)
474473
| hir::PatKind::Ref(_, _)

Diff for: compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ use hir::def::DefKind;
1111
use hir::pat_util::EnumerateAndAdjustIterator as _;
1212
use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
1313
use rustc_data_structures::fx::FxIndexMap;
14-
use rustc_hir as hir;
1514
use rustc_hir::def::{CtorOf, Res};
1615
use rustc_hir::def_id::LocalDefId;
17-
use rustc_hir::{HirId, PatKind};
16+
use rustc_hir::{self as hir, HirId, PatKind, PatLit, PatLitKind};
1817
use rustc_lint::LateContext;
1918
use rustc_middle::hir::place::ProjectionKind;
2019
// Export these here so that Clippy can use them.
@@ -560,11 +559,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
560559
// FIXME(never_patterns): does this do what I expect?
561560
needs_to_be_read = true;
562561
}
563-
PatKind::Path(qpath) => {
562+
PatKind::Lit(PatLit { kind: PatLitKind::Path(qpath), hir_id, .. }) => {
564563
// A `Path` pattern is just a name like `Foo`. This is either a
565564
// named constant or else it refers to an ADT variant
566565

567-
let res = self.cx.typeck_results().qpath_res(qpath, pat.hir_id);
566+
let res = self.cx.typeck_results().qpath_res(qpath, *hir_id);
568567
match res {
569568
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {
570569
// Named constants have to be equated with the value
@@ -1793,8 +1792,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
17931792
}
17941793
}
17951794

1796-
PatKind::Path(_)
1797-
| PatKind::Binding(.., None)
1795+
PatKind::Binding(.., None)
17981796
| PatKind::Lit(..)
17991797
| PatKind::Range(..)
18001798
| PatKind::Never

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use hir::def_id::LocalDefId;
55
use rustc_ast::util::parser::ExprPrecedence;
66
use rustc_data_structures::packed::Pu128;
77
use rustc_errors::{Applicability, Diag, MultiSpan};
8-
use rustc_hir as hir;
98
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
109
use rustc_hir::lang_items::LangItem;
1110
use rustc_hir::{
12-
Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, GenericBound, HirId,
13-
Node, Path, QPath, Stmt, StmtKind, TyKind, WherePredicateKind,
11+
self as hir, Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind,
12+
GenericBound, HirId, Node, PatLit, PatLitKind, Path, QPath, Stmt, StmtKind, TyKind,
13+
WherePredicateKind,
1414
};
1515
use rustc_hir_analysis::collect::suggest_impl_trait;
1616
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
@@ -1427,8 +1427,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14271427
// since the user probably just misunderstood how `let else`
14281428
// and `&&` work together.
14291429
if let Some((_, hir::Node::LetStmt(local))) = cond_parent
1430-
&& let hir::PatKind::Path(qpath) | hir::PatKind::TupleStruct(qpath, _, _) =
1431-
&local.pat.kind
1430+
&& let hir::PatKind::Lit(PatLit { kind: PatLitKind::Path(qpath), .. })
1431+
| hir::PatKind::TupleStruct(qpath, _, _) = &local.pat.kind
14321432
&& let hir::QPath::Resolved(None, path) = qpath
14331433
&& let Some(did) = path
14341434
.res

Diff for: compiler/rustc_hir_typeck/src/method/suggest.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
178178
})
179179
| hir::Node::Pat(&hir::Pat {
180180
kind:
181-
hir::PatKind::Path(QPath::TypeRelative(rcvr, segment))
182-
| hir::PatKind::Struct(QPath::TypeRelative(rcvr, segment), ..)
181+
hir::PatKind::Struct(QPath::TypeRelative(rcvr, segment), ..)
183182
| hir::PatKind::TupleStruct(QPath::TypeRelative(rcvr, segment), ..),
184183
span,
185184
..

Diff for: compiler/rustc_hir_typeck/src/pat.rs

+21-18
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use rustc_errors::{
1010
};
1111
use rustc_hir::def::{CtorKind, DefKind, Res};
1212
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
13-
use rustc_hir::{self as hir, BindingMode, ByRef, HirId, LangItem, Mutability, Pat, PatKind};
13+
use rustc_hir::{
14+
self as hir, BindingMode, ByRef, HirId, LangItem, Mutability, Pat, PatKind, PatLit, PatLitKind,
15+
};
1416
use rustc_infer::infer;
1517
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
1618
use rustc_middle::{bug, span_bug};
@@ -225,9 +227,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
225227
fn check_pat(&self, pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, pat_info: PatInfo<'_, 'tcx>) {
226228
let PatInfo { binding_mode, max_ref_mutbl, top_info: ti, current_depth, .. } = pat_info;
227229

228-
let path_res = match &pat.kind {
229-
PatKind::Path(qpath) => {
230-
Some(self.resolve_ty_and_res_fully_qualified_call(qpath, pat.hir_id, pat.span))
230+
let path_res = match pat.kind {
231+
PatKind::Lit(&PatLit { kind: PatLitKind::Path(ref qpath), hir_id, span }) => {
232+
Some(self.resolve_ty_and_res_fully_qualified_call(qpath, hir_id, span))
231233
}
232234
_ => None,
233235
};
@@ -246,6 +248,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
246248
PatKind::Wild | PatKind::Err(_) => expected,
247249
// We allow any type here; we ensure that the type is uninhabited during match checking.
248250
PatKind::Never => expected,
251+
PatKind::Lit(&PatLit { kind: PatLitKind::Path(ref qpath), hir_id, span }) => {
252+
let ty = self.check_pat_path(hir_id, span, qpath, path_res.unwrap(), expected, ti);
253+
self.write_ty(hir_id, ty);
254+
ty
255+
}
249256
PatKind::Lit(lt) => self.check_pat_lit(pat.span, lt, expected, ti),
250257
PatKind::Range(lhs, rhs, _) => self.check_pat_range(pat.span, lhs, rhs, expected, ti),
251258
PatKind::Binding(ba, var_id, ident, sub) => {
@@ -254,9 +261,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
254261
PatKind::TupleStruct(ref qpath, subpats, ddpos) => {
255262
self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, pat_info)
256263
}
257-
PatKind::Path(ref qpath) => {
258-
self.check_pat_path(pat.hir_id, pat.span, qpath, path_res.unwrap(), expected, ti)
259-
}
260264
PatKind::Struct(ref qpath, fields, has_rest_pat) => {
261265
self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, pat_info)
262266
}
@@ -364,16 +368,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
364368
| PatKind::Slice(..) => AdjustMode::Peel,
365369
// A never pattern behaves somewhat like a literal or unit variant.
366370
PatKind::Never => AdjustMode::Peel,
367-
// String and byte-string literals result in types `&str` and `&[u8]` respectively.
368-
// All other literals result in non-reference types.
369-
// As a result, we allow `if let 0 = &&0 {}` but not `if let "foo" = &&"foo" {}`.
370-
//
371-
// Call `resolve_vars_if_possible` here for inline const blocks.
372-
PatKind::Lit(lt) => match self.resolve_vars_if_possible(self.check_pat_lit_unadjusted(lt)).kind() {
373-
ty::Ref(..) => AdjustMode::Pass,
374-
_ => AdjustMode::Peel,
375-
},
376-
PatKind::Path(_) => match opt_path_res.unwrap() {
371+
PatKind::Lit(PatLit { kind: PatLitKind::Path(_), .. }) => match opt_path_res.unwrap() {
377372
// These constants can be of a reference type, e.g. `const X: &u8 = &0;`.
378373
// Peeling the reference types too early will cause type checking failures.
379374
// Although it would be possible to *also* peel the types of the constants too.
@@ -384,6 +379,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
384379
// a reference type wherefore peeling doesn't give up any expressiveness.
385380
_ => AdjustMode::Peel,
386381
},
382+
// String and byte-string literals result in types `&str` and `&[u8]` respectively.
383+
// All other literals result in non-reference types.
384+
// As a result, we allow `if let 0 = &&0 {}` but not `if let "foo" = &&"foo" {}`.
385+
//
386+
// Call `resolve_vars_if_possible` here for inline const blocks.
387+
PatKind::Lit(lt) => match self.resolve_vars_if_possible(self.check_pat_lit_unadjusted(lt)).kind() {
388+
ty::Ref(..) => AdjustMode::Pass,
389+
_ => AdjustMode::Peel,
390+
},
387391
// Ref patterns are complicated, we handle them in `check_pat_ref`.
388392
PatKind::Ref(..) => AdjustMode::Pass,
389393
// A `_` pattern works with any expected type, so there's no need to do anything.
@@ -905,7 +909,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
905909
PatKind::Wild
906910
| PatKind::Never
907911
| PatKind::Binding(..)
908-
| PatKind::Path(..)
909912
| PatKind::Box(..)
910913
| PatKind::Deref(_)
911914
| PatKind::Ref(..)

Diff for: compiler/rustc_lint/src/internal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir::def::Res;
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::{
88
BinOp, BinOpKind, Expr, ExprKind, GenericArg, HirId, Impl, Item, ItemKind, Node, Pat, PatKind,
9-
Path, PathSegment, QPath, Ty, TyKind,
9+
PatLit, PatLitKind, Path, PathSegment, QPath, Ty, TyKind,
1010
};
1111
use rustc_middle::ty::{self, GenericArgsRef, Ty as MiddleTy};
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -167,7 +167,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
167167
let span = match cx.tcx.parent_hir_node(ty.hir_id) {
168168
Node::Pat(Pat {
169169
kind:
170-
PatKind::Path(qpath)
170+
PatKind::Lit(PatLit { kind: PatLitKind::Path(qpath), .. })
171171
| PatKind::TupleStruct(qpath, ..)
172172
| PatKind::Struct(qpath, ..),
173173
..

Diff for: compiler/rustc_lint/src/nonstandard_style.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_abi::ExternAbi;
22
use rustc_hir::def::{DefKind, Res};
33
use rustc_hir::intravisit::FnKind;
4-
use rustc_hir::{GenericParamKind, PatKind};
4+
use rustc_hir::{GenericParamKind, PatKind, PatLit, PatLitKind};
55
use rustc_middle::ty;
66
use rustc_session::config::CrateType;
77
use rustc_session::{declare_lint, declare_lint_pass};
@@ -528,7 +528,11 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
528528

529529
fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) {
530530
// Lint for constants that look like binding identifiers (#7526)
531-
if let PatKind::Path(hir::QPath::Resolved(None, path)) = p.kind {
531+
if let PatKind::Lit(PatLit {
532+
kind: PatLitKind::Path(hir::QPath::Resolved(None, path)),
533+
..
534+
}) = p.kind
535+
{
532536
if let Res::Def(DefKind::Const, _) = path.res {
533537
if let [segment] = path.segments {
534538
NonUpperCaseGlobals::check_upper_case(

Diff for: compiler/rustc_mir_build/src/thir/pattern/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,6 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
318318
.unwrap_or_else(PatKind::Error)
319319
}
320320

321-
hir::PatKind::Path(ref qpath) => {
322-
return self.lower_path(qpath, pat.hir_id, pat.span);
323-
}
324-
325321
hir::PatKind::Deref(subpattern) => {
326322
let mutable = self.typeck_results.pat_has_ref_mut_binding(subpattern);
327323
let mutability = if mutable { hir::Mutability::Mut } else { hir::Mutability::Not };

Diff for: compiler/rustc_passes/src/dead.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ use hir::def_id::{LocalDefIdMap, LocalDefIdSet};
1010
use rustc_abi::FieldIdx;
1111
use rustc_data_structures::unord::UnordSet;
1212
use rustc_errors::MultiSpan;
13-
use rustc_hir as hir;
1413
use rustc_hir::def::{CtorOf, DefKind, Res};
1514
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
1615
use rustc_hir::intravisit::{self, Visitor};
17-
use rustc_hir::{Node, PatKind, TyKind};
16+
use rustc_hir::{self as hir, Node, PatKind, PatLit, PatLitKind, TyKind};
1817
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1918
use rustc_middle::middle::privacy::Level;
2019
use rustc_middle::query::Providers;
@@ -637,8 +636,8 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
637636
let res = self.typeck_results().qpath_res(path, pat.hir_id);
638637
self.handle_field_pattern_match(pat, res, fields);
639638
}
640-
PatKind::Path(ref qpath) => {
641-
let res = self.typeck_results().qpath_res(qpath, pat.hir_id);
639+
PatKind::Lit(PatLit { kind: PatLitKind::Path(qpath), hir_id, .. }) => {
640+
let res = self.typeck_results().qpath_res(qpath, *hir_id);
642641
self.handle_res(res);
643642
}
644643
PatKind::TupleStruct(ref qpath, fields, dotdot) => {

Diff for: compiler/rustc_passes/src/input_stats.rs

-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
295295
TupleStruct,
296296
Or,
297297
Never,
298-
Path,
299298
Tuple,
300299
Box,
301300
Deref,

Diff for: src/librustdoc/clean/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
303303
return kw::Underscore;
304304
}
305305
PatKind::Binding(_, _, ident, _) => return ident.name,
306-
PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p),
306+
PatKind::TupleStruct(ref p, ..)
307+
| PatKind::Lit(PatLit { kind: PatLitKind::Path(ref p), .. }) => qpath_to_string(p),
307308
PatKind::Or(pats) => {
308309
pats.iter().map(|p| name_from_pat(p).to_string()).collect::<Vec<String>>().join(" | ")
309310
}

0 commit comments

Comments
 (0)