Skip to content

Commit 85ba846

Browse files
committed
Fix theme config for json output (so cargo can use it)
1 parent e640d4f commit 85ba846

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compiler/rustc_errors/src/json.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use crate::emitter::{
1313
should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter,
14-
HumanReadableErrorType,
14+
HumanReadableErrorType, OutputTheme,
1515
};
1616
use crate::registry::Registry;
1717
use crate::translation::{to_fluent_args, Translate};
@@ -362,6 +362,11 @@ impl Diagnostic {
362362
.terminal_url(je.terminal_url)
363363
.ui_testing(je.ui_testing)
364364
.ignored_directories_in_source_blocks(je.ignored_directories_in_source_blocks.clone())
365+
.theme(if let HumanReadableErrorType::Unicode(_) = je.json_rendered {
366+
OutputTheme::Unicode
367+
} else {
368+
OutputTheme::Ascii
369+
})
365370
.emit_diagnostic(diag);
366371
let buf = Arc::try_unwrap(buf.0).unwrap().into_inner().unwrap();
367372
let buf = String::from_utf8(buf).unwrap();

compiler/rustc_session/src/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,9 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
16771677
for sub_option in option.split(',') {
16781678
match sub_option {
16791679
"diagnostic-short" => json_rendered = HumanReadableErrorType::Short,
1680+
"diagnostic-unicode" => {
1681+
json_rendered = HumanReadableErrorType::Unicode;
1682+
}
16801683
"diagnostic-rendered-ansi" => json_color = ColorConfig::Always,
16811684
"artifacts" => json_artifact_notifications = true,
16821685
"unused-externs" => json_unused_externs = JsonUnusedExterns::Loud,

0 commit comments

Comments
 (0)