Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7eefa76

Browse files
committed
Eliminate PatKind::Path
1 parent a4eff9d commit 7eefa76

18 files changed

+135
-57
lines changed

clippy_lints/src/equatable_if_let.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
5656
PatKind::Struct(_, a, etc) => !etc && a.iter().all(|x| unary_pattern(x.pat)),
5757
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => etc.as_opt_usize().is_none() && array_rec(a),
5858
PatKind::Ref(x, _) | PatKind::Box(x) | PatKind::Deref(x) | PatKind::Guard(x, _) => unary_pattern(x),
59-
PatKind::Path(_) | PatKind::Expr(_) => true,
59+
PatKind::Expr(_) => true,
6060
}
6161
}
6262

clippy_lints/src/manual_let_else.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
77
use clippy_utils::{is_lint_allowed, is_never_expr, msrvs, pat_and_expr_can_be_question_mark, peel_blocks};
88
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
99
use rustc_errors::Applicability;
10-
use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, Stmt, StmtKind};
10+
use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatExpr, PatExprKind, PatKind, QPath, Stmt, StmtKind};
1111
use rustc_lint::{LateContext, LintContext};
1212
use rustc_middle::lint::in_external_macro;
1313

@@ -292,7 +292,12 @@ fn pat_allowed_for_else(cx: &LateContext<'_>, pat: &'_ Pat<'_>, check_types: boo
292292
// Only do the check if the type is "spelled out" in the pattern
293293
if !matches!(
294294
pat.kind,
295-
PatKind::Struct(..) | PatKind::TupleStruct(..) | PatKind::Path(..)
295+
PatKind::Struct(..)
296+
| PatKind::TupleStruct(..)
297+
| PatKind::Expr(PatExpr {
298+
kind: PatExprKind::Path(..),
299+
..
300+
},)
296301
) {
297302
return;
298303
}

clippy_lints/src/manual_unwrap_or_default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_errors::Applicability;
22
use rustc_hir::def::Res;
3-
use rustc_hir::{Arm, Expr, ExprKind, HirId, LangItem, MatchSource, Pat, PatKind, QPath};
3+
use rustc_hir::{Arm, Expr, ExprKind, HirId, LangItem, MatchSource, Pat, PatExpr, PatExprKind, PatKind, QPath};
44
use rustc_lint::{LateContext, LateLintPass, LintContext};
55
use rustc_middle::ty::GenericArgKind;
66
use rustc_session::declare_lint_pass;
@@ -68,7 +68,7 @@ fn get_some<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'tcx>) -> Option<HirId> {
6868
}
6969

7070
fn get_none<'tcx>(cx: &LateContext<'tcx>, arm: &Arm<'tcx>) -> Option<&'tcx Expr<'tcx>> {
71-
if let PatKind::Path(QPath::Resolved(_, path)) = arm.pat.kind
71+
if let PatKind::Expr(PatExpr { kind: PatExprKind::Path(QPath::Resolved(_, path)), .. }) = arm.pat.kind
7272
&& let Some(def_id) = path.res.opt_def_id()
7373
// Since it comes from a pattern binding, we need to get the parent to actually match
7474
// against it.

clippy_lints/src/matches/collapsible_match.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clippy_utils::{
88
};
99
use rustc_errors::MultiSpan;
1010
use rustc_hir::LangItem::OptionNone;
11-
use rustc_hir::{Arm, Expr, HirId, Pat, PatKind};
11+
use rustc_hir::{Arm, Expr, HirId, Pat, PatExpr, PatExprKind, PatKind};
1212
use rustc_lint::LateContext;
1313
use rustc_span::Span;
1414

@@ -119,7 +119,11 @@ fn arm_is_wild_like(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
119119
}
120120
match arm.pat.kind {
121121
PatKind::Binding(..) | PatKind::Wild => true,
122-
PatKind::Path(ref qpath) => is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), OptionNone),
122+
PatKind::Expr(PatExpr {
123+
kind: PatExprKind::Path(qpath),
124+
hir_id,
125+
..
126+
}) => is_res_lang_ctor(cx, cx.qpath_res(qpath, *hir_id), OptionNone),
123127
_ => false,
124128
}
125129
}

clippy_lints/src/matches/manual_ok_err.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_ast::BindingMode;
66
use rustc_errors::Applicability;
77
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr};
88
use rustc_hir::def::{DefKind, Res};
9-
use rustc_hir::{Arm, Expr, ExprKind, Pat, PatKind, Path, QPath};
9+
use rustc_hir::{Arm, Expr, ExprKind, Pat, PatExpr, PatExprKind, PatKind, Path, QPath};
1010
use rustc_lint::{LateContext, LintContext};
1111
use rustc_middle::ty::Ty;
1212
use rustc_span::symbol::Ident;
@@ -60,7 +60,16 @@ pub(crate) fn check_match(cx: &LateContext<'_>, expr: &Expr<'_>, scrutinee: &Exp
6060
/// accepted.
6161
fn is_variant_or_wildcard(cx: &LateContext<'_>, pat: &Pat<'_>, can_be_wild: bool, must_match_err: bool) -> bool {
6262
match pat.kind {
63-
PatKind::Wild | PatKind::Path(..) | PatKind::Binding(_, _, _, None) if can_be_wild => true,
63+
PatKind::Wild
64+
| PatKind::Expr(PatExpr {
65+
kind: PatExprKind::Path(_),
66+
..
67+
})
68+
| PatKind::Binding(_, _, _, None)
69+
if can_be_wild =>
70+
{
71+
true
72+
},
6473
PatKind::TupleStruct(qpath, ..) => {
6574
is_res_lang_ctor(cx, cx.qpath_res(&qpath, pat.hir_id), ResultErr) == must_match_err
6675
},

clippy_lints/src/matches/manual_unwrap_or.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clippy_utils::{is_res_lang_ctor, path_to_local_id, peel_blocks, sugg};
77
use rustc_errors::Applicability;
88
use rustc_hir::LangItem::{OptionNone, ResultErr};
99
use rustc_hir::def::{DefKind, Res};
10-
use rustc_hir::{Arm, Expr, Pat, PatKind};
10+
use rustc_hir::{Arm, Expr, Pat, PatExpr, PatExprKind, PatKind};
1111
use rustc_lint::LateContext;
1212
use rustc_middle::ty::Ty;
1313
use rustc_span::sym;
@@ -89,7 +89,11 @@ fn applicable_or_arm<'a>(cx: &LateContext<'_>, arms: &'a [Arm<'a>]) -> Option<(&
8989
if arms.len() == 2
9090
&& arms.iter().all(|arm| arm.guard.is_none())
9191
&& let Some((idx, or_arm)) = arms.iter().enumerate().find(|(_, arm)| match arm.pat.kind {
92-
PatKind::Path(ref qpath) => is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), OptionNone),
92+
PatKind::Expr(PatExpr {
93+
hir_id,
94+
kind: PatExprKind::Path(qpath),
95+
..
96+
}) => is_res_lang_ctor(cx, cx.qpath_res(qpath, *hir_id), OptionNone),
9397
PatKind::TupleStruct(ref qpath, [pat], _) => {
9498
matches!(pat.kind, PatKind::Wild)
9599
&& is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), ResultErr)

clippy_lints/src/matches/manual_utils.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_ast::util::parser::ExprPrecedence;
1111
use rustc_errors::Applicability;
1212
use rustc_hir::LangItem::{OptionNone, OptionSome};
1313
use rustc_hir::def::Res;
14-
use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath};
14+
use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Mutability, Pat, PatExpr, PatExprKind, PatKind, Path, QPath};
1515
use rustc_lint::LateContext;
1616
use rustc_span::{SyntaxContext, sym};
1717

@@ -256,9 +256,11 @@ pub(super) fn try_parse_pattern<'tcx>(
256256
match pat.kind {
257257
PatKind::Wild => Some(OptionPat::Wild),
258258
PatKind::Ref(pat, _) => f(cx, pat, ref_count + 1, ctxt),
259-
PatKind::Path(ref qpath) if is_res_lang_ctor(cx, cx.qpath_res(qpath, pat.hir_id), OptionNone) => {
260-
Some(OptionPat::None)
261-
},
259+
PatKind::Expr(PatExpr {
260+
kind: PatExprKind::Path(qpath),
261+
hir_id,
262+
..
263+
}) if is_res_lang_ctor(cx, cx.qpath_res(qpath, *hir_id), OptionNone) => Some(OptionPat::None),
262264
PatKind::TupleStruct(ref qpath, [pattern], _)
263265
if is_res_lang_ctor(cx, cx.qpath_res(qpath, pat.hir_id), OptionSome) && pat.span.ctxt() == ctxt =>
264266
{

clippy_lints/src/matches/match_as_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet_with_applicability;
33
use clippy_utils::{is_res_lang_ctor, path_res, peel_blocks};
44
use rustc_errors::Applicability;
5-
use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, LangItem, Mutability, PatKind, QPath};
5+
use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, LangItem, Mutability, PatExpr, PatExprKind, PatKind, QPath};
66
use rustc_lint::LateContext;
77
use rustc_middle::ty;
88

@@ -59,7 +59,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr:
5959
fn is_none_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
6060
matches!(
6161
arm.pat.kind,
62-
PatKind::Path(ref qpath) if is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), LangItem::OptionNone)
62+
PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), .. }) if is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), LangItem::OptionNone)
6363
)
6464
}
6565

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_arena::DroplessArena;
77
use rustc_ast::ast::LitKind;
88
use rustc_errors::Applicability;
99
use rustc_hir::def_id::DefId;
10-
use rustc_hir::{Arm, Expr, HirId, HirIdMap, HirIdMapEntry, HirIdSet, Pat, PatExprKind, PatKind, RangeEnd};
10+
use rustc_hir::{Arm, Expr, HirId, HirIdMap, HirIdMapEntry, HirIdSet, Pat, PatExpr, PatExprKind, PatKind, RangeEnd};
1111
use rustc_lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
1212
use rustc_lint::{LateContext, LintContext};
1313
use rustc_middle::ty;
@@ -292,7 +292,11 @@ impl<'a> NormalizedPat<'a> {
292292
Self::Tuple(var_id, pats)
293293
},
294294
PatKind::Or(pats) => Self::Or(arena.alloc_from_iter(pats.iter().map(|pat| Self::from_pat(cx, arena, pat)))),
295-
PatKind::Path(ref path) => Self::Path(cx.qpath_res(path, pat.hir_id).opt_def_id()),
295+
PatKind::Expr(PatExpr {
296+
kind: PatExprKind::Path(path),
297+
hir_id,
298+
..
299+
}) => Self::Path(cx.qpath_res(path, *hir_id).opt_def_id()),
296300
PatKind::Tuple(pats, wild_idx) => {
297301
let field_count = match cx.typeck_results().pat_ty(pat).kind() {
298302
ty::Tuple(subs) => subs.len(),

clippy_lints/src/matches/match_wild_enum.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
33
use clippy_utils::{is_refutable, peel_hir_pat_refs, recurse_or_patterns};
44
use rustc_errors::Applicability;
55
use rustc_hir::def::{CtorKind, DefKind, Res};
6-
use rustc_hir::{Arm, Expr, PatKind, PathSegment, QPath, Ty, TyKind};
6+
use rustc_hir::{Arm, Expr, PatExpr, PatExprKind, PatKind, PathSegment, QPath, Ty, TyKind};
77
use rustc_lint::LateContext;
88
use rustc_middle::ty::{self, VariantDef};
99
use rustc_span::sym;
@@ -60,8 +60,13 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
6060
// covered by the set of guards that cover it, but that's really hard to do.
6161
recurse_or_patterns(arm.pat, |pat| {
6262
let path = match &peel_hir_pat_refs(pat).0.kind {
63-
PatKind::Path(path) => {
64-
let id = match cx.qpath_res(path, pat.hir_id) {
63+
PatKind::Expr(PatExpr {
64+
hir_id,
65+
kind: PatExprKind::Path(path),
66+
..
67+
}) => {
68+
// FIXME(clippy): don't you want to use the hir id of the peeled pat?
69+
let id = match cx.qpath_res(path, *hir_id) {
6570
Res::Def(
6671
DefKind::Const | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst,
6772
_,

clippy_lints/src/matches/needless_match.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use clippy_utils::{
88
};
99
use rustc_errors::Applicability;
1010
use rustc_hir::LangItem::OptionNone;
11-
use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, ItemKind, Node, Pat, PatExprKind, PatKind, Path, QPath};
11+
use rustc_hir::{
12+
Arm, BindingMode, ByRef, Expr, ExprKind, ItemKind, Node, Pat, PatExpr, PatExprKind, PatKind, Path, QPath,
13+
};
1214
use rustc_lint::LateContext;
1315
use rustc_span::sym;
1416

@@ -183,7 +185,13 @@ fn pat_same_as_expr(pat: &Pat<'_>, expr: &Expr<'_>) -> bool {
183185
return !matches!(annot, BindingMode(ByRef::Yes(_), _)) && pat_ident.name == first_seg.ident.name;
184186
},
185187
// Example: `Custom::TypeA => Custom::TypeB`, or `None => None`
186-
(PatKind::Path(QPath::Resolved(_, p_path)), ExprKind::Path(QPath::Resolved(_, e_path))) => {
188+
(
189+
PatKind::Expr(PatExpr {
190+
kind: PatExprKind::Path(QPath::Resolved(_, p_path)),
191+
..
192+
}),
193+
ExprKind::Path(QPath::Resolved(_, e_path)),
194+
) => {
187195
return over(p_path.segments, e_path.segments, |p_seg, e_seg| {
188196
p_seg.ident.name == e_seg.ident.name
189197
});

clippy_lints/src/matches/redundant_pattern_match.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::ast::LitKind;
99
use rustc_errors::Applicability;
1010
use rustc_hir::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk};
1111
use rustc_hir::def::{DefKind, Res};
12-
use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatExprKind, PatKind, QPath, UnOp};
12+
use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatExpr, PatExprKind, PatKind, QPath, UnOp};
1313
use rustc_lint::LateContext;
1414
use rustc_middle::ty::{self, GenericArgKind, Ty};
1515
use rustc_span::{Span, Symbol, sym};
@@ -149,8 +149,12 @@ fn find_method_and_type<'tcx>(
149149
None
150150
}
151151
},
152-
PatKind::Path(ref path) => {
153-
if let Res::Def(DefKind::Ctor(..), ctor_id) = cx.qpath_res(path, check_pat.hir_id)
152+
PatKind::Expr(PatExpr {
153+
kind: PatExprKind::Path(path),
154+
hir_id,
155+
..
156+
}) => {
157+
if let Res::Def(DefKind::Ctor(..), ctor_id) = cx.qpath_res(path, *hir_id)
154158
&& let Some(variant_id) = cx.tcx.opt_parent(ctor_id)
155159
{
156160
let method = if cx.tcx.lang_items().option_none_variant() == Some(variant_id) {
@@ -351,10 +355,20 @@ fn found_good_method<'tcx>(
351355
None
352356
}
353357
},
354-
(PatKind::TupleStruct(path_left, patterns, _), PatKind::Path(path_right))
355-
| (PatKind::Path(path_left), PatKind::TupleStruct(path_right, patterns, _))
356-
if patterns.len() == 1 =>
357-
{
358+
(
359+
PatKind::TupleStruct(path_left, patterns, _),
360+
PatKind::Expr(PatExpr {
361+
kind: PatExprKind::Path(path_right),
362+
..
363+
}),
364+
)
365+
| (
366+
PatKind::Expr(PatExpr {
367+
kind: PatExprKind::Path(path_left),
368+
..
369+
}),
370+
PatKind::TupleStruct(path_right, patterns, _),
371+
) if patterns.len() == 1 => {
358372
if let PatKind::Wild = patterns[0].kind {
359373
find_good_method_for_match(
360374
cx,
@@ -389,7 +403,13 @@ fn found_good_method<'tcx>(
389403
None
390404
}
391405
},
392-
(PatKind::Path(path_left), PatKind::Wild) => get_good_method(cx, arms, path_left),
406+
(
407+
PatKind::Expr(PatExpr {
408+
kind: PatExprKind::Path(path_left),
409+
..
410+
}),
411+
PatKind::Wild,
412+
) => get_good_method(cx, arms, path_left),
393413
_ => None,
394414
}
395415
}

clippy_lints/src/matches/single_match.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn report_single_pattern(cx: &LateContext<'_>, ex: &Expr<'_>, arm: &Arm<'_>, exp
114114
}
115115

116116
let (pat, pat_ref_count) = peel_hir_pat_refs(arm.pat);
117-
let (msg, sugg) = if let PatKind::Path(_) | PatKind::Expr(_) = pat.kind
117+
let (msg, sugg) = if let PatKind::Expr(_) = pat.kind
118118
&& let (ty, ty_ref_count) = peel_middle_ty_refs(cx.typeck_results().expr_ty(ex))
119119
&& let Some(spe_trait_id) = cx.tcx.lang_items().structural_peq_trait()
120120
&& let Some(pe_trait_id) = cx.tcx.lang_items().eq_trait()
@@ -331,14 +331,16 @@ impl<'a> PatState<'a> {
331331
#[expect(clippy::similar_names)]
332332
fn add_pat<'tcx>(&mut self, cx: &'a PatCtxt<'tcx>, pat: &'tcx Pat<'_>) -> bool {
333333
match pat.kind {
334-
PatKind::Path(_)
335-
if match *cx.typeck.pat_ty(pat).peel_refs().kind() {
336-
ty::Adt(adt, _) => adt.is_enum() || (adt.is_struct() && !adt.non_enum_variant().fields.is_empty()),
337-
ty::Tuple(tys) => !tys.is_empty(),
338-
ty::Array(_, len) => len.try_to_target_usize(cx.tcx) != Some(1),
339-
ty::Slice(..) => true,
340-
_ => false,
341-
} =>
334+
PatKind::Expr(PatExpr {
335+
kind: PatExprKind::Path(_),
336+
..
337+
}) if match *cx.typeck.pat_ty(pat).peel_refs().kind() {
338+
ty::Adt(adt, _) => adt.is_enum() || (adt.is_struct() && !adt.non_enum_variant().fields.is_empty()),
339+
ty::Tuple(tys) => !tys.is_empty(),
340+
ty::Array(_, len) => len.try_to_target_usize(cx.tcx) != Some(1),
341+
ty::Slice(..) => true,
342+
_ => false,
343+
} =>
342344
{
343345
matches!(self, Self::Wild)
344346
},
@@ -386,7 +388,6 @@ impl<'a> PatState<'a> {
386388
| PatKind::Binding(_, _, _, None)
387389
| PatKind::Expr(_)
388390
| PatKind::Range(..)
389-
| PatKind::Path(_)
390391
| PatKind::Never
391392
| PatKind::Err(_) => {
392393
*self = PatState::Wild;

clippy_lints/src/option_if_let_else.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use clippy_utils::{
77
use rustc_errors::Applicability;
88
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk};
99
use rustc_hir::def::Res;
10-
use rustc_hir::{Arm, BindingMode, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp};
10+
use rustc_hir::{
11+
Arm, BindingMode, Expr, ExprKind, MatchSource, Mutability, Pat, PatExpr, PatExprKind, PatKind, Path, QPath, UnOp,
12+
};
1113
use rustc_lint::{LateContext, LateLintPass};
1214
use rustc_session::declare_lint_pass;
1315
use rustc_span::SyntaxContext;
@@ -281,7 +283,11 @@ fn try_convert_match<'tcx>(
281283

282284
fn is_none_or_err_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
283285
match arm.pat.kind {
284-
PatKind::Path(ref qpath) => is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), OptionNone),
286+
PatKind::Expr(PatExpr {
287+
kind: PatExprKind::Path(qpath),
288+
hir_id,
289+
..
290+
}) => is_res_lang_ctor(cx, cx.qpath_res(qpath, *hir_id), OptionNone),
285291
PatKind::TupleStruct(ref qpath, [first_pat], _) => {
286292
is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), ResultErr)
287293
&& matches!(first_pat.kind, PatKind::Wild)

clippy_lints/src/use_self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir::def_id::LocalDefId;
1010
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty};
1111
use rustc_hir::{
1212
self as hir, AmbigArg, Expr, ExprKind, FnRetTy, FnSig, GenericArgsParentheses, GenericParam, GenericParamKind,
13-
HirId, Impl, ImplItemKind, Item, ItemKind, Pat, PatKind, Path, QPath, Ty, TyKind,
13+
HirId, Impl, ImplItemKind, Item, ItemKind, Pat, PatExpr, PatExprKind, PatKind, Path, QPath, Ty, TyKind,
1414
};
1515
use rustc_hir_analysis::lower_ty;
1616
use rustc_lint::{LateContext, LateLintPass};
@@ -258,7 +258,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
258258
&& self.msrv.meets(msrvs::TYPE_ALIAS_ENUM_VARIANTS)
259259
&& let Some(&StackItem::Check { impl_id, .. }) = self.stack.last()
260260
// get the path from the pattern
261-
&& let PatKind::Path(QPath::Resolved(_, path))
261+
&& let PatKind::Expr(&PatExpr { kind: PatExprKind::Path(QPath::Resolved(_, path)), .. })
262262
| PatKind::TupleStruct(QPath::Resolved(_, path), _, _)
263263
| PatKind::Struct(QPath::Resolved(_, path), _, _) = pat.kind
264264
&& cx.typeck_results().pat_ty(pat) == cx.tcx.type_of(impl_id).instantiate_identity()

clippy_lints/src/utils/author.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,6 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
708708
self.qpath(qpath);
709709
self.slice(fields, |pat| self.pat(pat));
710710
},
711-
PatKind::Path(ref qpath) => {
712-
bind!(self, qpath);
713-
kind!("Path(ref {qpath})");
714-
self.qpath(qpath);
715-
},
716711
PatKind::Tuple(fields, skip_pos) => {
717712
bind!(self, fields);
718713
kind!("Tuple({fields}, {skip_pos:?})");

0 commit comments

Comments
 (0)