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

rustfmt fails when encountering comment (+ trailing whitespace) #3851

Closed
lesurp opened this issue Oct 9, 2019 · 1 comment · Fixed by #3857
Closed

rustfmt fails when encountering comment (+ trailing whitespace) #3851

lesurp opened this issue Oct 9, 2019 · 1 comment · Fixed by #3857

Comments

@lesurp
Copy link

lesurp commented Oct 9, 2019

⮞ cargo fmt --version
rustfmt 1.4.4-stable (0462008 2019-08-06)

No trailing whitespace

fn main() {
    let a =
            // asasddasas 
    if true {
     1.0
    };
}

output: exact same (the 1.0 line is not indented

With trailing whitespace:

Please note the trailing whitespace after the let a= line

fn main() {
    let a = 
            // asasddasas 
    if true {
     1.0
    };
}

output:

 ⮞ cargo fmt
error[internal]: left behind trailing whitespace
 --> /tmp/foo/src/main.rs:2:2:11
  |
2 |     let a = 
  |            ^
  |

warning: rustfmt has failed to format. See previous 1 errors.
@calebcartwright
Copy link
Member

calebcartwright commented Oct 9, 2019

Thanks for the report @lesurp. I forget which version of rustfmt contains the fix for this (I want to say 1.4.6 or 1.4.7), but it has already been fixed.

If you try your snippet with the latest nightly version of rustfmt (1.4.9) you'll see the snippet correctly formatted without error

Oops, I was wrong sorry (my editor was trimming the trailing whitespace). I can reproduce this with the latest 1.4.9

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

Successfully merging a pull request may close this issue.

2 participants