fix: formatting macro with braces delimiter - #7031
Open
dswij wants to merge 1 commit into
Open
Conversation
dswij
commented
Aug 16, 2026
| // For macro invocations with braces, always put a space between | ||
| // the `macro_name!` and `{ /* macro_body */ }` but skip modifying | ||
| // anything in between the braces (for now). | ||
| // the `macro_name!` and `{ /* macro_body */ }`. |
Member
Author
There was a problem hiding this comment.
This is not correct. We do modify it by trimming (sometimes).
Comment on lines
-611
to
-637
| /// e.g. | ||
| /// | ||
| /// ```rust,compile_fail | ||
| /// foo!{ | ||
| /// x, | ||
| /// y, | ||
| /// foo( | ||
| /// a, | ||
| /// b, | ||
| /// c, | ||
| /// ), | ||
| /// } | ||
| /// ``` | ||
| /// | ||
| /// will become | ||
| /// | ||
| /// ```rust,compile_fail | ||
| /// foo!{ | ||
| /// x, | ||
| /// y, | ||
| /// foo( | ||
| /// a, | ||
| /// b, | ||
| /// c, | ||
| /// ), | ||
| /// } | ||
| /// ``` |
Member
Author
There was a problem hiding this comment.
The example seems wrong, or there is a regression.
The former won't be formatted: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=232fbfe6b62a1ffcddd22f3045bdd306
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6747.
This PR makes it so that
trim_left_preserve_layoutdoes nothing when the first line contains a string start.e.g., this will now not be formatted
I'm not too satisfied with this PR; I think the formatting for macros with braces
{,}needs to be reworked. I'm opening this PR as a starting point for that goal.