Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors are not always output as JSON #45

Closed
fmdkdd opened this issue Dec 12, 2016 · 1 comment
Closed

Errors are not always output as JSON #45

fmdkdd opened this issue Dec 12, 2016 · 1 comment
Assignees

Comments

@fmdkdd
Copy link
Member

fmdkdd commented Dec 12, 2016

By passing the --error-format json to cargo rustc, we have error messages as JSON only for the final rustc invocation. Any intermediary compilation will still output error messages in the human-readable format.

For example, if the file examples/foo.rs requires the library crate src/lib.rs which contains errors, then when compiling the library crate directly we get the error as JSON, but compiling the examples/foo target, we get the same error as human-readable output. The parser for rust error messages in Flycheck will choke, and we'll get a "suspicious state" error.

At this stage, there are two solutions, all with downsides.

  1. We can pass the --error-format json option in RUSTFLAGS when invoking cargo. This way, all invocations of rustc by cargo will output their errors as JSON.
    The downside is that using different RUSTFLAGS in successive invocation of cargo will trigger a recompilation. That is, if we pass RUSTFLAGS='--error-format json' to cargo in Flycheck, and the user manually calls cargo build after that, all dependencies will have to be recompiled. This can take time, especially for larger crates.

  2. To avoid the downside of RUSTFLAGS, the --message-format json flag was recently added (see Add --message-format flag. rust-lang/cargo#3000) to cargo. By passing this flag, we can have JSON messages for all rustc invocations, without retriggerring compilation (because this flag is known by cargo to have no effect on compilation output).
    The downside is that this flag was is currently not compatible with -Z no-trans on rust stable (see cargo rustc --message-format=json fails to parse stderr of rustc rust-lang/cargo#3390). It works on nightly, but requires a slight adjustment to the rust parser.

So option 2 is better, but will only be available once rust-lang/cargo#3390 is fixed and that fix has landed in stable, because I don't think we want to cut support for rust stable.

@fmdkdd fmdkdd added the blocked label Dec 12, 2016
@fmdkdd fmdkdd self-assigned this Dec 12, 2016
@fmdkdd
Copy link
Member Author

fmdkdd commented Feb 7, 2017

Fixed by flycheck/flycheck#1201.

@fmdkdd fmdkdd closed this as completed Feb 7, 2017
@fmdkdd fmdkdd removed the blocked label Mar 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant