Skip to content

Commit fa6dfc9

Browse files
authored
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.
2 parents 5ed746b + 6d07874 commit fa6dfc9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/libsyntax/json.rs

+7
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ impl Emitter for JsonEmitter {
112112
panic!("failed to print notification: {:?}", e);
113113
}
114114
}
115+
116+
fn should_show_explain(&self) -> bool {
117+
match self.json_rendered {
118+
HumanReadableErrorType::Short(_) => false,
119+
_ => true,
120+
}
121+
}
115122
}
116123

117124
// The following data types are provided just for serialisation.

src/test/ui/json-short.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ started: https://doc.rust-lang.org/book/
1515
"}
1616
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
1717
"}
18-
{"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`.
19-
"}

0 commit comments

Comments
 (0)