* [PATCH 6.12.y] rust: init: allow `dead_code` warnings for Rust >= 1.89.0
@ 2025-07-12 17:10 Miguel Ojeda
2025-07-12 18:04 ` Benno Lossin
0 siblings, 1 reply; 3+ messages in thread
From: Miguel Ojeda @ 2025-07-12 17:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Sasha Levin, Miguel Ojeda, Alex Gaynor
Cc: stable, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
linux-kernel, patches, Benno Lossin
Starting with Rust 1.89.0 (expected 2025-08-07), the Rust compiler
may warn:
error: trait `MustNotImplDrop` is never used
--> rust/kernel/init/macros.rs:927:15
|
927 | trait MustNotImplDrop {}
| ^^^^^^^^^^^^^^^
|
::: rust/kernel/sync/arc.rs:133:1
|
133 | #[pin_data]
| ----------- in this procedural macro expansion
|
= note: `-D dead-code` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(dead_code)]`
= note: this error originates in the macro `$crate::__pin_data`
which comes from the expansion of the attribute macro
`pin_data` (in Nightly builds, run with
-Z macro-backtrace for more info)
Thus `allow` it to clean it up.
This does not happen in mainline nor 6.15.y, because there the macro was
moved out of the `kernel` crate, and `dead_code` warnings are not
emitted if the macro is foreign to the crate. Thus this patch is
directly sent to stable and intended for 6.12.y only.
Similarly, it is not needed in previous LTSs, because there the Rust
version is pinned.
Cc: Benno Lossin <lossin@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
Greg, Sasha: please note that an equivalent patch is _not_ in mainline.
We could put these `allow`s in mainline (they wouldn't hurt), but it
isn't a good idea to add things in mainline for the only reason of
backporting them, thus I am sending this directly to stable.
The patch is pretty safe -- there is no actual code change.
rust/kernel/init/macros.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/kernel/init/macros.rs b/rust/kernel/init/macros.rs
index b7213962a6a5..e530028bb9ed 100644
--- a/rust/kernel/init/macros.rs
+++ b/rust/kernel/init/macros.rs
@@ -924,6 +924,7 @@ impl<'__pin, $($impl_generics)*> ::core::marker::Unpin for $name<$($ty_generics)
// We prevent this by creating a trait that will be implemented for all types implementing
// `Drop`. Additionally we will implement this trait for the struct leading to a conflict,
// if it also implements `Drop`
+ #[allow(dead_code)]
trait MustNotImplDrop {}
#[expect(drop_bounds)]
impl<T: ::core::ops::Drop> MustNotImplDrop for T {}
@@ -932,6 +933,7 @@ impl<$($impl_generics)*> MustNotImplDrop for $name<$($ty_generics)*>
// We also take care to prevent users from writing a useless `PinnedDrop` implementation.
// They might implement `PinnedDrop` correctly for the struct, but forget to give
// `PinnedDrop` as the parameter to `#[pin_data]`.
+ #[allow(dead_code)]
#[expect(non_camel_case_types)]
trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {}
impl<T: $crate::init::PinnedDrop>
base-commit: fbad404f04d758c52bae79ca20d0e7fe5fef91d3
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.12.y] rust: init: allow `dead_code` warnings for Rust >= 1.89.0
2025-07-12 17:10 [PATCH 6.12.y] rust: init: allow `dead_code` warnings for Rust >= 1.89.0 Miguel Ojeda
@ 2025-07-12 18:04 ` Benno Lossin
2025-07-13 14:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Benno Lossin @ 2025-07-12 18:04 UTC (permalink / raw)
To: Miguel Ojeda, Greg Kroah-Hartman, Sasha Levin, Alex Gaynor
Cc: stable, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
linux-kernel, patches
On Sat Jul 12, 2025 at 7:10 PM CEST, Miguel Ojeda wrote:
> Starting with Rust 1.89.0 (expected 2025-08-07), the Rust compiler
> may warn:
>
> error: trait `MustNotImplDrop` is never used
> --> rust/kernel/init/macros.rs:927:15
> |
> 927 | trait MustNotImplDrop {}
> | ^^^^^^^^^^^^^^^
> |
> ::: rust/kernel/sync/arc.rs:133:1
> |
> 133 | #[pin_data]
> | ----------- in this procedural macro expansion
> |
> = note: `-D dead-code` implied by `-D warnings`
> = help: to override `-D warnings` add `#[allow(dead_code)]`
> = note: this error originates in the macro `$crate::__pin_data`
> which comes from the expansion of the attribute macro
> `pin_data` (in Nightly builds, run with
> -Z macro-backtrace for more info)
>
> Thus `allow` it to clean it up.
This is a bit strange, I can't directly reproduce the issue... I already
get this warning in 1.88:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=465f71a848e77ac3f7a96a0af6bc9e2a
> This does not happen in mainline nor 6.15.y, because there the macro was
> moved out of the `kernel` crate, and `dead_code` warnings are not
> emitted if the macro is foreign to the crate. Thus this patch is
> directly sent to stable and intended for 6.12.y only.
>
> Similarly, it is not needed in previous LTSs, because there the Rust
> version is pinned.
>
> Cc: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Anyways the patch itself looks fine, nobody should care about the
dead-code warning (since it is in fact used to prevent `Drop` being
implemented).
Acked-by: Benno Lossin <lossin@kernel.org>
---
Cheers,
Benno
> ---
> Greg, Sasha: please note that an equivalent patch is _not_ in mainline.
>
> We could put these `allow`s in mainline (they wouldn't hurt), but it
> isn't a good idea to add things in mainline for the only reason of
> backporting them, thus I am sending this directly to stable.
>
> The patch is pretty safe -- there is no actual code change.
>
> rust/kernel/init/macros.rs | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/rust/kernel/init/macros.rs b/rust/kernel/init/macros.rs
> index b7213962a6a5..e530028bb9ed 100644
> --- a/rust/kernel/init/macros.rs
> +++ b/rust/kernel/init/macros.rs
> @@ -924,6 +924,7 @@ impl<'__pin, $($impl_generics)*> ::core::marker::Unpin for $name<$($ty_generics)
> // We prevent this by creating a trait that will be implemented for all types implementing
> // `Drop`. Additionally we will implement this trait for the struct leading to a conflict,
> // if it also implements `Drop`
> + #[allow(dead_code)]
> trait MustNotImplDrop {}
> #[expect(drop_bounds)]
> impl<T: ::core::ops::Drop> MustNotImplDrop for T {}
> @@ -932,6 +933,7 @@ impl<$($impl_generics)*> MustNotImplDrop for $name<$($ty_generics)*>
> // We also take care to prevent users from writing a useless `PinnedDrop` implementation.
> // They might implement `PinnedDrop` correctly for the struct, but forget to give
> // `PinnedDrop` as the parameter to `#[pin_data]`.
> + #[allow(dead_code)]
> #[expect(non_camel_case_types)]
> trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {}
> impl<T: $crate::init::PinnedDrop>
>
> base-commit: fbad404f04d758c52bae79ca20d0e7fe5fef91d3
> --
> 2.50.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6.12.y] rust: init: allow `dead_code` warnings for Rust >= 1.89.0
2025-07-12 18:04 ` Benno Lossin
@ 2025-07-13 14:41 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-13 14:41 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Sasha Levin, Alex Gaynor, stable, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, rust-for-linux, linux-kernel, patches
On Sat, Jul 12, 2025 at 08:04:48PM +0200, Benno Lossin wrote:
> On Sat Jul 12, 2025 at 7:10 PM CEST, Miguel Ojeda wrote:
> > Starting with Rust 1.89.0 (expected 2025-08-07), the Rust compiler
> > may warn:
> >
> > error: trait `MustNotImplDrop` is never used
> > --> rust/kernel/init/macros.rs:927:15
> > |
> > 927 | trait MustNotImplDrop {}
> > | ^^^^^^^^^^^^^^^
> > |
> > ::: rust/kernel/sync/arc.rs:133:1
> > |
> > 133 | #[pin_data]
> > | ----------- in this procedural macro expansion
> > |
> > = note: `-D dead-code` implied by `-D warnings`
> > = help: to override `-D warnings` add `#[allow(dead_code)]`
> > = note: this error originates in the macro `$crate::__pin_data`
> > which comes from the expansion of the attribute macro
> > `pin_data` (in Nightly builds, run with
> > -Z macro-backtrace for more info)
> >
> > Thus `allow` it to clean it up.
>
> This is a bit strange, I can't directly reproduce the issue... I already
> get this warning in 1.88:
>
> https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=465f71a848e77ac3f7a96a0af6bc9e2a
>
> > This does not happen in mainline nor 6.15.y, because there the macro was
> > moved out of the `kernel` crate, and `dead_code` warnings are not
> > emitted if the macro is foreign to the crate. Thus this patch is
> > directly sent to stable and intended for 6.12.y only.
> >
> > Similarly, it is not needed in previous LTSs, because there the Rust
> > version is pinned.
> >
> > Cc: Benno Lossin <lossin@kernel.org>
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
>
> Anyways the patch itself looks fine, nobody should care about the
> dead-code warning (since it is in fact used to prevent `Drop` being
> implemented).
>
> Acked-by: Benno Lossin <lossin@kernel.org>
Thanks, now queued up.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-13 14:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 17:10 [PATCH 6.12.y] rust: init: allow `dead_code` warnings for Rust >= 1.89.0 Miguel Ojeda
2025-07-12 18:04 ` Benno Lossin
2025-07-13 14:41 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).