Re: [PATCH] rust: allow `clippy::as_underscore` in the generated bindings
From: Miguel Ojeda
Date: Sun Sep 06 2026 - 19:12:13 EST
On Sun, Sep 6, 2026 at 11:58 PM John Hubbard <jhubbard@xxxxxxxxxx> wrote:
>
> A CLIPPY=1 build emitted about 15000 `as _` conversion warnings, all of
> them in bindgen's generated output and none in hand-written code.
>
> bindgen 0.73 returns each bitfield read through a trailing `as _`, and
> 0.72 returns it through a transmute, which the lint ignores. The
> bindings and uapi crates allow `clippy::all` over the generated code.
> That group does not cover `clippy::as_underscore`, a restriction lint.
>
> The minimum supported bindgen is 0.71.1, and 0.72 does not emit the
> cast, so upstream CI may not see these warnings yet.
>
> Allow `clippy::as_underscore` by name in the bindings and uapi crates.
>
> Assisted-by: LLM
> Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
Applied to `rust-fixes` so that we get it into linux-next since this
sort of thing can be quite annoying -- thanks!
[ The lint messages look like:
error: using `as _` conversion
--> rust/bindings/bindings_generated.rs:18947:9
|
18947 | self._bitfield_1.get_const::<0usize, 16u8>() as u32 as _
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
|
help: consider giving the type explicitly: `u32`
|
= help: for further information visit
https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#as_underscore
= note: `-D clippy::as-underscore` implied by `-D warnings`
= help: to override `-D warnings` add
`#[allow(clippy::as_underscore)]`
- Miguel ]
[ Removed CI sentence. - Miguel ]
Cc: stable@xxxxxxxxxxxxxxx # Needed in 6.12.y and later (Rust is
pinned in older LTSs).
Technically it is not needed in 6.12.y since the lint is not enabled,
but it doesn't hurt, may help downstream trees and may simplify future
backports.
Cheers,
Miguel