Skip to content

error[internal]: left behind trailing whitespace #3904

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

Closed
samuela opened this issue Nov 4, 2019 · 10 comments · Fixed by #3905
Closed

error[internal]: left behind trailing whitespace #3904

samuela opened this issue Nov 4, 2019 · 10 comments · Fixed by #3905
Labels
a-comments bug Panic, non-idempotency, invalid code, etc.

Comments

@samuela
Copy link

samuela commented Nov 4, 2019

I'm trying to format a module and rustfmt is failing with

error[internal]: left behind trailing whitespace
     --> /rustybox/shell/ash.rs:13759:13759:0
      |
13759 |
      | ^^
      |

warning: rustfmt has failed to format. See previous 1 errors.

Here's the source file: ash.rs.zip

@calebcartwright
Copy link
Member

Hey @samuela - What version of rustfmt are you using?

@samuela
Copy link
Author

samuela commented Nov 4, 2019

Switching the comment from /* */ to // ... seems to have resolved it.

@samuela
Copy link
Author

samuela commented Nov 4, 2019

@calebcartwright

I'm running on the command line with

root@58f110f80b00:/rustybox# cargo fmt --version
rustfmt 1.4.9-nightly (33e3667 2019-10-07)

@samuela
Copy link
Author

samuela commented Nov 4, 2019

I have what seems to be a similar situation with this bit of code:

  checkkwd = (0x2i32 | 0x1i32) as smallint; /* unrecognized "\z": print both chars unless ' or " */
                                            
  rpp = rpp2;

where rustfmt is adamant that there must be a bunch of spaces on the second line in order to match up with the beginning / in the comment. Strangely cargo fmt doesn't throw an error in this case.

@calebcartwright
Copy link
Member

Thanks. I ask as there's been quite a few of various trailing whitespace errors fixed over the last few releases. Let me see if I can reproduce with the latest on master

@samuela
Copy link
Author

samuela commented Nov 4, 2019

Sounds good, thanks for taking a look!

@calebcartwright
Copy link
Member

Strangely cargo fmt doesn't throw an error in this case.

👀 That sounds really odd. cargo fmt basically just detects workspace info (edition, packge source file root, etc.) which it passes as args to rustfmt, but it's always rustfmt that's running

@samuela
Copy link
Author

samuela commented Nov 4, 2019

@calebcartwright Yeah, also thought it was kinda strange. Happy to provide the complete file for this case as well if you'd like.

@calebcartwright
Copy link
Member

nearly 16k lines! That looks fun 😄

I'm still getting the whitespace error with 1.4.10 (as well as a few line formatted, but exceeded maximum width errors). As far as the whitespace error, do you have a minimal reproducible example from the file you shared? That'd make it a bit easier for someone to work on a fix

@calebcartwright
Copy link
Member

calebcartwright commented Nov 4, 2019

I think you may want to open separate issues for the two other items you've noted above, and keep this issue focused on the trailing white space issue (different results between rustfmt and cargo fmt would be a major issue above and beyond a trailing whitespace error)

@topecongiro topecongiro added a-comments bug Panic, non-idempotency, invalid code, etc. labels Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants