rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.06k stars 893 forks source link

Spurious semicolon inside closure is not idempotent #6116

Open Kyuuhachi opened 8 months ago

Kyuuhachi commented 8 months ago

Consider the following snippet.

fn foo() -> fn(i32) -> i32 {
    |a| {
        ;
        a
    }
}

Rustfmt starts by removing that spurious semicolon.

fn foo() -> fn(i32) -> i32 {
    |a| {
        a
    }
}

If run again, it notices that the closure fits on one line.

fn foo() -> fn(i32) -> i32 {
    |a| a
}
rscprof commented 8 months ago

@rustbot claim