Skip to content

Redundant new line in if statement #4392

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

Open
davidBar-On opened this issue Aug 19, 2020 · 1 comment
Open

Redundant new line in if statement #4392

davidBar-On opened this issue Aug 19, 2020 · 1 comment

Comments

@davidBar-On
Copy link
Contributor

Input

fn main() {
    if 'a' == 0
    /* x */ as char {} }

fn main() {
    if 1234 == 'a'
    /* x */ as i32 {} }

fn main() {
    if 'a' == b // x
    as char {}
}

Output

fn main() {
    if 'a'
        == 0
    /* x */ as char
    {}
}

fn main() {
    if 1234
        == 'a'
    /* x */ as i32
    {}
}

fn main() {
    if 'a'
        == b // x
    as char
    {}
}

Expected output

fn main() {
    if 'a' == 0
    /* x */ as char
    {}
}

fn main() {
    if 1234 == 'a'
    /* x */ as i32
    {}
}

fn main() {
    if 'a' == b // x
    as char
    {}
}

Meta

  • rustfmt version: rustfmt 2.0.0-rc.2-nightly (688e472 2020-08-10)
  • From where did you install rustfmt?: local build from a clone (Linux WSL under Windows 10)
@davidBar-On
Copy link
Contributor Author

davidBar-On commented Aug 19, 2020

The problem seem to happen in pairs.rs, rewrite_pairs_multiline() function, line 128:

    if last_line_width(&result) + offset <= nested_shape.used_width() {

For some reason the decision is that the line will exceed the allowed line size.

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

3 participants