]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rust: pin-init: internal: suppress `non_snake_case` lint in `[pin_]init!`
authorMirko Adzic <adzicmirko97@gmail.com>
Wed, 27 May 2026 17:19:54 +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 local variables generated in `[pin_]init!`.

Conceptually the identifiers in `[pin_]init!` just references the field
names, and are not defining them, so the warning should not be generated,
similar to how constructing a struct with non-snake-case field names do no
generate these warnings.

Reported-by: Gary Guo <gary@garyguo.net>
Closes: https://github.com/Rust-for-Linux/pin-init/issues/125
Closes: https://lore.kernel.org/rust-for-linux/DGTBJBIVFZ2K.2F1ZEFGY0G7NK@garyguo.net/
Fixes: 42415d163e5d ("rust: pin-init: add references to previously initialized fields")
Signed-off-by: Mirko Adzic <adzicmirko97@gmail.com>
[ Reworded commit message - Gary ]
Link: https://patch.msgid.link/20260527-pin-init-sync-v1-3-e20335ed2501@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
rust/pin-init/internal/src/init.rs

index 699b105570a54fb9e46fcb6518414d270538d326..041a845937304b9de83e7eb977a029c18a77bf78 100644 (file)
@@ -296,7 +296,9 @@ fn init_fields(
             #init
 
             #(#cfgs)*
-            #[allow(unused_variables)]
+            // Allow `non_snake_case` since the same warning is going to be reported for the struct
+            // field.
+            #[allow(unused_variables, non_snake_case)]
             let #ident = #guard.let_binding();
         });