-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Cleaner macros utilizing syn::Member #18199
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
Conversation
#[derive(QueryData)]
#[query_data(mutable(foo))]
//~^ ERROR: `mutable` does not take any arguments
struct MutableInvalidAttributeParameters {
a: &'static mut Foo,
}should we really give a error for this? seems so unnessesary and extra code. When u do this it already says "expected |
chescock
left a comment
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.
Yeah, this seems cleaner!
It's a little unfortunate that syn::Member doesn't have the rest of the Field value, forcing most of the uses here to do fields.iter().enumerate().filter().map() instead of just field.members(). Would it ever make sense to add our own wrapper type around a &Field and its index, along with a function to iterate them from a Fields, so that we could share a little more code here?
|
Yeah we could do that, but would be better as a follow up pr |
james7132
left a comment
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.
This is so much cleaner! LGTM.
|
@Bleachfuel, I would rather like to merge this, but the merge conflicts are non-trivial. Could you take a look? |
|
CI is still failing unfortunately :( |
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
1 similar comment
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
Closing as adopted. |
# Objective Some macros were handling Idents and indexes as seperate things, we can use syn::Member to make this more readable and nicer. revive of #18199
Objective
Some macros were handling Idents and indexes as seperate things, we can use syn::Member to make this more readable and nicer.
Testing
ran all revelant crate tests.