Skip to content

Expression left untouched if can't fit in line length limit #2970

@YaLTeR

Description

@YaLTeR

rustfmt 0.99.2-nightly (5c9a2b6 2018-08-07)
Input like:

fn foo() {
    a.first().second().third().fourth(|| { let a = 1; }).fifth(some_argument).sixth("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
}

is left completely untouched due to being unable to fit the long argument, even in the presence of patterns that must be broken into multiple lines (|| { let a = 1; } in this case). I'd expect rustfmt to do the best it can even if that means leaving some lines overflowing (which would be better than not doing anything), for instance like this:

fn foo() {
    a.first()
        .second()
        .third()
        .fourth(|| {
            let a = 1;
        }).fifth(some_argument)
        .sixth(
            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        );
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions