Skip to content

fix: formatting macro with braces delimiter - #7031

Open
dswij wants to merge 1 commit into
rust-lang:mainfrom
dswij:issue-6747
Open

fix: formatting macro with braces delimiter#7031
dswij wants to merge 1 commit into
rust-lang:mainfrom
dswij:issue-6747

Conversation

@dswij

@dswij dswij commented Aug 16, 2026

Copy link
Copy Markdown
Member

Fixes #6747.

This PR makes it so that trim_left_preserve_layout does nothing when the first line contains a string start.

e.g., this will now not be formatted

macro! {"
...
"};

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.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 16, 2026
Comment thread src/macros.rs
// 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 */ }`.

@dswij dswij Aug 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. We do modify it by trimming (sometimes).

View changes since the review

Comment thread src/utils.rs
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,
/// ),
/// }
/// ```

@dswij dswij Aug 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strings incorrectly unindented with braced macro

2 participants