Skip to content

Extra brace is inserted after #[cfg(...)] on a block #4475

@mbartlett21

Description

@mbartlett21

Describe the bug

When formatting a single-line block expression with a #[cfg(...)] attribute before it, an extra open brace is produced.

To Reproduce

main.rs:

fn main() {
    #[cfg(debug_assertions)]
    { println!("DEBUG"); }
}

Run rustfmt main.rs

main.rs now contains:

fn main() {
    #[cfg(debug_assertions)]
    {
{        println!("DEBUG");
    }
}

Expected behavior

The braces are put onto different lines correctly

Meta

  • rustfmt version: rustfmt 1.4.22-nightly (97d03010 2020-10-04)

  • From where did you install rustfmt?: I think cargo

  • How do you run rustfmt:

    I tried with both cargo fmt and rustfmt. Both do the same

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-duplicateStatus: duplicate of another issue or PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions