Skip to content

Commit 4a14995

Browse files
committed
clean-up
1 parent 2dc84cb commit 4a14995

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

clippy_lints/src/format_push_string.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
2-
use clippy_utils::higher;
32
use clippy_utils::ty::is_type_lang_item;
43
use rustc_hir::{AssignOpKind, Expr, ExprKind, LangItem, MatchSource};
54
use rustc_lint::{LateContext, LateLintPass};
@@ -46,22 +45,15 @@ fn is_string(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
4645
fn is_format(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
4746
let e = e.peel_blocks().peel_borrows();
4847

49-
if e.span.from_expansion()
50-
&& let Some(macro_def_id) = e.span.ctxt().outer_expn_data().macro_def_id
51-
{
52-
cx.tcx.get_diagnostic_name(macro_def_id) == Some(sym::format_macro)
53-
} else if let Some(higher::If { then, r#else, .. }) = higher::If::hir(e) {
54-
is_format(cx, then) || r#else.is_some_and(|e| is_format(cx, e))
55-
} else {
56-
match higher::IfLetOrMatch::parse(cx, e) {
57-
Some(higher::IfLetOrMatch::Match(_, arms, MatchSource::Normal)) => {
58-
arms.iter().any(|arm| is_format(cx, arm.body))
59-
},
60-
Some(higher::IfLetOrMatch::IfLet(_, _, then, r#else, _)) => {
61-
is_format(cx, then) || r#else.is_some_and(|e| is_format(cx, e))
62-
},
63-
_ => false,
64-
}
48+
match e.kind {
49+
_ if e.span.from_expansion()
50+
&& let Some(macro_def_id) = e.span.ctxt().outer_expn_data().macro_def_id =>
51+
{
52+
cx.tcx.is_diagnostic_item(sym::format_macro, macro_def_id)
53+
},
54+
ExprKind::Match(_, arms, MatchSource::Normal) => arms.iter().any(|arm| is_format(cx, arm.body)),
55+
ExprKind::If(_, then, els) => is_format(cx, then) || els.is_some_and(|e| is_format(cx, e)),
56+
_ => false,
6557
}
6658
}
6759

0 commit comments

Comments
 (0)