[PATCH] rust: allow `unknown_lints` in the generated bindings
From: John Hubbard
Date: Fri Sep 11 2026 - 15:56:53 EST
A build with bindgen 0.73.2 and the minimum supported rustc, 1.85.0,
emits about 12000 `unknown_lints` warnings, all of them in bindgen's
generated output. CONFIG_WERROR or W=e turns them into a failed build.
Starting with 0.73.0, bindgen writes `#[allow(unnecessary_transmutes)]`
onto every bitfield accessor and constructor it generates. It does so
regardless of `--rust-target`, which rust/Makefile already sets to 1.85.
That lint exists only since rustc 1.88.0.
Commit 7129ea6e242b ("rust: clean Rust 1.88.0's `unnecessary_transmutes`
lint") made the kernel's own attribute conditional, to keep
`unknown_lints` enabled. That condition cannot be put on an attribute
that bindgen writes.
Allow `unknown_lints` in the bindings and uapi crates.
Cc: stable@xxxxxxxxxxxxxxx # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Assisted-by: LLM
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
---
rust/bindings/lib.rs | 2 ++
rust/uapi/lib.rs | 2 ++
2 files changed, 4 insertions(+)
diff --git a/rust/bindings/lib.rs b/rust/bindings/lib.rs
index 812f8e5a08d5..a3af57d7d137 100644
--- a/rust/bindings/lib.rs
+++ b/rust/bindings/lib.rs
@@ -26,6 +26,8 @@
#[allow(clippy::ptr_as_ptr)]
#[allow(clippy::ref_as_ptr)]
#[allow(clippy::undocumented_unsafe_blocks)]
+// `bindgen` emits `#[allow(...)]` for lints newer than the minimum supported `rustc`.
+#[allow(unknown_lints)]
#[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
#[cfg_attr(
CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
diff --git a/rust/uapi/lib.rs b/rust/uapi/lib.rs
index 797ead5b5626..361b490acc25 100644
--- a/rust/uapi/lib.rs
+++ b/rust/uapi/lib.rs
@@ -23,6 +23,8 @@
unreachable_pub,
unsafe_op_in_unsafe_fn
)]
+// `bindgen` emits `#[allow(...)]` for lints newer than the minimum supported `rustc`.
+#![allow(unknown_lints)]
#![cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
#![cfg_attr(
CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
base-commit: 3026c6e4f223bdded6448fefe53ff85d9cbe51bd
--
2.55.0