Open
Description
Input code
fn f() {
match x {
0 => S {
},
_ => AAAAAAAAA,
}
}
(Note, the 4th line contains 12 spaces, which you can see if you select the text.)
Actual result
$ rustfmt file.rs --config max_width=20
error[internal]: left behind trailing whitespace
--> /usr/local/google/home/mkember/a.rs:4:4:1
|
4 |
| ^^^^^^^^^^^^
|
warning: rustfmt has failed to format. See previous 1 errors.
$ echo $?
1
Expected result
Here are some possibilities, from best to worst (IMO):
- Successfully delete the trailing whitespace. I'm not sure why the long line that follows prevents it from doing so.
- Print a warning that it wasn't able to remove trailing whitespace, but still succeed (exit status 0).
- Provide an option that makes such errors non-fatal (I though
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.