Skip to content

Commit f095fd7

Browse files
committed
clean-up
1 parent c48592e commit f095fd7

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::res::MaybeDef;
43
use rustc_hir::{AssignOpKind, Expr, ExprKind, LangItem, MatchSource};
54
use rustc_lint::{LateContext, LateLintPass};
@@ -49,22 +48,15 @@ fn is_string(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
4948
fn is_format(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
5049
let e = e.peel_blocks().peel_borrows();
5150

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

0 commit comments

Comments
 (0)