rust-lang/rustfmt

Add JSON output for errors

Open

#4.369 geöffnet am 7. Aug. 2020

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (760 Forks)batch import
A-emittersC-feature-requestE-help-wantedP-lowhacktoberfest

Repository-Metriken

Stars
 (4.893 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 67T) (5 gemergte PRs in 30 T)

Beschreibung

There is already an --emit json option that emits formatting changes as JSON. However if Rustfmt encounters a parse error it prints the error to stderr in human readable form and exits with error code 1.

$ rustfmt --emit json lib.rs
error: expected one of `!` or `::`, found `<eof>`
  --> /.../src/lib.rs:16:1
   |
16 | sdf
   | ^^^ expected one of `!` or `::`

failed to parse Real("/.../src/lib.rs")

It would be helpful in some situations to be able to have these errors in JSON format too. For example for IDE integration or CI. (One of my coworkers is using a horrible regex to parse this, against my advice!)

I think an --emit-errors json option would be reasonable.

  • rustfmt version: rustfmt 2.0.0-rc.2-nightly (e91edf56 2020-08-04)
  • From where did you install rustfmt?: Git master, from yesterday.

Contributor Guide