]> git.hungrycats.org Git - linux/commit
rust: allow `unknown_lints` in generated bindings for Rust < 1.88
authorMiguel Ojeda <ojeda@kernel.org>
Tue, 8 Sep 2026 17:05:39 +0000 (19:05 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 8 Sep 2026 21:29:18 +0000 (23:29 +0200)
commitf4c3e38111fd84c2c7ae5785755f4a4d476e1cba
tree77bc7040f10ddb91ccb20142a38fadb7ffc6af56
parent2ac74c6db40adaa29c50cbb281ae9a6f63de18e1
rust: allow `unknown_lints` in generated bindings for Rust < 1.88

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.

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

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#issuecomment-5588526559
Assisted-by: LLM
Link: https://patch.msgid.link/20260908170539.345207-1-ojeda@kernel.org
[ Removed the `cfg` for `allow(unnecessary_transmutes)` as suggested by
  Gary. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/bindings/lib.rs
rust/uapi/lib.rs