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

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

Closed
YaLTeR opened this issue Aug 27, 2018 · 2 comments
Closed

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

YaLTeR opened this issue Aug 27, 2018 · 2 comments
Milestone

Comments

@YaLTeR
Copy link
Contributor

YaLTeR commented Aug 27, 2018

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",
        );
}
@nrc
Copy link
Member

nrc commented Aug 30, 2018

That would be better, but I think this is p-low because it would be a fairly disruptive change and in any case the user has to fix this up. Also since the formatting causes an error I think we can fix this backwards compatibly post 1.0.

@calebcartwright
Copy link
Member

I know this one was opened first, but closing in favor of #3863 given the additional discussions in that thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants