[PATCH RFC 4/7] rust: pin-init: allow `dead_code` on projection structure

Alexandre Courbot posted 7 patches 1 month, 3 weeks ago
[PATCH RFC 4/7] rust: pin-init: allow `dead_code` on projection structure
Posted by Alexandre Courbot 1 month, 3 weeks ago
Projection structures are not necessarily (and often not) used in their
entirety. At the moment partial uses result in warnings about the unused
members.

Discard them by allowing `dead_code` on the projection structure

To: Benno Lossin <lossin@kernel.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

---
Benno, please let me know if this looks good to you and I will send you
a Github PR for this.
---
 rust/pin-init/src/macros.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rust/pin-init/src/macros.rs b/rust/pin-init/src/macros.rs
index 682c61a587a0..fe60e570c729 100644
--- a/rust/pin-init/src/macros.rs
+++ b/rust/pin-init/src/macros.rs
@@ -1004,6 +1004,7 @@ fn drop(&mut self) {
         @not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?),
     ) => {
         $crate::macros::paste! {
+            #[allow(dead_code)]
             #[doc(hidden)]
             $vis struct [< $name Projection >] <'__pin, $($decl_generics)*> {
                 $($(#[$($p_attr)*])* $pvis $p_field : ::core::pin::Pin<&'__pin mut $p_type>,)*

-- 
2.52.0
Re: [PATCH RFC 4/7] rust: pin-init: allow `dead_code` on projection structure
Posted by Benno Lossin 1 month, 3 weeks ago
On Tue Dec 16, 2025 at 6:13 AM CET, Alexandre Courbot wrote:
> Projection structures are not necessarily (and often not) used in their
> entirety. At the moment partial uses result in warnings about the unused
> members.
>
> Discard them by allowing `dead_code` on the projection structure
>
> To: Benno Lossin <lossin@kernel.org>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>
> ---
> Benno, please let me know if this looks good to you and I will send you
> a Github PR for this.

Looks good :)

Cheers,
Benno

> ---
>  rust/pin-init/src/macros.rs | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/rust/pin-init/src/macros.rs b/rust/pin-init/src/macros.rs
> index 682c61a587a0..fe60e570c729 100644
> --- a/rust/pin-init/src/macros.rs
> +++ b/rust/pin-init/src/macros.rs
> @@ -1004,6 +1004,7 @@ fn drop(&mut self) {
>          @not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?),
>      ) => {
>          $crate::macros::paste! {
> +            #[allow(dead_code)]
>              #[doc(hidden)]
>              $vis struct [< $name Projection >] <'__pin, $($decl_generics)*> {
>                  $($(#[$($p_attr)*])* $pvis $p_field : ::core::pin::Pin<&'__pin mut $p_type>,)*