diff options
| author | Jeremy Fitzhardinge <jeremy@goop.org> | 2023-09-09 10:03:06 -0700 |
|---|---|---|
| committer | Jeremy Fitzhardinge <jsgf@fb.com> | 2023-09-19 14:17:02 -0700 |
| commit | 54267ddc0c582b15838bc9c7741e70a8321914bf (patch) | |
| tree | eedc0e87389cf445016f64fc05168df3ed4ca522 | |
| parent | 62ad57b95a23c40b0153d1b4c1b1801d9c35b72e (diff) | |
| download | rust-54267ddc0c582b15838bc9c7741e70a8321914bf.tar.gz rust-54267ddc0c582b15838bc9c7741e70a8321914bf.zip | |
Document type field in json diagnostics.
| -rw-r--r-- | src/doc/rustc/src/json.md | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/doc/rustc/src/json.md b/src/doc/rustc/src/json.md index 11d7b5b5938..28bd04777ea 100644 --- a/src/doc/rustc/src/json.md +++ b/src/doc/rustc/src/json.md @@ -11,9 +11,11 @@ If parsing the output with Rust, the [`cargo_metadata`](https://crates.io/crates/cargo_metadata) crate provides some support for parsing the messages. -When parsing, care should be taken to be forwards-compatible with future changes -to the format. Optional values may be `null`. New fields may be added. Enumerated -fields like "level" or "suggestion_applicability" may add new values. +Each type of message has a `type` field which can be used to distinguish the +different formats. When parsing, care should be taken to be forwards-compatible +with future changes to the format. Optional values may be `null`. New fields may +be added. Enumerated fields like "level" or "suggestion_applicability" may add +new values. ## Diagnostics @@ -29,6 +31,8 @@ Diagnostics have the following format: ```javascript { + /* Type of this message */ + "type": "diagnostic", /* The primary message. */ "message": "unused variable: `x`", /* The diagnostic code. @@ -217,6 +221,8 @@ flag][option-emit] documentation. ```javascript { + /* Type of this message */ + "type": "artifact", /* The filename that was generated. */ "artifact": "libfoo.rlib", /* The kind of artifact that was generated. Possible values: @@ -239,6 +245,8 @@ information, even if the diagnostics have been suppressed (such as with an ```javascript { + /* Type of this message */ + "type": "future_incompat", /* An array of objects describing a warning that will become a hard error in the future. */ |
