]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: pin-init: internal: suppress `non_snake_case` lint in `#[pin_data]`
authorMirko Adzic <adzicmirko97@gmail.com>
Wed, 27 May 2026 17:19:53 +0000 (18:19 +0100)
committerGary Guo <gary@garyguo.net>
Fri, 29 May 2026 20:34:53 +0000 (21:34 +0100)
Allows `non_snake_case` lint on struct fields generated by `#[pin_data]`.

Since the same warning will be reported by the compiler on the struct
definition, having extra warnings for the generated code is unnecessary
and confusing.

Signed-off-by: Mirko Adzic <adzicmirko97@gmail.com>
Link: https://patch.msgid.link/20260527-pin-init-sync-v1-2-e20335ed2501@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
rust/pin-init/internal/src/pin_data.rs

index 9ca8235ed3d6ade5647cf2e611a0c3c0ed7ab319..9fbbd25bcaac524ff78ac28b71101e058e21045f 100644 (file)
@@ -191,7 +191,10 @@ fn generate_unpin_impl(
     quote! {
         // This struct will be used for the unpin analysis. It is needed, because only structurally
         // pinned fields are relevant whether the struct should implement `Unpin`.
-        #[allow(dead_code)] // The fields below are never used.
+        #[allow(
+            dead_code, // The fields below are never used.
+            non_snake_case // The warning will be emitted on the struct definition.
+        )]
         struct __Unpin #generics_with_pin_lt
         #where_token
             #predicates
@@ -318,7 +321,9 @@ fn generate_projections(
     let docs = format!(" Pin-projections of [`{ident}`]");
     quote! {
         #[doc = #docs]
-        #[allow(dead_code)]
+        // Allow `non_snake_case` since the same warning will be emitted on
+        // the struct definition.
+        #[allow(dead_code, non_snake_case)]
         #[doc(hidden)]
         #vis struct #projection #generics_with_pin_lt
             #whr
@@ -386,6 +391,9 @@ fn generate_the_pin_data(
                 /// - `(*slot).#field_name` points to uninitialized and exclusively accessed
                 ///   memory.
                 #(#cfg_attrs)*
+                // Allow `non_snake_case` since the same warning will be emitted on
+                // the struct definition.
+                #[allow(non_snake_case)]
                 #[inline(always)]
                 #vis unsafe fn #field_name(
                     self,