Ignore span's parents in collect_ast_format_args/find_format_args

This commit is contained in:
Alex Macleod 2023-09-08 12:40:21 +00:00
parent 253f1c410b
commit cc8c0e0099

View File

@ -389,7 +389,9 @@ fn is_assert_arg(cx: &LateContext<'_>, expr: &Expr<'_>, assert_expn: ExpnId) ->
/// `FormatArgsCollector` /// `FormatArgsCollector`
pub fn collect_ast_format_args(span: Span, format_args: &FormatArgs) { pub fn collect_ast_format_args(span: Span, format_args: &FormatArgs) {
AST_FORMAT_ARGS.with(|ast_format_args| { 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 { if let Some(expr) = format_args_expr {
AST_FORMAT_ARGS.with(|ast_format_args| { 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);
}); });
} }
} }