Repository navigation
Open
Labels
A-attributesArea: attributesArea: attributesA-cfg_select`cfg_select!``cfg_select!`A-commentsArea: commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEF-stmt_expr_attributes`#![feature(stmt_expr_attributes)]``#![feature(stmt_expr_attributes)]`I-unexpectedly-adds-codeIssue: rustfmt unexpected adds codeIssue: rustfmt unexpected adds codeI-unexpectedly-removes-codeIssue: unexpectedly removes code that we should not be removingIssue: unexpectedly removes code that we should not be removingSO-match_block_trailing_commaStable option: match_block_trailing_commaStable option: match_block_trailing_commaUO-control_brace_styleUnstable option: control_brace_styleUnstable option: control_brace_style
Description
NB: these are all follow-ups to #7183, not main without #7183.
TheHave{{ }}happy path trailing comma handling doesn't yet account formatch_block_trailing_commaconfigcfg_select!double-brace concise formatting respectmatch_block_trailing_comma#7213There are some comments that are unexpectedly removed between outer/inner braces, and before/afterDon't lose comments and attributes between=>. Seecfg_select_comments_that_might_get_lostfor test cases.cfg_select!predicates, outer/inner blocks, arm body and trailing commas #7211 and rustfmt: prevent more comment loss incfg_select!rust#164815- See
// Doc commentscase; we seem to be adding braces at times. - Wrt.
#![feature(stmt_expr_attributes)], we seem to be adding a brace to e.g.=> #[cfg(true)] 1.=> #[cfg(true)] 1is not valid syntax, but=> { #[cfg(true)] 1 }becomes validstmt_expr_attributessyntax. Invalid syntax => compile-pass. We might not be account forHavecontrol_brace_styleconfig for where to place the bracecfg_select!double-brace concise formatting respectcontrol_brace_style#7214
Metadata
Metadata
Assignees
Labels
A-attributesArea: attributesArea: attributesA-cfg_select`cfg_select!``cfg_select!`A-commentsArea: commentsArea: commentsC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEF-stmt_expr_attributes`#![feature(stmt_expr_attributes)]``#![feature(stmt_expr_attributes)]`I-unexpectedly-adds-codeIssue: rustfmt unexpected adds codeIssue: rustfmt unexpected adds codeI-unexpectedly-removes-codeIssue: unexpectedly removes code that we should not be removingIssue: unexpectedly removes code that we should not be removingSO-match_block_trailing_commaStable option: match_block_trailing_commaStable option: match_block_trailing_commaUO-control_brace_styleUnstable option: control_brace_styleUnstable option: control_brace_style
Activity
jieyouxu commentedon Oct 24, 2026
I don't think (4) we care about, tbh.
ytmimi commentedon Oct 28, 2026
In regards to (4) above; Yeah, in that case rustfmt is taking code that parses, but doesn't compile and converts it to code that compiles without altering the original intention, so I think it's for the best.