-
Notifications
You must be signed in to change notification settings - Fork 888
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
Trailing whitespace followed by long unbreakable line causes error[internal]: left behind trailing whitespace #5711
Comments
rustfmt typically doesn't play nicely with generated code. There are other closed issues, but you can check out #5422 as an example.
rustfmt is bound by the
Leaning towards this as a solution to allow users to ignore |
I see, thanks for explaining. I didn't realize |
FWIW we're planning on doing this for both error_on_line_overflow (#3391) and error_on_unformatted, just that like many of the dev tools teams we've extremely limited bandwidth and doing so isn't a top priority |
Thank you for your explanation. I just got stuck at the same point. Sadly Visual Code does not mention any error and my code (which usually gets formatted automatically) just remained unformatted and I was wondering. |
thank you for all your work on rustfmt! I hit this organically (i.e. non-generated code), glad to see it's already a known issue. I hope you get more development resources to keep making excellent dev tools :) |
I've just hit this issue, with a single trailing space in a match arm... reporting details in case this version of the problem has not been seen. Here is the affected code: fn determine_instructions(ng: &Option<NextGap>) -> String {
let message = match ng {
None => "No gaps to fill, done! Press 'S' to save.".to_string(),
Some(ng) =>
format!("Next gap: {}, after {}. Click to place a point, BS to remove a point, 'N' to finish the section, 'S' to save.", ng.gap, ng.previous)
};
... There is a trailing space after the I get this error:
I just noticed that this file stopped formatting automatically on save (neovim), but the editor did not surface the As suggested above, I think making this a soft error and continuing with the rest of the file is a good option. Many thanks... I love that there is just one formatting standard for Rust! |
Input code
(Note, the 4th line contains 12 spaces, which you can see if you select the text.)
Actual result
Expected result
Here are some possibilities, from best to worst (IMO):
error_on_unformatted=false
would, but it does not).If you're running rustfmt manually on your own code this isn't such a big deal. But in my case I am running it automatically on Rust bindings code generated by a program. I want to fail the whole program is rustfmt fails on a real problem, like invalid Rust syntax. I don't want it to fail just because it wasn't able to format optimally. One solution (at least for this example) is to make
max_width
very large, but that makes everything else less readable. The whole point of running rustfmt is so I can generate ugly code without worrying about formatting.The text was updated successfully, but these errors were encountered: