Skip to content

Commit

Permalink
Document type field in json diagnostics.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgf committed Sep 19, 2023
1 parent 62ad57b commit 54267dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/doc/rustc/src/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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.
*/
Expand Down

0 comments on commit 54267dd

Please sign in to comment.