Re: [PATCH 1/2] kbuild: rust: allow `clippy::uninlined_format_args`
From: Tamir Duberstein
Date: Thu Apr 09 2026 - 12:24:40 EST
On Fri, Apr 3, 2026 at 9:07 AM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Fri, Apr 3, 2026 at 12:25 PM Tamir Duberstein <tamird@xxxxxxxxxx> wrote:
> >
> > Seeing this patch a bit late but in clippy 1.85.0 there is
> > `#[clippy::format_args]` which would permit us to make the lint work
> > with our custom macros.
>
> +1, that may be good to consider, especially with the bump -- added
> and backlinked in:
>
> https://github.com/Rust-for-Linux/linux/issues/349
>
> Maybe an issue would be good to create too.
Turns out `#[clippy::format_args]` doesn't work for us due to the
`fmt!` proc-macro.
It seems the handling of `#[clippy::format_args]` is more
sophisticated than (at least I) expected: it doesn't blindly check the
inputs to annotated macros, but rather looks for the place where
`fmt::Arguments` are created.
In our case something like `pr_info!("{}", i)` ends up expanding to
`core::format_args!("{}", Adapter(&(i)))`, which does not trigger
`uninlined_format_args`.
We also cannot fix that just by having `fmt!` assign `Adapter(&(i))`
to a local variable and then return `fmt::Arguments`, since
`core::format_args!` borrows its arguments. The local would not live
long enough.
I filed this upstream as https://github.com/rust-lang/rust-clippy/issues/16833.