rust: allow `unknown_lints` in generated bindings for Rust < 1.88
Subsystems (3)
Miguel Ojeda
maintainerPATCH 1/1 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.
--- rust/bindings/lib.rs | 1 + rust/uapi/lib.rs | 1 + 2 files changed, 2 insertions(+)
rust/bindings/lib.rs +1 -0
@@ -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,
rust/uapi/lib.rs +1 -0
@@ -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
Signature · 1 line
2.55.0
Gary Guo
reviewerQuoted 37 lines · Miguel Ojeda
Starting with bindgen 0.73.2 [1],
#[allow(unnecessary_transmutes)]are used, even when--rust-target 1.85is 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_lintsin 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
bindgenuses such attributes, or whether it is an oversight.Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).Cc Emilio Cobos Álvarez <[email protected]>Assisted-by LLMSigned-off-by Miguel Ojeda <[email protected]>--- rust/bindings/lib.rs | 1 + rust/uapi/lib.rs | 1 + 2 files changed, 2 insertions(+)rust/bindings/lib.rs +0
-0
rust/bindings/lib.rs line 31
Quoted 5 lines
rust/bindings/lib.rs +1
-0@@ -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
Quoted 16 lines
rust/bindings/lib.rs +0
-0#[cfg_attr( CONFIG_RUSTC_HAS_SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,rust/uapi/lib.rs +1
-0@@ -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
Quoted 2 lines · Gary Guo
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
Quoted 23 lines · Miguel Ojeda
Starting with bindgen 0.73.2 [1],
#[allow(unnecessary_transmutes)]are used, even when--rust-target 1.85is 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_lintsin 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
bindgenuses such attributes, or whether it is an oversight.
Quoted 5 lines
Cc [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs).Cc Emilio Cobos Álvarez <[email protected]>Assisted-by LLMSigned-off-by Miguel Ojeda <[email protected]>
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