diff options
| author | bors <bors@rust-lang.org> | 2024-11-11 00:00:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-11 00:00:58 +0000 |
| commit | 42b24963202f31d417a972e56e48a17e916b279b (patch) | |
| tree | a4a484ea3a381466b93c01ca6cd7da18b045e6e0 /src/librustdoc/doctest.rs | |
| parent | 143ce0920a2307b19831160a01f06f107610f1b2 (diff) | |
| parent | acf6344b42b86bf63c73632620438fc4836b0d8e (diff) | |
| download | rust-42b24963202f31d417a972e56e48a17e916b279b.tar.gz rust-42b24963202f31d417a972e56e48a17e916b279b.zip | |
Auto merge of #126597 - estebank:unicode-output, r=fmease
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. In order to enable, the flags `-Zunstable-options=yes --error-format=human-unicode` must be passed in. 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 | ^^^^^^^^ ``` After:  Before: 
Diffstat (limited to 'src/librustdoc/doctest.rs')
| -rw-r--r-- | src/librustdoc/doctest.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 11d8f1947d6..25e576e9e63 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -15,6 +15,7 @@ pub(crate) use make::DocTestBuilder; pub(crate) use markdown::test as test_markdown; use rustc_ast as ast; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; +use rustc_errors::emitter::HumanReadableErrorType; use rustc_errors::{ColorConfig, DiagCtxtHandle, ErrorGuaranteed, FatalError}; use rustc_hir::CRATE_HIR_ID; use rustc_hir::def_id::LOCAL_CRATE; @@ -520,10 +521,14 @@ fn run_test( }); if let ErrorOutputType::HumanReadable(kind, color_config) = rustdoc_options.error_format { let short = kind.short(); + let unicode = kind == HumanReadableErrorType::Unicode; if short { compiler.arg("--error-format").arg("short"); } + if unicode { + compiler.arg("--error-format").arg("human-unicode"); + } match color_config { ColorConfig::Never => { |
