Skip to content

Commit 1d78004

Browse files
estebankfmease
authored andcommitted
Add Unicode block-drawing compiler output support
Add nightly-only theming support to rustc output using Unicode box drawing characters instead of ASCII-art to draw the terminal UI: After: ``` error: foo ╭▸ test.rs:3:3 │ 3 │ X0 Y0 Z0 │ ┌───╿──│──┘ │ ┌│───│──┘ │ ┏││━━━┙ │ ┃││ 4 │ ┃││ X1 Y1 Z1 5 │ ┃││ X2 Y2 Z2 │ ┃│└────╿──│──┘ `Z` label │ ┃└─────│──┤ │ ┗━━━━━━┥ `Y` is a good letter too │ `X` is a good letter ╰╴ note: bar ╭▸ test.rs:4:3 │ 4 │ ┏ X1 Y1 Z1 5 │ ┃ X2 Y2 Z2 6 │ ┃ X3 Y3 Z3 │ ┗━━━━━━━━━━┛ ├ note: bar ╰ note: baz note: qux ╭▸ test.rs:4:3 │ 4 │ X1 Y1 Z1 ╰╴ ━━━━━━━━ ``` Before: ``` error: foo --> test.rs:3:3 | 3 | X0 Y0 Z0 | ___^__-__- | |___|__| | ||___| | ||| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label | ||_____|__| | |______| `Y` is a good letter too | `X` is a good letter | note: bar --> test.rs:4:3 | 4 | / X1 Y1 Z1 5 | | X2 Y2 Z2 6 | | X3 Y3 Z3 | |__________^ = note: bar = note: baz note: qux --> test.rs:4:3 | 4 | X1 Y1 Z1 | ^^^^^^^^ ```
1 parent f61306d commit 1d78004

37 files changed

+2339
-295
lines changed

compiler/rustc_errors/src/emitter.rs

+583-120
Large diffs are not rendered by default.

compiler/rustc_errors/src/json.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use termcolor::{ColorSpec, WriteColor};
2727

2828
use crate::diagnostic::IsLint;
2929
use crate::emitter::{
30-
ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType,
30+
ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType, OutputTheme,
3131
should_show_source_code,
3232
};
3333
use crate::registry::Registry;
@@ -377,6 +377,11 @@ impl Diagnostic {
377377
.terminal_url(je.terminal_url)
378378
.ui_testing(je.ui_testing)
379379
.ignored_directories_in_source_blocks(je.ignored_directories_in_source_blocks.clone())
380+
.theme(if let HumanReadableErrorType::Unicode = je.json_rendered {
381+
OutputTheme::Unicode
382+
} else {
383+
OutputTheme::Ascii
384+
})
380385
.emit_diagnostic(diag);
381386
let buf = Arc::try_unwrap(buf.0).unwrap().into_inner().unwrap();
382387
let buf = String::from_utf8(buf).unwrap();

0 commit comments

Comments
 (0)