Skip to content

Commit 27d5f5c

Browse files
committed
inline is_if_let into all callers
1 parent 62e1225 commit 27d5f5c

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

clippy_lints/src/matches/match_like_matches.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub(crate) fn check_if_let<'tcx>(
2222
else_expr: &'tcx Expr<'_>,
2323
) {
2424
let mut arms = [(Some(let_pat), then_expr), (None, else_expr)].into_iter();
25-
let is_if_let = true;
2625
if !span_contains_comment(cx.sess().source_map(), expr.span)
2726
&& cx.typeck_results().expr_ty(expr).is_bool()
2827
&& let Some((None, else_expr)) = arms.next_back()
@@ -66,10 +65,7 @@ pub(crate) fn check_if_let<'tcx>(
6665
cx,
6766
MATCH_LIKE_MATCHES_MACRO,
6867
expr.span,
69-
format!(
70-
"{} expression looks like `matches!` macro",
71-
if is_if_let { "if let .. else" } else { "match" }
72-
),
68+
"if let .. else expression looks like `matches!` macro",
7369
"try",
7470
format!(
7571
"{}matches!({}, {pat_and_guard})",
@@ -93,18 +89,11 @@ pub(super) fn check_match<'tcx>(
9389
arms.iter()
9490
.map(|arm| (cx.tcx.hir_attrs(arm.hir_id), Some(arm.pat), arm.body, arm.guard)),
9591
e,
96-
false,
9792
)
9893
}
9994

10095
/// Lint a `match` or `if let` for replacement by `matches!`
101-
fn find_matches_sugg<'a, 'b, I>(
102-
cx: &LateContext<'_>,
103-
ex: &Expr<'_>,
104-
mut arms: I,
105-
expr: &Expr<'_>,
106-
is_if_let: bool,
107-
) -> bool
96+
fn find_matches_sugg<'a, 'b, I>(cx: &LateContext<'_>, ex: &Expr<'_>, mut arms: I, expr: &Expr<'_>) -> bool
10897
where
10998
'b: 'a,
11099
I: Clone
@@ -172,10 +161,7 @@ where
172161
cx,
173162
MATCH_LIKE_MATCHES_MACRO,
174163
expr.span,
175-
format!(
176-
"{} expression looks like `matches!` macro",
177-
if is_if_let { "if let .. else" } else { "match" }
178-
),
164+
"match expression looks like `matches!` macro",
179165
"try",
180166
format!(
181167
"{}matches!({}, {pat_and_guard})",

0 commit comments

Comments
 (0)