Skip to content

Comma in comment causes no formatting to happen #3532

Closed
@jgouly

Description

@jgouly

The following code passes with rustfmt --check:

fn foo(a: T) {
    match a {
1 => {}
    0 => {}
    // _ => panic!("doesn't format!"),
    }
}

If you remove the comma afterpanic!("doesn't format!"),, rustfmt --check complains.

$ rustfmt --check src/fmt.rs
Diff in fmt.rs at line 1:
 fn foo(a: T) {
   match a {
-1 => {}
-  0 => {}
-  // _ => panic!("doesn't format!")
+    1 => {}
+    0 => {} // _ => panic!("doesn't format!")
   }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions