Skip to content

rustfmt formatting of cfg_select! pending for Rust 1.99 diverges from style FCP #160944

Description

@traviscross

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-style-nominatedNominated for discussion during a style team meeting.T-rustfmtRelevant 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions