mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: allow `unknown_lints` in the generated bindings
@ 2026-09-11 19:52 John Hubbard
  2026-09-12 16:29 ` Gary Guo
  0 siblings, 1 reply; 2+ messages in thread
From: John Hubbard @ 2026-09-11 19:52 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, Greg Kroah-Hartman, rust-for-linux, LKML,
	John Hubbard, stable

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@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Assisted-by: LLM
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-12 16:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 19:52 [PATCH] rust: allow `unknown_lints` in the generated bindings John Hubbard
2026-09-12 16:29 ` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®