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

Alexandre Courbot
2025-12-16T05:14:13Z

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