From cc8c0e00991ccf692b9b12bf887cefac99fffa04 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Fri, 8 Sep 2023 12:40:21 +0000 Subject: [PATCH] Ignore span's parents in `collect_ast_format_args`/`find_format_args` --- clippy_utils/src/macros.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clippy_utils/src/macros.rs b/clippy_utils/src/macros.rs index 173f9841d446..98724fcbe96a 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); }); } }