about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-12 16:43:14 +0000
committerbors <bors@rust-lang.org>2023-09-12 16:43:14 +0000
commitb788addfcc955368b9771b77d312c248fab60253 (patch)
tree2ce969415025fe2c5696f1e8bda6a7e8831d7ba1
parentcb057019d46b823f142b6cc201319586e61471a8 (diff)
parentcc8c0e00991ccf692b9b12bf887cefac99fffa04 (diff)
downloadrust-b788addfcc955368b9771b77d312c248fab60253.tar.gz
rust-b788addfcc955368b9771b77d312c248fab60253.zip
Auto merge of #11473 - Alexendoo:format-args-span-parents, r=dswij
Ignore span's parents in `collect_ast_format_args`/`find_format_args`

Fixes #11470, covers some cases missed by #10980

Can't have a test yet because of #11126 but it works locally

changelog: none

r? `@dswij`
-rw-r--r--clippy_utils/src/macros.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/clippy_utils/src/macros.rs b/clippy_utils/src/macros.rs
index 173f9841d44..98724fcbe96 100644
--- a/clippy_utils/src/macros.rs
+++ b/clippy_utils/src/macros.rs
@@ -389,7 +389,9 @@ thread_local! {
 /// `FormatArgsCollector`
 pub fn collect_ast_format_args(span: Span, format_args: &FormatArgs) {
     AST_FORMAT_ARGS.with(|ast_format_args| {
-        ast_format_args.borrow_mut().insert(span, format_args.clone());
+        ast_format_args
+            .borrow_mut()
+            .insert(span.with_parent(None), format_args.clone());
     });
 }
 
@@ -414,7 +416,7 @@ pub fn find_format_args(cx: &LateContext<'_>, start: &Expr<'_>, expn_id: ExpnId,
 
     if let Some(expr) = format_args_expr {
         AST_FORMAT_ARGS.with(|ast_format_args| {
-            ast_format_args.borrow().get(&expr.span).map(callback);
+            ast_format_args.borrow().get(&expr.span.with_parent(None)).map(callback);
         });
     }
 }