Skip to content

Bad formatting with closures #6382

Open
@Jasonshengxi

Description

@Jasonshengxi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions