-
Notifications
You must be signed in to change notification settings - Fork 888
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
Nested macro_rules
utilising inner metavariable are infinitely indented with repeated formatting
#4609
Comments
The issue is caused because original code snippet is used, since the macro code cannot be parsed properly: a |
The original code does compile and execute as expected - I’m not sure what you mean by “cannot be parsed properly”. |
Oops! You are right. It is a while since I evaluated the root case .... Sorry for that. Note that the proposed fix is handling the general issue of formatting macro body when original code snippet is used, and not the specific issue of handling the |
Another example: macro_rules! alpha {
() => {
macro_rules! beta {
() => {
gamma!(*)
};
}
};
} Where I’ve written I found a hint at a likely underlying problem: if you take just the inner macro_rules! delta {
() => {
epsilon!(*)
};
} Whereas if you remove that |
…ro formatting when repeating formatting
Submitted PR #5473 with a proposed solution. |
Input
Output
Note that the body and trailing closing braces of the nested
macro_rules
block is indented. With further invocations ofrustfmt
, this block is continuously indented to the next level.Removing the usage of the inner
macro_rules
's$s
in theprintln!
usage causes the formatting to behave as expected.Expected output
The input should likely remain unchanged.
Meta
The text was updated successfully, but these errors were encountered: