From 42fc5aee6499ed6f7d1fca0d2fbac1515291b978 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 4 Jun 2025 11:54:20 +0200 Subject: [PATCH] Fix span of AddrOf in format_args!() expansion. Diagnostics should know that the `&` for arguments in format_args!() come from the macro expansion rather than from the original source. --- compiler/rustc_ast_lowering/src/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 4138cc426c75..7a4e056175c0 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -489,7 +489,7 @@ fn expand_format_args<'hir>( let placeholder_span = placeholder_span.unwrap_or(arg.expr.span).with_ctxt(macsp.ctxt()); let arg = ctx.lower_expr(&arg.expr); - let ref_arg = ctx.arena.alloc(ctx.expr_ref(arg.span, arg)); + let ref_arg = ctx.arena.alloc(ctx.expr_ref(arg.span.with_ctxt(macsp.ctxt()), arg)); make_argument(ctx, placeholder_span, ref_arg, ty) }, ));