-
Notifications
You must be signed in to change notification settings - Fork 926
format_macro_matchers
unusual behavior with commas
#5984
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
Comments
Linking the tracking issue for |
ProblemThis seems to be caused by the intersection of 2 things: an assumption in the macro parsing code, where we always insert a 'separator' before parsing a meta-variable ( Lines 907 to 910 in 7289391
$ident s at the start of each line.
and, what seems to me, like a bug in the token rules. Running the provided snippet through the macro parser gives the following tokens.
What HappensI believe these are the root of the problem: This expression ( This is why when it's rewriting the expression, it emits: The solution (Part of it at least)I'm going to try and update the token rules, so that |
@InsertCreativityHere thanks for taking the time to look into this, and for the clear explanation of the issue |
For a struct-like macro:
Formatting with
format_macro_matchers = true
produces weird results:It seems like it always removes whitespace after a comma rather than using it as a possible break location. Single-line macros have similarly weird results:
rustfmt 1.7.0-nightly (f704f3b9 2023-12-19)
The text was updated successfully, but these errors were encountered: