-
Notifications
You must be signed in to change notification settings - Fork 38
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 derive in macro-expanded structs #75
Conversation
syn::Type::Group(ref group) => { | ||
impl_field(ident, &group.elem) | ||
} |
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.
The change is here. I went with recursion to avoid duplication and I'm not sure if this can actually occur recursively.
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.
maybe add a note about this, so it isn't refactored / changed in the future?
I assume this is backwards compatible with pre 1.47 ? |
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.
A comment like I suggested would be nice, about the 1.47 breakage; can we add your repro as a test to prevent this in the future?
And thank you for this! I would never have guessed from the changelog that a backwards incompatible change occurred in stable (nor that this would be affected...)
syn::Type::Group(ref group) => { | ||
impl_field(ident, &group.elem) | ||
} |
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.
maybe add a note about this, so it isn't refactored / changed in the future?
I didn't really understand the discussion in the rust issue, it was stated that either the macro is unhygenic, or we didn't correctly handle Edit: @mitsuhiko maybe you can shed some light on this? |
I am even more confused right now; we do have
|
Ohhhhh, gosh, sorry I totally missed the part that the derive pread on an array is inside a |
Ok since this is kind of an emergency I'm going to merge it and push new version; we can follow up later on other details if needed |
scroll_derive 0.10.3 is out with this fix, thanks @jan-auer et. al! |
I should have probably provided more information. Would you like me to follow up with some code comments on this? Effectively the change is that now the compiler creates more On the bottom line, I think this is actually something that this derive just has to handle. Since every type can (now) appear inside an invisible group, it has to account for that and traverse. Thanks for merging this! |
This accommodates for an apparent change in behavior since Rust 1.47.0. When array-type struct fields are expanded in a macro, they are put in an invisible type group, which the derive needs to handle.
Minimal repro: