-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix relationship macro for multiple named members fields #18530
Fix relationship macro for multiple named members fields #18530
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good fix, but needs a regression test please :)
Gotcha I'm not familiar with testing macros but I'll poke around in this tmrw night if I can get time! |
For a test, just add some dead code in a struct that checks that this compiles. Or use a doc test, which can be a bit nicer. |
Got it, sounds straightforward! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having tested with my own similar error case, I believe the same fix is necessary on line 781 also to avoid the same bug occurring in the relationship_target macro.
woops sorry, messed up when implementing it for enum's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for line 781
Good catch! |
10f06ef
to
4f4b993
Compare
Extra case handled in |
Hm, these CI failures don't look related to my change. Did I inherit them by rebasing against main? They're all in the bevy_reflect crate which I didn't touch |
I think it's because you're changing a macro crate which are compiled differently. And you can't depend on bevy_ecs in it. so you should probably move your examples to bevy_ecs |
841a809
to
d1497ac
Compare
Thanks. I opted for actual test content rather than adding a bunch of cases to doc tests that might just be noise. Hoping this covers the cases appropriately but happy to adjust if folks have suggestions for alternate approaches! |
# Objective Fixes #18466 ## Solution Updated the macro generation pattern to place the comma in the correct place in the pattern. ## Testing - Tried named and unnamed fields in combination, and used rust expand macro tooling to see the generated code and verify its correctness (see screenshots in example below) --- ## Showcase Screenshot showing expanded macro with multiple named fields  Screenshot showing expanded macro with single unnamed field  ## Migration Guide n/a
Objective
Fixes #18466
Solution
Updated the macro generation pattern to place the comma in the correct place in the pattern.
Testing
Showcase
Screenshot showing expanded macro with multiple named fields

Screenshot showing expanded macro with single unnamed field

Migration Guide
n/a