rust-lang / rustfmt

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

nightly won't unwrap trailing line comments #6199

Closed fowles closed 3 months ago

fowles commented 3 months ago
fn main() -> Result<(), Box<dyn std::error::Error>> {
    if false {
        return Ok(()); // 8901234567890123456789012345678901234567890
                       // 12345
    }
    if true {
        if true {
            if true {
                if true {
                    if true {
                        return Ok(()); // The workspace has been deleted
                                       // (see above)
                    }
                }
            }
        }
    }
    Ok(())
}

when formatted with

edition = "2021"
max_width = 100
wrap_comments = true
comment_width = 100

this should unwrap both line comments as they will both fit within 100 characters.

ytmimi commented 3 months ago

@fowles to the best of my knowledge wrap_commetns won't unwrap / reflow text, and I believe this is the intended behavior. This seems like it's a duplicate of https://github.com/rust-lang/rustfmt/issues/2968.