Skip to content

--message-format=json doesn't emit every error message #5992

@koute

Description

@koute

Steps to reproduce:

$ cargo new foo
$ cd foo
$ echo 'yew = "= 0.4.0"' >> Cargo.toml

Replace src/main.rs with this:

#[macro_use]
extern crate yew;

fn main() {
    html! {
        <div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
            <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
        </div>
    }
}

Then if you build it:

$ cargo build --target=wasm32-unknown-unknown

you'll get the following error:

error: recursion limit reached while expanding the macro `stringify`
  --> src/main.rs:5:5
   |
5  | /     html! {
6  | |         <div>
7  | |             <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
8  | |             <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
...  |
17 | |         </div>
18 | |     }
   | |_____^
   |
   = help: consider adding a `#![recursion_limit="128"]` attribute to your crate
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

error: Could not compile `foo`.

however if you build it with:

cargo build --target=wasm32-unknown-unknown --message-format=json

then the error message is missing from the output. I'd expect cargo to emit a line with {"reason": "compiler-message", ...} just as it usually does for errors; instead it emits no "compiler-message"s, e.g. the output of this (to match only "compiler-message"s):

$ cargo build --target=wasm32-unknown-unknown --message-format=json | ruby -ne 'require "json"; require "pp"; j = JSON.parse( $_ ); if j["reason"] == "compiler-message"; pp j; end'

is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions