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

Commit 0faf8c7

Browse files
committed
Rename PatKind::Lit to Expr
1 parent 28d2363 commit 0faf8c7

21 files changed

+34
-34
lines changed

clippy_lints/src/default_numeric_fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<'tcx> Visitor<'tcx> for NumericFallbackVisitor<'_, 'tcx> {
224224

225225
fn visit_pat(&mut self, pat: &'tcx Pat<'_>) {
226226
match pat.kind {
227-
PatKind::Lit(&PatExpr {
227+
PatKind::Expr(&PatExpr {
228228
hir_id,
229229
kind: PatExprKind::Lit { lit, .. },
230230
..

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::Lit(_) => true,
59+
PatKind::Path(_) | PatKind::Expr(_) => true,
6060
}
6161
}
6262

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
163163
if let ExprKind::Let(lt) = expr.kind
164164
&& match lt.pat.kind {
165165
PatKind::Slice([], None, []) => true,
166-
PatKind::Lit(lit) => match lit.kind {
166+
PatKind::Expr(lit) => match lit.kind {
167167
PatExprKind::Lit { lit, .. } => match lit.node {
168168
LitKind::Str(lit, _) => lit.as_str().is_empty(),
169169
_ => false,

clippy_lints/src/manual_range_patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl LateLintPass<'_> for ManualRangePatterns {
8989
let mut ranges_found = Vec::new();
9090

9191
for pat in pats {
92-
if let PatKind::Lit(lit) = pat.kind
92+
if let PatKind::Expr(lit) = pat.kind
9393
&& let Some(num) = Num::new(lit)
9494
{
9595
numbers_found.insert(num.val);

clippy_lints/src/matches/match_bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) fn check(cx: &LateContext<'_>, scrutinee: &Expr<'_>, arms: &[Arm<'_>]
2121
move |diag| {
2222
if arms.len() == 2 {
2323
// no guards
24-
let exprs = if let PatKind::Lit(arm_bool) = arms[0].pat.kind {
24+
let exprs = if let PatKind::Expr(arm_bool) = arms[0].pat.kind {
2525
if let PatExprKind::Lit { lit, .. } = arm_bool.kind {
2626
match lit.node {
2727
LitKind::Bool(true) => Some((arms[0].body, arms[1].body)),

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 3 additions & 3 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, PatExprKind, HirId, HirIdMap, HirIdMapEntry, HirIdSet, Pat, PatKind, RangeEnd};
10+
use rustc_hir::{Arm, Expr, HirId, HirIdMap, HirIdMapEntry, HirIdSet, Pat, PatExprKind, PatKind, RangeEnd};
1111
use rustc_lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
1212
use rustc_lint::{LateContext, LintContext};
1313
use rustc_middle::ty;
@@ -311,9 +311,9 @@ impl<'a> NormalizedPat<'a> {
311311
);
312312
Self::Tuple(None, pats)
313313
},
314-
PatKind::Lit(e) => match &e.kind {
314+
PatKind::Expr(e) => match &e.kind {
315315
// TODO: Handle negative integers. They're currently treated as a wild match.
316-
PatExprKind::Lit{ lit, negated: false } => match lit.node {
316+
PatExprKind::Lit { lit, negated: false } => match lit.node {
317317
LitKind::Str(sym, _) => Self::LitStr(sym),
318318
LitKind::ByteStr(ref bytes, _) | LitKind::CStr(ref bytes, _) => Self::LitBytes(bytes),
319319
LitKind::Byte(val) => Self::LitInt(val.into()),

clippy_lints/src/matches/match_str_case_mismatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn verify_case<'a>(case_method: &'a CaseMethod, arms: &'a [Arm<'_>]) -> Option<(
8585
};
8686

8787
for arm in arms {
88-
if let PatKind::Lit(PatExpr {
88+
if let PatKind::Expr(PatExpr {
8989
kind: PatExprKind::Lit { lit, negated: false },
9090
..
9191
}) = arm.pat.kind

clippy_lints/src/matches/needless_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fn pat_same_as_expr(pat: &Pat<'_>, expr: &Expr<'_>) -> bool {
189189
});
190190
},
191191
// Example: `5 => 5`
192-
(PatKind::Lit(pat_expr_expr), ExprKind::Lit(expr_spanned)) => {
192+
(PatKind::Expr(pat_expr_expr), ExprKind::Lit(expr_spanned)) => {
193193
if let PatExprKind::Lit {
194194
lit: pat_spanned,
195195
negated: false,

clippy_lints/src/matches/overlapping_arms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn all_ranges<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], ty: Ty<'tcx>)
5757
});
5858
}
5959

60-
if let PatKind::Lit(value) = pat.kind {
60+
if let PatKind::Expr(value) = pat.kind {
6161
let value = ConstEvalCtxt::new(cx)
6262
.eval_pat_expr(value)?
6363
.int_value(cx.tcx, cx.typeck_results().node_type(pat.hir_id))?;

clippy_lints/src/matches/redundant_pattern_match.rs

Lines changed: 3 additions & 3 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, PatKind, QPath, UnOp, PatExprKind};
12+
use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatExprKind, PatKind, QPath, UnOp};
1313
use rustc_lint::LateContext;
1414
use rustc_middle::ty::{self, GenericArgKind, Ty};
1515
use rustc_span::{Span, Symbol, sym};
@@ -74,8 +74,8 @@ fn find_match_true<'tcx>(
7474
span: Span,
7575
message: &'static str,
7676
) {
77-
if let PatKind::Lit(lit) = pat.kind
78-
&& let PatExprKind::Lit{ lit, negated: false } = lit.kind
77+
if let PatKind::Expr(lit) = pat.kind
78+
&& let PatExprKind::Lit { lit, negated: false } = lit.kind
7979
&& let LitKind::Bool(pat_is_true) = lit.node
8080
{
8181
let mut applicability = Applicability::MachineApplicable;

0 commit comments

Comments
 (0)