Repository navigation
rustfmt formatting of cfg_select! pending for Rust 1.99 diverges from style FCP #160944
Copy link
Copy link
Closed
Closed
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-style-nominatedNominated for discussion during a style team meeting.Nominated for discussion during a style team meeting.T-rustfmtRelevant to the rustfmt team, which will review and decide on the PR/issue.Relevant to the rustfmt team, which will review and decide on the PR/issue.T-styleRelevant to the style team, which will review and decide on the PR/issue.Relevant to the style team, which will review and decide on the PR/issue.
Description
In rust-lang/style-team#201 (comment), the style team FCPed a decision about how to format code within cfg_select. This included by reference the determination made in #144323 (comment). In that, we specified the following formatting:
cfg_select! {
feature
= "debug-with-rustfmt-long-long-long-long-loooooooonnnnnnnnnnnnnnnggggggffffffffffffffff"
=> {
println!();
}
feature
= "debug-with-rustfmt-long-long-long-long-loooooooonnnnnnnnnnnnnnnggggggffffffffffffffff"
=> {}
anything(
"some other long long long long long thing long long long long long long long long long long long",
) => {}
}That PR was closed, and formatting for cfg_select! landed in #154202 (thanks for that!). But the current formatting, for the above, on nightly, is:
cfg_select! {
feature = "debug-with-rustfmt-long-long-long-long-loooooooonnnnnnnnnnnnnnnggggggffffffffffffffff" =>
{
println!();
}
feature = "debug-with-rustfmt-long-long-long-long-loooooooonnnnnnnnnnnnnnnggggggffffffffffffffff" =>
{}
anything(
"some other long long long long long thing long long long long long long long long long long long",
) => {}
}It's also not adding trailing commas, so it formats this —
cfg_select! {
all(target_arch = "x86_64", target_env = "gnu", not(any(target_os = "os1", target_os = "os2"))) => {}
any(one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen) => {}
_ => {}
}— as:
cfg_select! {
all(
target_arch = "x86_64",
target_env = "gnu",
not(any(target_os = "os1", target_os = "os2"))
) => {}
any(
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen,
fourteen, fifteen, sixteen
) => {}
_ => {}
}I'd suspect we might want it to add the trailing commas there.
@ytmimi: What are you thoughts on how to handle this given the pending beta bump?
cc @rust-lang/rustfmt @rust-lang/style
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-style-nominatedNominated for discussion during a style team meeting.Nominated for discussion during a style team meeting.T-rustfmtRelevant to the rustfmt team, which will review and decide on the PR/issue.Relevant to the rustfmt team, which will review and decide on the PR/issue.T-styleRelevant to the style team, which will review and decide on the PR/issue.Relevant to the style team, which will review and decide on the PR/issue.
Activity
ytmimi commentedon Aug 11, 2026
@traviscross could we pull the formatting from the beta but keep it on nightly? I think we should try to adhere to the formatting rules that @rust-lang/style came up with.
Are the rules officially incorporated in the style-guide? Would be nice to have them as a reference when updating the implementation.
Edit: I guess to prevent this from landing on
betawe could add ais_nightly_channel!()check to gate formattingtraviscross commentedon Aug 11, 2026
That would make sense to me; thanks. I'm working on a style guide PR.
traviscross commentedon Aug 12, 2026
Style guide PR:
cfg_select!formatting rules to the style guide #160967ytmimi commentedon Aug 12, 2026
PR to gate
cfg_select!formatting on thenightlyrelease channel:cfg_select!formatting to thenightlyrelease channel #160998Rollup merge of rust-lang#160998 - ytmimi:nightly_only_cfg_select_for…
Unrolled build for #160998