Re: [PATCH] rust: fix formatting expressions
From: Janne Grunau
Date: Sun Jan 04 2026 - 08:05:18 EST
On Sun, Jan 04, 2026 at 08:00:27AM -0500, Tamir Duberstein wrote:
> From: Tamir Duberstein <tamird@xxxxxxxxx>
>
> Allow usage like `pr_info!("one + 1 = {}", one + 1)` to compile by
> ensuring that a reference is taken to the entire expression.
>
> Fixes: c5cf01ba8dfe ("rust: support formatting of foreign types")
> Reported-by: Janne Grunau <j@xxxxxxxxxx>
> Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Custom.20formatting/near/566219493
> ---
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
> ---
> rust/macros/fmt.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/macros/fmt.rs b/rust/macros/fmt.rs
> index 2f4b9f6e2211..8354abd54502 100644
> --- a/rust/macros/fmt.rs
> +++ b/rust/macros/fmt.rs
> @@ -67,7 +67,7 @@ pub(crate) fn fmt(input: TokenStream) -> TokenStream {
> }
> (None, acc)
> })();
> - args.extend(quote_spanned!(first_span => #lhs #adapter(&#rhs)));
> + args.extend(quote_spanned!(first_span => #lhs #adapter(&(#rhs))));
> }
> };
>
thanks, this fixes the trivial example I added to rust_minimal.rs and
all out-of-tree use in the asahi driver where I discovered the issue.
Tested-by: Janne Grunau <j@xxxxxxxxxx>
Reviewed-by: Janne Grunau <j@xxxxxxxxxx>
Janne