rust-lang/rustfmt

Method calls with a long literal string doesn't get formatted

Closed this issue · 1 comments

Some method calls won't format if there's a long literal string in it. For example, an .expect() with a long message:

fn foo() {
    let _: i32 = "42".parse::<i32>() 
    .expect("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
}

rustfmt will skip formatting in this entire line. You can test it in in the playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=135ec08b2266e6e642bb1603f7592100. If you shorten the string by a single char, it will get formatted correctly.

Tested with rustfmt 1.8.0-nightly (eb4e234674 2024-10-09).

Duplicate of #3863