Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88
@ 2026-09-08 17:05 Miguel Ojeda
  2026-09-08 20:54 ` Gary Guo
  2026-09-08 21:35 ` Miguel Ojeda
  0 siblings, 2 replies; 4+ messages in thread
From: Miguel Ojeda @ 2026-09-08 17:05 UTC (permalink / raw)
  To: Miguel Ojeda, Nathan Chancellor, Nicolas Schier
  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, rust-for-linux, linux-kbuild, stable,
	Emilio Cobos Álvarez

Starting with bindgen 0.73.2 [1], `#[allow(unnecessary_transmutes)]`
are used, even when `--rust-target 1.85` is passed.

However, the lint was introduced in Rust 1.88.0. Thus building with
older Rust versions warns like:

    error: unknown lint: `unnecessary_transmutes`
         --> rust/uapi/uapi_generated.rs:26294:13
          |
    26294 |     #[allow(unnecessary_transmutes)]
          |             ^^^^^^^^^^^^^^^^^^^^^^
          |
          = note: `-D unknown-lints` implied by `-D warnings`
          = help: to override `-D warnings` add `#[allow(unknown_lints)]`

Thus allow `unknown_lints` in the generated bindings -- only when building
with older Rust versions.

I have asked upstream if this is intentional [1], i.e. if we are supposed
to always allow unknown lints in case `bindgen` uses such attributes,
or whether it is an oversight.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Cc: Emilio Cobos Álvarez <emilio@crisal.io>
Link: https://github.com/rust-lang/rust-bindgen/pull/3455 [1]
Assisted-by: LLM
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/bindings/lib.rs | 1 +
 rust/uapi/lib.rs     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/rust/bindings/lib.rs b/rust/bindings/lib.rs
index ad24c920b919..9e2c9a8e7e6c 100644
--- a/rust/bindings/lib.rs
+++ b/rust/bindings/lib.rs
@@ -27,6 +27,7 @@
 #[allow(clippy::ptr_as_ptr)]
 #[allow(clippy::ref_as_ptr)]
 #[allow(clippy::undocumented_unsafe_blocks)]
+#[cfg_attr(not(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES), 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 2df0340e63d1..c1e27192ecce 100644
--- a/rust/uapi/lib.rs
+++ b/rust/uapi/lib.rs
@@ -24,6 +24,7 @@
     unreachable_pub,
     unsafe_op_in_unsafe_fn
 )]
+#![cfg_attr(not(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES), allow(unknown_lints))]
 #![cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
 #![cfg_attr(
     CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,

base-commit: 2ac74c6db40adaa29c50cbb281ae9a6f63de18e1
-- 
2.55.0


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

* Re: [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88
  2026-09-08 17:05 [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88 Miguel Ojeda
@ 2026-09-08 20:54 ` Gary Guo
  2026-09-08 21:23   ` Miguel Ojeda
  2026-09-08 21:35 ` Miguel Ojeda
  1 sibling, 1 reply; 4+ messages in thread
From: Gary Guo @ 2026-09-08 20:54 UTC (permalink / raw)
  To: Miguel Ojeda, Nathan Chancellor, Nicolas Schier
  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, rust-for-linux, linux-kbuild, stable,
	Emilio Cobos Álvarez

On Tue Sep 8, 2026 at 6:05 PM BST, Miguel Ojeda wrote:
> Starting with bindgen 0.73.2 [1], `#[allow(unnecessary_transmutes)]`
> are used, even when `--rust-target 1.85` is passed.
>
> However, the lint was introduced in Rust 1.88.0. Thus building with
> older Rust versions warns like:
>
>     error: unknown lint: `unnecessary_transmutes`
>          --> rust/uapi/uapi_generated.rs:26294:13
>           |
>     26294 |     #[allow(unnecessary_transmutes)]
>           |             ^^^^^^^^^^^^^^^^^^^^^^
>           |
>           = note: `-D unknown-lints` implied by `-D warnings`
>           = help: to override `-D warnings` add `#[allow(unknown_lints)]`
>
> Thus allow `unknown_lints` in the generated bindings -- only when building
> with older Rust versions.
>
> I have asked upstream if this is intentional [1], i.e. if we are supposed
> to always allow unknown lints in case `bindgen` uses such attributes,
> or whether it is an oversight.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Cc: Emilio Cobos Álvarez <emilio@crisal.io>
> Link: https://github.com/rust-lang/rust-bindgen/pull/3455 [1]
> Assisted-by: LLM
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
>  rust/bindings/lib.rs | 1 +
>  rust/uapi/lib.rs     | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/rust/bindings/lib.rs b/rust/bindings/lib.rs
> index ad24c920b919..9e2c9a8e7e6c 100644
> --- a/rust/bindings/lib.rs
> +++ b/rust/bindings/lib.rs
> @@ -27,6 +27,7 @@
>  #[allow(clippy::ptr_as_ptr)]
>  #[allow(clippy::ref_as_ptr)]
>  #[allow(clippy::undocumented_unsafe_blocks)]
> +#[cfg_attr(not(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES), allow(unknown_lints))]
>  #[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]

I think we can drop the cfg on the `allow(unnecessary_transmutes)`.

Best,
Gary

>  #[cfg_attr(
>      CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
> diff --git a/rust/uapi/lib.rs b/rust/uapi/lib.rs
> index 2df0340e63d1..c1e27192ecce 100644
> --- a/rust/uapi/lib.rs
> +++ b/rust/uapi/lib.rs
> @@ -24,6 +24,7 @@
>      unreachable_pub,
>      unsafe_op_in_unsafe_fn
>  )]
> +#![cfg_attr(not(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES), allow(unknown_lints))]
>  #![cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
>  #![cfg_attr(
>      CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
>
> base-commit: 2ac74c6db40adaa29c50cbb281ae9a6f63de18e1



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

* Re: [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88
  2026-09-08 20:54 ` Gary Guo
@ 2026-09-08 21:23   ` Miguel Ojeda
  0 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2026-09-08 21:23 UTC (permalink / raw)
  To: Gary Guo
  Cc: Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, rust-for-linux, linux-kbuild,
	stable, Emilio Cobos Álvarez

On Tue, Sep 8, 2026 at 10:54 PM Gary Guo <gary@garyguo.net> wrote:
>
> I think we can drop the cfg on the `allow(unnecessary_transmutes)`.

Yeah, you are right. Perhaps it could have been temporary with a quick
0.73.3, but Emilio replied already.

Cheers,
Miguel

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

* Re: [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88
  2026-09-08 17:05 [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88 Miguel Ojeda
  2026-09-08 20:54 ` Gary Guo
@ 2026-09-08 21:35 ` Miguel Ojeda
  1 sibling, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2026-09-08 21:35 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Nathan Chancellor, Nicolas Schier, 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, rust-for-linux, linux-kbuild,
	stable, Emilio Cobos Álvarez

On Tue, Sep 8, 2026 at 7:06 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with bindgen 0.73.2 [1], `#[allow(unnecessary_transmutes)]`
> are used, even when `--rust-target 1.85` is passed.
>
> However, the lint was introduced in Rust 1.88.0. Thus building with
> older Rust versions warns like:
>
>     error: unknown lint: `unnecessary_transmutes`
>          --> rust/uapi/uapi_generated.rs:26294:13
>           |
>     26294 |     #[allow(unnecessary_transmutes)]
>           |             ^^^^^^^^^^^^^^^^^^^^^^
>           |
>           = note: `-D unknown-lints` implied by `-D warnings`
>           = help: to override `-D warnings` add `#[allow(unknown_lints)]`
>
> Thus allow `unknown_lints` in the generated bindings -- only when building
> with older Rust versions.
>
> I have asked upstream if this is intentional [1], i.e. if we are supposed
> to always allow unknown lints in case `bindgen` uses such attributes,
> or whether it is an oversight.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Cc: Emilio Cobos Álvarez <emilio@crisal.io>
> Link: https://github.com/rust-lang/rust-bindgen/pull/3455 [1]
> Assisted-by: LLM
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Applied early to `rust-fixes`, but tags still welcome for a day or so -- thanks!

    [ Emilio said it wasn't intentional -- we will work around it for now
      on the kernel side. - Miguel ]

    [ Removed the `cfg` for `allow(unnecessary_transmutes)` as suggested by
      Gary. - Miguel ]

Cheers,
Miguel

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

end of thread, other threads:[~2026-09-08 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 17:05 [PATCH] rust: allow `unknown_lints` in generated bindings for Rust < 1.88 Miguel Ojeda
2026-09-08 20:54 ` Gary Guo
2026-09-08 21:23   ` Miguel Ojeda
2026-09-08 21:35 ` Miguel Ojeda

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