Skip to content

cfg_select! follow-ups to #7183 #7191

Open

Description

@jieyouxu

NB: these are all follow-ups to #7183, not main without #7183.

  1. The {{ }} happy path trailing comma handling doesn't yet account for match_block_trailing_comma config Have cfg_select! double-brace concise formatting respect match_block_trailing_comma #7213
  2. There are some comments that are unexpectedly removed between outer/inner braces, and before/after =>. See cfg_select_comments_that_might_get_lost for test cases. Don't lose comments and attributes between cfg_select! predicates, outer/inner blocks, arm body and trailing commas #7211 and rustfmt: prevent more comment loss in cfg_select! rust#164815
  3. See // Doc comments case; we seem to be adding braces at times.
  4. Wrt. #![feature(stmt_expr_attributes)], we seem to be adding a brace to e.g. => #[cfg(true)] 1. => #[cfg(true)] 1 is not valid syntax, but => { #[cfg(true)] 1 } becomes valid stmt_expr_attributes syntax. Invalid syntax => compile-pass.
  5. We might not be account for control_brace_style config for where to place the brace Have cfg_select! double-brace concise formatting respect control_brace_style #7214

Activity

  1. added
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Oct 17, 2026
  2. added
    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE
    I-unexpectedly-removes-codeIssue: unexpectedly removes code that we should not be removing
    and removed
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Oct 17, 2026
  3. jieyouxu commented on Oct 24, 2026

    @jieyouxu
    MemberAuthor

    I don't think (4) we care about, tbh.

  4. ytmimi commented on Oct 28, 2026

    @ytmimi
    Contributor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: attributesA-cfg_select`cfg_select!`A-commentsArea: commentsC-bugCategory: 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)]`I-unexpectedly-adds-codeIssue: rustfmt unexpected adds codeI-unexpectedly-removes-codeIssue: unexpectedly removes code that we should not be removingSO-match_block_trailing_commaStable option: match_block_trailing_commaUO-control_brace_styleUnstable option: control_brace_style

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions