Skip to content

[Rust] Support macro repetitions inside structs #3912

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FichteFoll
Copy link
Collaborator

@FichteFoll FichteFoll commented Jan 28, 2024

This only addresses a specific case of macro repetitions inside the struct body and similar changes to other statements with body blocks are likely also necessary, but I'm keeping the change to a limited scope in order to observe its effects first. Further reports of such issues can be handled analogously.

Closes #3904.

This only addresses a specific case of macro repetitions inside the
struct body and similar changes to other statements with body blocks
are likely also necessary, but I'm keeping the change to a limited in
order to observe its effects first. Further reports of such issues can
be handled analogously.
@FichteFoll
Copy link
Collaborator Author

FichteFoll commented Jan 28, 2024

The other reason I didn't do it for other block statements is that I didn't have any (valid) examples at hand to verify with and I'm not comfortable enough with macros to craft them ad-hoc.

`const` and function definitions are not valid inside structs. `impl`
was probably meant here.
@FichteFoll
Copy link
Collaborator Author

This doesn't handle macros like println!($($arg)); or println!($($arg)?); well and I don't really see how it could … Putting the PR on hold for now.

@jrappen
Copy link
Collaborator

jrappen commented Apr 19, 2025

... putting the PR on hold.

@FichteFoll Do you plan to pick this up again?

@FichteFoll
Copy link
Collaborator Author

Not in the near future. I don't think this can be handled cleanly with the current structure and inside a prototype match. A better approach would likely be to either create a derived syntax with macro block support added in every relevant context that a macro pattern can be used, or directly add support for macro patterns into each syntax construct natively with the upside of only having one syntax to maintain but the downside of this single syntax becoming noticably more complex.

Haven't really thought about it more than that, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Rust] Macro improperly marked as invalid
2 participants