Fix #22865 non_snake_case on bundle derive#22866
Fix #22865 non_snake_case on bundle derive#22866SOF3 wants to merge 1 commit intobevyengine:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the new non_snake_case warning emitted by code generated via deconstruct_moving_ptr! when field-derived locals end up with names like field__marker (regression noted in #22865, bevy_ecs 0.18).
Changes:
- Adds
#[allow(non_snake_case)]toletbindings generated in the tuple andMaybeUninit::<tuple>arms ofdeconstruct_moving_ptr!.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $( | ||
| #[allow(non_snake_case)] | ||
| let $pattern = unsafe { ptr.move_field(|f| &raw mut (*f).$field_index) }; | ||
| )* |
There was a problem hiding this comment.
This only adds #[allow(non_snake_case)] to the tuple (let tuple { ... }) and MaybeUninit::<tuple> arms. The derive(Bundle) expansion that triggered #22865 uses the struct-pattern arms (let StructName { field: field_local, ... } = ptr;), which still expand to let field__marker = ...; without an allow, so the original warning is likely unchanged. Consider applying the same #[allow(non_snake_case)] to the struct and MaybeUninit::<Struct> arms as well (the ones using get_pattern!).
| // - Each field is distinct, since otherwise the block of code above would fail compilation | ||
| $(let $pattern = unsafe { ptr.move_field(|f| &raw mut (*f).$field_index) };)* | ||
| $( | ||
| #[allow(non_snake_case)] |
There was a problem hiding this comment.
Please add a comment explaining why this allow is needed :)
| // - Each field is distinct, since otherwise the block of code above would fail compilation | ||
| $(let $pattern = unsafe { ptr.move_maybe_uninit_field(|f| &raw mut (*f).$field_index) };)* | ||
| $( | ||
| #[allow(non_snake_case)] |
There was a problem hiding this comment.
Ditto on the comment here.
|
CI is failing due to a GitHub network error, could you trigger a rerun? |
|
This doesn't seem like the right place to fix this. If a user wants to provide a non-snake-case identifier, can't they write Looking at the linked issue, I see this is happening with bevy/crates/bevy_ecs/macros/src/lib.rs Line 115 in d1c3557 I think it would be better to add That would mean adding it to the bevy/crates/bevy_ecs/macros/src/lib.rs Lines 154 to 164 in d1c3557 |
Objective
Fixes #22865
Solution
Add
#[allow(non_snake_case)]to avoid validating thefieldvariable format.Testing