Skip to contentSkip to conversation

FAILED: patch "[PATCH] rust: allow `clippy::as_underscore` in the generated bindings" failed to apply to 6.12-stable tree

PATCH [email protected] 3 participants 3 messages Sep 16 – Sep 18

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 2ac74c6db40adaa29c50cbb281ae9a6f63de18e1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026091618-barrier-dexterous-aa2d@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 2ac74c6db40adaa29c50cbb281ae9a6f63de18e1 Mon Sep 17 00:00:00 2001
From: John Hubbard <[email protected]>
Date: Sun, 6 Sep 2026 14:58:22 -0700
Subject: [PATCH] rust: allow clippy::as_underscore in the generated bindings

A CLIPPY=1 build emitted about 15000 as _ conversion warnings, all of them in bindgen's generated output and none in hand-written code.

[ 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 ]

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.

Allow clippy::as_underscore by name in the bindings and uapi crates.

Assisted-by LLM
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).
[ Removed CI sentence. - Miguel ]
rust/bindings/lib.rs +1 -0
index 812f8e5a08d5..ad24c920b919 100644
@@ -22,6 +22,7 @@
 #![feature(cfi_encoding)]
 
 #[allow(dead_code)]
+#[allow(clippy::as_underscore)]
 #[allow(clippy::cast_lossless)]
 #[allow(clippy::ptr_as_ptr)]
 #[allow(clippy::ref_as_ptr)]
rust/uapi/lib.rs +1 -0
index 797ead5b5626..2df0340e63d1 100644
@@ -10,6 +10,7 @@
 #![no_std]
 #![allow(
     clippy::all,
+    clippy::as_underscore,
     clippy::cast_lossless,
     clippy::ptr_as_ptr,
     clippy::ref_as_ptr,
#1 lore raw
Quoted 2 lines · On 9/16/26 2:13 AM, [email protected] wrote:

The patch below does not apply to the 6.12-stable tree.

Please drop it from 6.12.y instead of backporting it. It would be a no-op there, and my Cc: stable line was too broad.

clippy::as_underscore is a restriction lint, so it stays off unless the build enables it, and 6.12.y never enables it. A CLIPPY=1 build there cannot emit the warnings this patch silences. The flag arrived with commit 5e30550558b1 ("rust: enable clippy::as_underscore lint") in v6.17:

  $ git grep -l Wclippy::as_underscore v6.12.110
  $ git grep -l Wclippy::as_underscore v6.17.13
  v6.17.13:Makefile

The conflict has the same root: the patch wants the allow() lines for cast_lossless, ptr_as_ptr, and ref_as_ptr as context, and those only exist in trees that enable those lints.

The tag should have said "Needed in 6.17.y and later". Sorry for the noise.

thanks,

Signature · 1 line
John Hubbard
Quoted 85 lines

If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 2ac74c6db40adaa29c50cbb281ae9a6f63de18e1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026091618-barrier-dexterous-aa2d@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 2ac74c6db40adaa29c50cbb281ae9a6f63de18e1 Mon Sep 17 00:00:00 2001
From: John Hubbard <[email protected]>
Date: Sun, 6 Sep 2026 14:58:22 -0700
Subject: [PATCH] rust: allow clippy::as_underscore in the generated bindings

A CLIPPY=1 build emitted about 15000 as _ conversion warnings, all of them in bindgen's generated output and none in hand-written code.

[ 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 ]

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.

Allow clippy::as_underscore by name in the bindings and uapi crates.

Assisted-by LLM
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).
[ Removed CI sentence. - Miguel ]
rust/bindings/lib.rs +1 -0
index 812f8e5a08d5..ad24c920b919 100644
@@ -22,6 +22,7 @@
 #![feature(cfi_encoding)]
 
 #[allow(dead_code)]
+#[allow(clippy::as_underscore)]
 #[allow(clippy::cast_lossless)]
 #[allow(clippy::ptr_as_ptr)]
 #[allow(clippy::ref_as_ptr)]
rust/uapi/lib.rs +1 -0
index 797ead5b5626..2df0340e63d1 100644
@@ -10,6 +10,7 @@
 #![no_std]
 #![allow(
     clippy::all,
+    clippy::as_underscore,
     clippy::cast_lossless,
     clippy::ptr_as_ptr,
     clippy::ref_as_ptr,
maintainer
#2 lore raw
Quoted 2 lines

Please drop it from 6.12.y instead of backporting it. It would be a no-op there, and my Cc: stable line was too broad.

Dropped, nothing is queued for 6.12.y.

Signature · 2 lines
Thanks,
Sasha