Skip to content

Commit 838330b

Browse files
Mirko-Anbdd0121
authored andcommitted
internal: suppress non_snake_case lint in [pin_]init!
Changes how `[pin_]init!` handles `InitializerKind::Value` to avoid creating a local variable that can cause `non_snake_case` lint. Allows `non_snake_case` lint on local variables generated elsewhere in `[pin_]init!`. Since the same warning will be reported by the compiler on the struct definition, having the extra warning for the generated local variables is unnecessary and confusing. Reported-by: Gary Guo <gary@garyguo.net> Link: #125 Closes: https://lore.kernel.org/rust-for-linux/DGTBJBIVFZ2K.2F1ZEFGY0G7NK@garyguo.net/ Fixes: db96c51 ("add references to previously initialized fields") Signed-off-by: Mirko Adzic <adzicmirko97@gmail.com>
1 parent 7c66b8a commit 838330b

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4141
check by `#[pin_data]`.
4242
- `#[pin_data]` no longer produces additional `non_snake_case` warnings if field names
4343
are not of snake case. Standard field definition warnings are unaffected.
44+
- `init!` and `pin_init!` no longer produce `non_snake_case` warnings if field names
45+
are not of snake case. Warnings on the struct definition are unaffected.
4446

4547
## [0.0.10] - 2025-08-19
4648

internal/src/init.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ fn init_fields(
296296
#init
297297

298298
#(#cfgs)*
299-
#[allow(unused_variables)]
299+
// Allow `non_snake_case` since the same warning is going to be reported for the struct
300+
// field.
301+
#[allow(unused_variables, non_snake_case)]
300302
let #ident = #guard.let_binding();
301303
});
302304

0 commit comments

Comments
 (0)