Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mbartlett21 opened this issue Oct 17, 2020 · 1 comment
Closed

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

mbartlett21 opened this issue Oct 17, 2020 · 1 comment
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate

Comments

@mbartlett21
Copy link

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

@mbartlett21 mbartlett21 added the bug Panic, non-idempotency, invalid code, etc. label Oct 17, 2020
@calebcartwright
Copy link
Member

Thank you for the report, though closing as a duplicate of #4467 and #4452 (comment). Will be addressed in the next rustc-ap bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate
Projects
None yet
Development

No branches or pull requests

2 participants