From 852f1e3177ff6e61d35fd42ec3bd7ce19100653a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 19 Sep 2024 18:04:39 +0200 Subject: [PATCH] Don't emit if literal comes from macro expansion --- clippy_lints/src/literal_string_with_formatting_arg.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clippy_lints/src/literal_string_with_formatting_arg.rs b/clippy_lints/src/literal_string_with_formatting_arg.rs index 2938ff3772fd..a05ca4a2681b 100644 --- a/clippy_lints/src/literal_string_with_formatting_arg.rs +++ b/clippy_lints/src/literal_string_with_formatting_arg.rs @@ -37,6 +37,9 @@ declare_lint_pass!(LiteralStringWithFormattingArg => [LITERAL_STRING_WITH_FORMAT impl EarlyLintPass for LiteralStringWithFormattingArg { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { + if expr.span.from_expansion() { + return; + } if let ExprKind::Lit(lit) = expr.kind { let add = match lit.kind { LitKind::Str => 1,