Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustfmt --check: handle writing to a broken pipe gracefully
The rustfmt tool panics when any writes to the output file descriptor fail, whether sending color codes to the terminal, regular writes, or flushing stdout. It's fairly easy to hit this by accidentally writing to a broken pipe. For example, I hit this when I tried to pipe into `less` but made a typo: $ rustfmt --check src/main.rs | les panic This patch updates rustfmt to handle BrokenPipe / EPIPE failures more gracefully. Any failures lead to the program immediately exiting, since there is no sense in continuing to write to a broken pipe, except for the final flush() which doesn't need to exit early since it's already at the end of program execution. Any write errors aside from BrokenPipe still result in panic!(), since any other errors are unexpected. This leaves the program behaving the same as before for any other write errors.
- Loading branch information