Rollup merge of #64753 - ehuss:json-short-explain, r=Mark-Simulacrum

Don't emit explain with json short messages.

This fixes an issue where `--error-format=json --json=diagnostic-short` would emit the "For more information about this error" message, which doesn't match the behavior of `--error-format=short` which explicitly excludes it.
This commit is contained in:
Mazdak Farrokhzad 2019-09-25 03:48:32 +02:00 committed by GitHub
commit fa6dfc995e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -112,6 +112,13 @@ impl Emitter for JsonEmitter {
panic!("failed to print notification: {:?}", e);
}
}
fn should_show_explain(&self) -> bool {
match self.json_rendered {
HumanReadableErrorType::Short(_) => false,
_ => true,
}
}
}
// The following data types are provided just for serialisation.

View file

@ -15,5 +15,3 @@ started: https://doc.rust-lang.org/book/
"}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
"}
{"message":"For more information about this error, try `rustc --explain E0601`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0601`.
"}