Skip to content

Commit ae5de6c

Browse files
committed
Auto merge of rust-lang#134248 - oli-obk:patkind-path-removal, r=BoxyUwU
Merge `PatKind::Path` into `PatKind::Expr` Follow-up to rust-lang#134228 We always had a duplication where `Path`s could be represented as `PatKind::Path` or `PatKind::Lit(ExprKind::Path)`. We had to handle both everywhere, and still do after rust-lang#134228, so I'm removing it now.
2 parents 0cc4f4f + 559648a commit ae5de6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+299
-183
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
13911391
None,
13921392
);
13931393
// Destructure like a unit struct.
1394-
let unit_struct_pat = hir::PatKind::Path(qpath);
1394+
let unit_struct_pat = hir::PatKind::Expr(self.arena.alloc(hir::PatExpr {
1395+
kind: hir::PatExprKind::Path(qpath),
1396+
hir_id: self.next_id(),
1397+
span: self.lower_span(lhs.span),
1398+
}));
13951399
return self.pat_without_dbm(lhs.span, unit_struct_pat);
13961400
}
13971401
}

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

+23-10
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6969
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
7070
None,
7171
);
72-
break hir::PatKind::Path(qpath);
72+
let kind = hir::PatExprKind::Path(qpath);
73+
let span = self.lower_span(pattern.span);
74+
let expr = hir::PatExpr { hir_id: pat_hir_id, span, kind };
75+
let expr = self.arena.alloc(expr);
76+
return hir::Pat {
77+
hir_id: self.next_id(),
78+
kind: hir::PatKind::Expr(expr),
79+
span,
80+
default_binding_modes: true,
81+
};
7382
}
7483
PatKind::Struct(qself, path, fields, etc) => {
7584
let qpath = self.lower_qpath(
@@ -304,16 +313,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
304313
)
305314
}
306315
Some(res) => {
307-
let hir_id = self.next_id();
308316
let res = self.lower_res(res);
309-
hir::PatKind::Path(hir::QPath::Resolved(
310-
None,
311-
self.arena.alloc(hir::Path {
312-
span: self.lower_span(ident.span),
313-
res,
314-
segments: arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), hir_id, res)],
315-
}),
316-
))
317+
let span = self.lower_span(ident.span);
318+
hir::PatKind::Expr(self.arena.alloc(hir::PatExpr {
319+
kind: hir::PatExprKind::Path(hir::QPath::Resolved(
320+
None,
321+
self.arena.alloc(hir::Path {
322+
span,
323+
res,
324+
segments: arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), self.next_id(), res)],
325+
}),
326+
)),
327+
hir_id: self.next_id(),
328+
span,
329+
}))
317330
}
318331
}
319332
}

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

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

14381438
use PatKind::*;
14391439
match self.kind {
1440-
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => true,
1440+
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
14411441
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_short_(it),
14421442
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
14431443
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
@@ -1464,7 +1464,7 @@ impl<'hir> Pat<'hir> {
14641464

14651465
use PatKind::*;
14661466
match self.kind {
1467-
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Path(_) | Err(_) => {}
1467+
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
14681468
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
14691469
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
14701470
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
@@ -1618,9 +1618,6 @@ pub enum PatKind<'hir> {
16181618
/// A never pattern `!`.
16191619
Never,
16201620

1621-
/// A path pattern for a unit struct/variant or a (maybe-associated) constant.
1622-
Path(QPath<'hir>),
1623-
16241621
/// A tuple pattern (e.g., `(a, b)`).
16251622
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
16261623
/// `0 <= position <= subpats.len()`

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

-3
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,6 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V:
709709
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
710710
walk_list!(visitor, visit_pat, children);
711711
}
712-
PatKind::Path(ref qpath) => {
713-
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
714-
}
715712
PatKind::Struct(ref qpath, fields, _) => {
716713
try_visit!(visitor.visit_qpath(qpath, pattern.hir_id, pattern.span));
717714
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
@@ -105,7 +105,10 @@ impl hir::Pat<'_> {
105105
let mut variants = vec![];
106106
self.walk(|p| match &p.kind {
107107
PatKind::Or(_) => false,
108-
PatKind::Path(hir::QPath::Resolved(_, path))
108+
PatKind::Expr(hir::PatExpr {
109+
kind: hir::PatExprKind::Path(hir::QPath::Resolved(_, path)),
110+
..
111+
})
109112
| PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..)
110113
| PatKind::Struct(hir::QPath::Resolved(_, path), ..) => {
111114
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
@@ -703,7 +703,6 @@ fn resolve_local<'tcx>(
703703
| PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), ..)
704704
| PatKind::Wild
705705
| PatKind::Never
706-
| PatKind::Path(_)
707706
| PatKind::Expr(_)
708707
| PatKind::Range(_, _, _)
709708
| PatKind::Err(_) => false,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
4141
kind: hir::ExprKind::Path(hir::QPath::TypeRelative(qself, _)),
4242
..
4343
})
44-
| hir::Node::Pat(hir::Pat {
45-
kind: hir::PatKind::Path(hir::QPath::TypeRelative(qself, _)),
44+
| hir::Node::PatExpr(hir::PatExpr {
45+
kind: hir::PatExprKind::Path(hir::QPath::TypeRelative(qself, _)),
4646
..
4747
}) if qself.hir_id == self_ty.hir_id => true,
4848
_ => false,

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

-3
Original file line numberDiff line numberDiff line change
@@ -1906,9 +1906,6 @@ impl<'a> State<'a> {
19061906
}
19071907
self.pclose();
19081908
}
1909-
PatKind::Path(ref qpath) => {
1910-
self.print_qpath(qpath, true);
1911-
}
19121909
PatKind::Struct(ref qpath, fields, etc) => {
19131910
self.print_qpath(qpath, true);
19141911
self.nbsp();

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

-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
480480
hir::PatKind::Binding(_, _, _, _)
481481
| hir::PatKind::Struct(_, _, _)
482482
| hir::PatKind::TupleStruct(_, _, _)
483-
| hir::PatKind::Path(_)
484483
| hir::PatKind::Tuple(_, _)
485484
| hir::PatKind::Box(_)
486485
| hir::PatKind::Ref(_, _)

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

+5-7
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, PatExpr, PatExprKind, PatKind};
1817
use rustc_lint::LateContext;
1918
use rustc_middle::hir::place::ProjectionKind;
2019
// Export these here so that Clippy can use them.
@@ -564,11 +563,11 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
564563
// FIXME(never_patterns): does this do what I expect?
565564
needs_to_be_read = true;
566565
}
567-
PatKind::Path(qpath) => {
566+
PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, span }) => {
568567
// A `Path` pattern is just a name like `Foo`. This is either a
569568
// named constant or else it refers to an ADT variant
570569

571-
let res = self.cx.typeck_results().qpath_res(qpath, pat.hir_id);
570+
let res = self.cx.typeck_results().qpath_res(qpath, *hir_id);
572571
match res {
573572
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {
574573
// Named constants have to be equated with the value
@@ -581,7 +580,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
581580
// Otherwise, this is a struct/enum variant, and so it's
582581
// only a read if we need to read the discriminant.
583582
needs_to_be_read |=
584-
self.is_multivariant_adt(place.place.ty(), pat.span);
583+
self.is_multivariant_adt(place.place.ty(), *span);
585584
}
586585
}
587586
}
@@ -1801,8 +1800,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
18011800
}
18021801
}
18031802

1804-
PatKind::Path(_)
1805-
| PatKind::Binding(.., None)
1803+
PatKind::Binding(.., None)
18061804
| PatKind::Expr(..)
18071805
| PatKind::Range(..)
18081806
| 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, expr_needs_parens,
11+
self as hir, Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind,
12+
GenericBound, HirId, Node, PatExpr, PatExprKind, Path, QPath, Stmt, StmtKind, TyKind,
13+
WherePredicateKind, expr_needs_parens,
1414
};
1515
use rustc_hir_analysis::collect::suggest_impl_trait;
1616
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
@@ -1422,8 +1422,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14221422
// since the user probably just misunderstood how `let else`
14231423
// and `&&` work together.
14241424
if let Some((_, hir::Node::LetStmt(local))) = cond_parent
1425-
&& let hir::PatKind::Path(qpath) | hir::PatKind::TupleStruct(qpath, _, _) =
1426-
&local.pat.kind
1425+
&& let hir::PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), .. })
1426+
| hir::PatKind::TupleStruct(qpath, _, _) = &local.pat.kind
14271427
&& let hir::QPath::Resolved(None, path) = qpath
14281428
&& let Some(did) = path
14291429
.res

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

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

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

+34-22
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use rustc_errors::{
1111
use rustc_hir::def::{CtorKind, DefKind, Res};
1212
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
1313
use rustc_hir::{
14-
self as hir, BindingMode, ByRef, ExprKind, HirId, LangItem, Mutability, Pat, PatKind,
15-
expr_needs_parens,
14+
self as hir, BindingMode, ByRef, ExprKind, HirId, LangItem, Mutability, Pat, PatExpr,
15+
PatExprKind, PatKind, expr_needs_parens,
1616
};
1717
use rustc_infer::infer;
1818
use rustc_middle::traits::PatternOriginExpr;
@@ -312,9 +312,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
312312
fn check_pat(&self, pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, pat_info: PatInfo<'_, 'tcx>) {
313313
let PatInfo { binding_mode, max_ref_mutbl, top_info: ti, current_depth, .. } = pat_info;
314314

315-
let path_res = match &pat.kind {
316-
PatKind::Path(qpath) => {
317-
Some(self.resolve_ty_and_res_fully_qualified_call(qpath, pat.hir_id, pat.span))
315+
let path_res = match pat.kind {
316+
PatKind::Expr(PatExpr { kind: PatExprKind::Path(ref qpath), hir_id, span }) => {
317+
Some(self.resolve_ty_and_res_fully_qualified_call(qpath, *hir_id, *span))
318318
}
319319
_ => None,
320320
};
@@ -333,6 +333,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
333333
PatKind::Wild | PatKind::Err(_) => expected,
334334
// We allow any type here; we ensure that the type is uninhabited during match checking.
335335
PatKind::Never => expected,
336+
PatKind::Expr(PatExpr { kind: PatExprKind::Path(ref qpath), hir_id, span }) => {
337+
let ty = self.check_pat_path(
338+
*hir_id,
339+
pat.hir_id,
340+
*span,
341+
qpath,
342+
path_res.unwrap(),
343+
expected,
344+
ti,
345+
);
346+
self.write_ty(*hir_id, ty);
347+
ty
348+
}
336349
PatKind::Expr(lt) => self.check_pat_lit(pat.span, lt, expected, ti),
337350
PatKind::Range(lhs, rhs, _) => self.check_pat_range(pat.span, lhs, rhs, expected, ti),
338351
PatKind::Binding(ba, var_id, ident, sub) => {
@@ -341,9 +354,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
341354
PatKind::TupleStruct(ref qpath, subpats, ddpos) => {
342355
self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, pat_info)
343356
}
344-
PatKind::Path(ref qpath) => {
345-
self.check_pat_path(pat.hir_id, pat.span, qpath, path_res.unwrap(), expected, ti)
346-
}
347357
PatKind::Struct(ref qpath, fields, has_rest_pat) => {
348358
self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, pat_info)
349359
}
@@ -456,16 +466,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
456466
| PatKind::Slice(..) => AdjustMode::Peel,
457467
// A never pattern behaves somewhat like a literal or unit variant.
458468
PatKind::Never => AdjustMode::Peel,
459-
// String and byte-string literals result in types `&str` and `&[u8]` respectively.
460-
// All other literals result in non-reference types.
461-
// As a result, we allow `if let 0 = &&0 {}` but not `if let "foo" = &&"foo" {}`.
462-
//
463-
// Call `resolve_vars_if_possible` here for inline const blocks.
464-
PatKind::Expr(lt) => match self.resolve_vars_if_possible(self.check_pat_expr_unadjusted(lt)).kind() {
465-
ty::Ref(..) => AdjustMode::Pass,
466-
_ => AdjustMode::Peel,
467-
},
468-
PatKind::Path(_) => match opt_path_res.unwrap() {
469+
PatKind::Expr(PatExpr { kind: PatExprKind::Path(_), .. }) => match opt_path_res.unwrap() {
469470
// These constants can be of a reference type, e.g. `const X: &u8 = &0;`.
470471
// Peeling the reference types too early will cause type checking failures.
471472
// Although it would be possible to *also* peel the types of the constants too.
@@ -476,6 +477,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
476477
// a reference type wherefore peeling doesn't give up any expressiveness.
477478
_ => AdjustMode::Peel,
478479
},
480+
481+
// String and byte-string literals result in types `&str` and `&[u8]` respectively.
482+
// All other literals result in non-reference types.
483+
// As a result, we allow `if let 0 = &&0 {}` but not `if let "foo" = &&"foo" {}`.
484+
//
485+
// Call `resolve_vars_if_possible` here for inline const blocks.
486+
PatKind::Expr(lt) => match self.resolve_vars_if_possible(self.check_pat_expr_unadjusted(lt)).kind() {
487+
ty::Ref(..) => AdjustMode::Pass,
488+
_ => AdjustMode::Peel,
489+
},
490+
479491
// Ref patterns are complicated, we handle them in `check_pat_ref`.
480492
PatKind::Ref(..) => AdjustMode::Pass,
481493
// A `_` pattern works with any expected type, so there's no need to do anything.
@@ -1001,7 +1013,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10011013
PatKind::Wild
10021014
| PatKind::Never
10031015
| PatKind::Binding(..)
1004-
| PatKind::Path(..)
10051016
| PatKind::Box(..)
10061017
| PatKind::Deref(_)
10071018
| PatKind::Ref(..)
@@ -1139,7 +1150,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11391150

11401151
fn check_pat_path(
11411152
&self,
1142-
hir_id: HirId,
1153+
path_id: HirId,
1154+
pat_id_for_diag: HirId,
11431155
span: Span,
11441156
qpath: &hir::QPath<'_>,
11451157
path_resolution: (Res, Option<LoweredTy<'tcx>>, &'tcx [hir::PathSegment<'tcx>]),
@@ -1193,11 +1205,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11931205

11941206
// Type-check the path.
11951207
let (pat_ty, pat_res) =
1196-
self.instantiate_value_path(segments, opt_ty, res, span, span, hir_id);
1208+
self.instantiate_value_path(segments, opt_ty, res, span, span, path_id);
11971209
if let Err(err) =
11981210
self.demand_suptype_with_origin(&self.pattern_cause(ti, span), expected, pat_ty)
11991211
{
1200-
self.emit_bad_pat_path(err, hir_id, span, res, pat_res, pat_ty, segments);
1212+
self.emit_bad_pat_path(err, pat_id_for_diag, span, res, pat_res, pat_ty, segments);
12011213
}
12021214
pat_ty
12031215
}

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

+4-6
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
AmbigArg, BinOp, BinOpKind, Expr, ExprKind, GenericArg, HirId, Impl, Item, ItemKind, Node, Pat,
9-
PatKind, Path, PathSegment, QPath, Ty, TyKind,
9+
PatExpr, PatExprKind, PatKind, 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};
@@ -164,11 +164,9 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
164164
TyKind::Path(QPath::Resolved(_, path)) => {
165165
if lint_ty_kind_usage(cx, &path.res) {
166166
let span = match cx.tcx.parent_hir_node(ty.hir_id) {
167-
Node::Pat(Pat {
168-
kind:
169-
PatKind::Path(qpath)
170-
| PatKind::TupleStruct(qpath, ..)
171-
| PatKind::Struct(qpath, ..),
167+
Node::PatExpr(PatExpr { kind: PatExprKind::Path(qpath), .. })
168+
| Node::Pat(Pat {
169+
kind: PatKind::TupleStruct(qpath, ..) | PatKind::Struct(qpath, ..),
172170
..
173171
})
174172
| Node::Expr(

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::{AttrArgs, AttrItem, AttrKind, GenericParamKind, PatKind};
4+
use rustc_hir::{AttrArgs, AttrItem, AttrKind, GenericParamKind, PatExprKind, PatKind};
55
use rustc_middle::ty;
66
use rustc_session::config::CrateType;
77
use rustc_session::{declare_lint, declare_lint_pass};
@@ -527,7 +527,11 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
527527

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

0 commit comments

Comments
 (0)