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

Bad formatting with closures #6382

Open
Jasonshengxi opened this issue Oct 31, 2024 · 1 comment
Open

Bad formatting with closures #6382

Jasonshengxi opened this issue Oct 31, 2024 · 1 comment

Comments

@Jasonshengxi
Copy link

Jasonshengxi commented Oct 31, 2024

Formatting the following code produces awful results:

fn main() {
    {
        {
            {
                let result = this_is_a_quite_long_name(
                    another_long_one, 
                    &|from, to| -> LongResult<Words> {
                        () // this comment is to keep it from collapsing
                    }
                )?;
            }
        }
    }
}

it's formatted into this:

fn main() {
    {
        {
            {
                let result = this_is_a_quite_long_name(another_long_one, &|from,
                                                                           to|
                 -> LongResult<
                    Words,
                > {
                    () // this comment is to keep it from collapsing
                })?;
            }
        }
    }
}

playground: link

I can ignore it by using #[rustfmt::skip] but this behavior seems incorrect.

@ytmimi
Copy link
Contributor

ytmimi commented Nov 2, 2024

Likely a duplicate of one of these other closure formatting issues: https://github.com/rust-lang/rustfmt/issues?q=is%3Aissue%20state%3Aopen%20label%3Aa-closures

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