# Rustc's json output format

**URL:** <https://internals.rust-lang.org/t/rustcs-json-output-format/3446>\
**Category:** tools and infrastructure\
**Created:** [May 9, 2016, 9:15am UTC](https://internals.rust-lang.org/t/rustcs-json-output-format/3446 "2016-05-09T09:15:44Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![oli-obk](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/oli-obk/32/3168_2.png) [@oli-obk](https://internals.rust-lang.org/u/oli-obk)\
**Post date:** [May 17, 2016, 4:29pm UTC](https://internals.rust-lang.org/t/rustcs-json-output-format/3446/11 "2016-05-17T16:29:22Z")

</div>

So, here's my current report on the usability of the json output:

# "expected X, got Y" errors

These are split into two `children` without spans. There's a few ways that they could be improved.

1. for types, the error could give the span of the reason for the `expected`. So if it's a function argument, give a span for that argument's declaration.
2. these are so common in rustc that there's [special code](https://github.com/rust-lang/rust/pull/19870/files) processing this kind of text into multiple lines

- json should profit from this, too, maybe an `expected` field?

1. these should not be split up, but I'm not sure how to do this better, other than 2.

 ![](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/8/816396d0bdd8307bf271e67b534f8a948c2f31e6.png)

# multiple suggested imports

To automate future 1-click-solutions, instead of listing them in the current note manner, the `suggested_replacement` could be used to offer inserting a new line on the top of the file with `use xyz;`.

 ![](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/6/69d7d31afbfb4325d8572eae574c8b30219ec14d.png)

# suggestions for suggestions

1. remove the `suggested_replacement` field, and instead add a new "error `level`".
2. generally use suggestions more often. E.g. in `unresolved name` errors ![](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/7/7d75ce815fd318583b6b870b947d043f3f3b976c.png)

# the `label` field

I've so far ignored it. Many errors do not set it, and with those that do set it, I've found that I can't replace the main `message`, and that it's partially redundant with the `note`s. An example is a type-mismatch. `let _: () = 5;` gives `"type mismatch"` for the message, `expected type '()'` and `got type '_'` for the notes, and then `"expected (), found integral variable"` for the `label`. The label is nicer than the notes, but still needs the message.

I could simply show it when it's there, but I don't want to clutter the error popups with redundancy.

#Macro Expansion

I'm not sure how to improve on this yet. An alternative would be to repeat the error at every expansion location. Or just show something at the location of the expansion.

 ![](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/f/f0dbfbc6c1fcfe7ccd5e3d99dd1c1fa1203e8207.png)

#WIP

Anyway, this is a work in progress. If anyone has ideas what to try out, I'll check how it works and post some screenshots.

---

_[View the full topic](https://internals.rust-lang.org/t/rustcs-json-output-format/3446)._
