Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
musjj opened this issue Oct 10, 2024 · 1 comment
Closed

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

musjj opened this issue Oct 10, 2024 · 1 comment

Comments

@musjj
Copy link

musjj commented Oct 10, 2024

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).

@ytmimi
Copy link
Contributor

ytmimi commented Oct 10, 2024

Duplicate of #3863

@ytmimi ytmimi marked this as a duplicate of #3863 Oct 10, 2024
@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants