rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.21k stars 1.6k forks source link

Report rustfmt errors to the user, and use partial formatting even if there was an error #10752

Open kpreid opened 2 years ago

kpreid commented 2 years ago

Currently, rust-analyzer always assumes that rustfmt exiting with error is an uninteresting syntax error report, and skips reformatting the file. This behavior is suboptimal in at least two cases:

In both of these cases, it would be better to

Given the stated rationale of ... otherwise an error is surfaced to the user on top of the syntax error diagnostics they're already receiving ..., perhaps a good compromise would be to report rustfmt errors only if there are no other errors.

It also might be necessary to modify rustfmt to give distinct exit codes for “could not parse” and “parsed and formatted but with errors/warnings”. It might help to give rustfmt a file rather than pipes. I'm not familiar with exactly what interfaces/behaviors rustfmt currently offers.

simbleau commented 2 years ago

Here to put respect on this issue.