rust-lang / rustfmt

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

Formatting error: closing curly-brace placed to the last comment (using `visual` imports indent) #6379

Open boozook opened 4 weeks ago

boozook commented 4 weeks ago

Valid code example (just from some crate documentation):

use binrw::{
    binrw,    // #[binrw] attribute
    BinRead,  // trait for reading
    BinWrite, // trait for writing
};

My rustfmt.toml:

imports_indent = "Visual"

Version of rustfmt: rustfmt 1.8.0-nightly (4392847410 2024-10-21)


Expected result of formatting example code above: (something like this, not sure)

use binrw::{binrw,    // #[binrw] attribute
            BinRead,  // trait for reading
            BinWrite, // trait for writing
           };

Actual result that breaks the code - closing curly-brace placed to the last comment:

use binrw::{binrw,    // #[binrw] attribute
            BinRead,  // trait for reading
            BinWrite  // trait for writing};
ytmimi commented 4 weeks ago

Thanks for the report. Confirming I can reproduce this with rustfmt 1.8.0-nightly (96cc01b197 2024-10-23)