-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Unicode block-drawing compiler output support #126597
base: master
Are you sure you want to change the base?
Conversation
0fb5d30
to
3b7a44f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment was marked as resolved.
This comment was marked as resolved.
Some changes occurred in tests/ui/check-cfg cc @Urgau |
r? compiler |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
57ff435
to
6fe519d
Compare
c64e042
to
171688f
Compare
☔ The latest upstream changes (presumably #130778) made this pull request unmergeable. Please resolve the merge conflicts. |
171688f
to
f8f56b6
Compare
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after rebase. sorry for the abysmal delay. I have some small nits but they shouldn't really block this PR. esp. since annotate-snippet
will likely remedy them
if margin.was_cut_left() { | ||
// We have stripped some code/whitespace from the beginning, make it clear. | ||
buffer.puts(line_offset, code_offset, "...", Style::LineNumber); | ||
buffer.puts(line_offset, code_offset, placeholder, Style::LineNumber); | ||
} | ||
if margin.was_cut_right(line_len) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super important: You could slightly tweak the comment & code inside Margin::was_cut_right
? The comment is outdated (refers to "code above" and "..."
) and hard-codes the offset (it's 6
right now; it that 2 * width(padding)
?).
I think was_cut_right
is still correct because "...".len() == 3 == "…".len()
but otoh I'm not sure if it the usizes
represent byte offsets for indexing or for displaying ("len vs width"). So might be worth double checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that below, you use placeholder.chars().map(|ch| char_width(ch)).sum()
to robustly calculate the padding
of the placeholder
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… however given the plan to push annotate-snippets
forward and eventually use it in the compiler over emitter.rs
, I'm sure if these issues matter ^^'.
if margin.was_cut_left() { | ||
// We have stripped some code/whitespace from the beginning, make it clear. | ||
buffer.puts(line_offset, code_offset, "...", Style::LineNumber); | ||
buffer.puts(line_offset, code_offset, placeholder, Style::LineNumber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't spent too much thought on this but I wonder if things would break (offsets, alignments) if OutputTheme::Ascii.margin().len() != OutputTheme::Unicode.margin().len()
(which coincidentally isn't the case for ...
and …
so things just work out). Anyway, see comment chain directly below.
@@ -1102,7 +1155,11 @@ impl HumanEmitter { | |||
let style = | |||
if annotation.is_primary { Style::LabelPrimary } else { Style::LabelSecondary }; | |||
let (pos, col) = if pos == 0 { | |||
(pos + 1, (annotation.end_col.display + 1).saturating_sub(left)) | |||
if annotation.end_col.display == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe leave a comment why this is necessary?
@@ -2082,7 +2249,7 @@ impl HumanEmitter { | |||
buffer.putc( | |||
row_num, | |||
(padding as isize + p) as usize, | |||
if part.is_addition(sm) { '+' } else { '~' }, | |||
if part.is_addition(sm) { '+' } else { self.diff() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: For annotate-snippet
, it would be nice if symbols like +
that currently don't vary by OutputTheme
get moved to the "palette".
f8f56b6
to
2af9d09
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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 | ^^^^^^^^ ```
2af9d09
to
eb55252
Compare
d9c8f15
to
b53c0cb
Compare
@bors r+ |
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: ![rustc output with unicode box drawing characters](https://github.com/rust-lang/rust/assets/1606434/d210b79a-6579-4407-9706-ba8edc6e9f25) Before: ![current rustc output with ASCII art](https://github.com/rust-lang/rust/assets/1606434/5aecccf8-a6ee-4469-8b39-72fb0d979a9f)
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
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:
Before:
After:
Before: