rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
5.85k stars 860 forks source link

--message-format=json panic on broken pipe #6183

Closed richardscollin closed 3 weeks ago

richardscollin commented 3 weeks ago

rustc version: 1.80.0-nightly (7c52d2db6 2024-06-03) platform: x86_64-unknown-linux-gnu

On a clean project run:

cargo +nightly fmt --message-format=json | echo ice

If the program which is being piped to (echo in this case) doesn't consume the input, the write will cause a panic in rustfmt.

rustc-ice-2024-06-04T16_38_03-53230.txt

My expected behavior is the command would fail, but it would not generate a rustc-ice-2024-06-04T16_38_03-53230.txt file or suggesting filing an issue.

ytmimi commented 3 weeks ago

Thanks for the report. This is likely a duplicate of #6089 and other reported piping issues like #2926