[PATCH 3/8] rust: pin-init: internal: suppress `non_snake_case` lint in `[pin_]init!`
From: Gary Guo
Date: Wed May 27 2026 - 13:26:04 EST
From: Mirko Adzic <adzicmirko97@xxxxxxxxx>
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@xxxxxxxxxxx>
Closes: https://github.com/Rust-for-Linux/pin-init/issues/125
Closes: https://lore.kernel.org/rust-for-linux/DGTBJBIVFZ2K.2F1ZEFGY0G7NK@xxxxxxxxxxx/
Fixes: 42415d163e5d ("rust: pin-init: add references to previously initialized fields")
Signed-off-by: Mirko Adzic <adzicmirko97@xxxxxxxxx>
[ Reworded commit message - Gary ]
Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
---
rust/pin-init/internal/src/init.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/rust/pin-init/internal/src/init.rs b/rust/pin-init/internal/src/init.rs
index 699b105570a5..041a84593730 100644
--- a/rust/pin-init/internal/src/init.rs
+++ b/rust/pin-init/internal/src/init.rs
@@ -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();
});
--
2.54.0