Skip to content

Commit

Permalink
Auto merge of #126597 - estebank:unicode-output, r=fmease
Browse files Browse the repository at this point in the history
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)
bors committed Nov 11, 2024
2 parents 143ce09 + acf6344 commit 42b2496
Showing 38 changed files with 2,362 additions and 315 deletions.
716 changes: 589 additions & 127 deletions compiler/rustc_errors/src/emitter.rs

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ use termcolor::{ColorSpec, WriteColor};

use crate::diagnostic::IsLint;
use crate::emitter::{
ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType,
ColorConfig, Destination, Emitter, HumanEmitter, HumanReadableErrorType, OutputTheme,
should_show_source_code,
};
use crate::registry::Registry;
@@ -377,6 +377,11 @@ impl Diagnostic {
.terminal_url(je.terminal_url)
.ui_testing(je.ui_testing)
.ignored_directories_in_source_blocks(je.ignored_directories_in_source_blocks.clone())
.theme(if let HumanReadableErrorType::Unicode = je.json_rendered {
OutputTheme::Unicode
} else {
OutputTheme::Ascii
})
.emit_diagnostic(diag);
let buf = Arc::try_unwrap(buf.0).unwrap().into_inner().unwrap();
let buf = String::from_utf8(buf).unwrap();
1,401 changes: 1,289 additions & 112 deletions compiler/rustc_parse/src/parser/tests.rs

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
@@ -1721,6 +1721,9 @@ pub fn parse_json(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> Json
for sub_option in option.split(',') {
match sub_option {
"diagnostic-short" => json_rendered = HumanReadableErrorType::Short,
"diagnostic-unicode" => {
json_rendered = HumanReadableErrorType::Unicode;
}
"diagnostic-rendered-ansi" => json_color = ColorConfig::Always,
"artifacts" => json_artifact_notifications = true,
"unused-externs" => json_unused_externs = JsonUnusedExterns::Loud,
@@ -1767,14 +1770,17 @@ pub fn parse_error_format(
ErrorOutputType::Json { pretty: true, json_rendered, color_config: json_color }
}
Some("short") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Short, color),
Some("human-unicode") => {
ErrorOutputType::HumanReadable(HumanReadableErrorType::Unicode, color)
}
Some(arg) => {
early_dcx.abort_if_error_and_set_error_format(ErrorOutputType::HumanReadable(
HumanReadableErrorType::Default,
color,
));
early_dcx.early_fatal(format!(
"argument for `--error-format` must be `human`, `json` or \
`short` (instead was `{arg}`)"
"argument for `--error-format` must be `human`, `human-annotate-rs`, \
`human-unicode`, `json`, `pretty-json` or `short` (instead was `{arg}`)"
))
}
}
@@ -1827,18 +1833,21 @@ pub fn parse_crate_edition(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches
fn check_error_format_stability(
early_dcx: &EarlyDiagCtxt,
unstable_opts: &UnstableOptions,
error_format: ErrorOutputType,
format: ErrorOutputType,
) {
if !unstable_opts.unstable_options {
if let ErrorOutputType::Json { pretty: true, .. } = error_format {
early_dcx.early_fatal("`--error-format=pretty-json` is unstable");
}
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet, _) =
error_format
{
early_dcx.early_fatal("`--error-format=human-annotate-rs` is unstable");
}
}
if unstable_opts.unstable_options {
return;
}
let format = match format {
ErrorOutputType::Json { pretty: true, .. } => "pretty-json",
ErrorOutputType::HumanReadable(format, _) => match format {
HumanReadableErrorType::AnnotateSnippet => "human-annotate-rs",
HumanReadableErrorType::Unicode => "human-unicode",
_ => return,
},
_ => return,
};
early_dcx.early_fatal(format!("`--error-format={format}` is unstable"))
}

fn parse_output_types(
14 changes: 13 additions & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,9 @@ use rustc_data_structures::sync::{
};
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
use rustc_errors::codes::*;
use rustc_errors::emitter::{DynEmitter, HumanEmitter, HumanReadableErrorType, stderr_destination};
use rustc_errors::emitter::{
DynEmitter, HumanEmitter, HumanReadableErrorType, OutputTheme, stderr_destination,
};
use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry;
use rustc_errors::{
@@ -966,6 +968,11 @@ fn default_emitter(
.macro_backtrace(macro_backtrace)
.track_diagnostics(track_diagnostics)
.terminal_url(terminal_url)
.theme(if let HumanReadableErrorType::Unicode = kind {
OutputTheme::Unicode
} else {
OutputTheme::Ascii
})
.ignored_directories_in_source_blocks(
sopts.unstable_opts.ignore_directory_in_diagnostics_source_blocks.clone(),
);
@@ -1470,6 +1477,11 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
let short = kind.short();
Box::new(
HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
.theme(if let HumanReadableErrorType::Unicode = kind {
OutputTheme::Unicode
} else {
OutputTheme::Ascii
})
.short_message(short),
)
}
4 changes: 4 additions & 0 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
@@ -2223,6 +2223,10 @@ pub fn char_width(ch: char) -> usize {
}
}

pub fn str_width(s: &str) -> usize {
s.chars().map(char_width).sum()
}

/// Normalizes the source code and records the normalizations.
fn normalize_src(src: &mut String) -> Vec<NormalizedPos> {
let mut normalized_pos = vec![];
9 changes: 8 additions & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::unord::UnordSet;
use rustc_errors::codes::*;
use rustc_errors::emitter::{DynEmitter, HumanEmitter, stderr_destination};
use rustc_errors::emitter::{
DynEmitter, HumanEmitter, HumanReadableErrorType, OutputTheme, stderr_destination,
};
use rustc_errors::json::JsonEmitter;
use rustc_errors::{ErrorGuaranteed, TerminalUrl};
use rustc_feature::UnstableFeatures;
@@ -154,6 +156,11 @@ pub(crate) fn new_dcx(
.teach(unstable_opts.teach)
.diagnostic_width(diagnostic_width)
.track_diagnostics(unstable_opts.track_diagnostics)
.theme(if let HumanReadableErrorType::Unicode = kind {
OutputTheme::Unicode
} else {
OutputTheme::Ascii
})
.ui_testing(unstable_opts.ui_testing),
)
}
5 changes: 5 additions & 0 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
@@ -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 => {
20 changes: 10 additions & 10 deletions src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error: empty line after doc comment
|
LL | / /// for the crate
LL | |
| |_
| |_^
LL | fn first_in_crate() {}
| ------------------- the comment documents this function
|
@@ -22,7 +22,7 @@ error: empty line after doc comment
|
LL | / /// for the module
LL | |
| |_
| |_^
LL | fn first_in_module() {}
| -------------------- the comment documents this function
|
@@ -39,7 +39,7 @@ error: empty line after doc comment
|
LL | / /// # Indented
LL | |
| |_
| |_^
LL | /// Blank line
LL | fn indented() {}
| ------------- the comment documents this function
@@ -55,7 +55,7 @@ error: empty line after doc comment
|
LL | / /// This should produce a warning
LL | |
| |_
| |_^
LL | fn with_doc_and_newline() {}
| ------------------------- the comment documents this function
|
@@ -69,7 +69,7 @@ LL | |
LL | | /** This is also a doc comment and is part of the warning
LL | | */
LL | |
| |_
| |_^
...
LL | fn three_attributes() {}
| --------------------- the comment documents this function
@@ -82,7 +82,7 @@ error: empty line after doc comment
LL | / /// docs for `old_code`
LL | | // fn old_code() {}
LL | |
| |_
| |_^
LL | fn new_code() {}
| ------------- the comment documents this function
|
@@ -102,7 +102,7 @@ LL | | /// Docs
LL | | /// for OldB
LL | | // struct OldB;
LL | |
| |_
| |_^
...
LL | struct Multiple;
| --------------- the comment documents this struct
@@ -125,7 +125,7 @@ LL | / /**
LL | | * Meant to be inner doc comment
LL | | */
LL | |
| |_
| |_^
LL | fn first_in_module() {}
| -------------------- the comment documents this function
|
@@ -143,7 +143,7 @@ LL | | * Docs for `old_code`
LL | | */
LL | | /* fn old_code() {} */
LL | |
| |_
| |_^
...
LL | fn new_code() {}
| ------------- the comment documents this function
@@ -161,7 +161,7 @@ error: empty line after doc comment
LL | / /// Docs for `old_code2`
LL | | /* fn old_code2() {} */
LL | |
| |_
| |_^
LL | /// Docs for `new_code2`
LL | fn new_code2() {}
| -------------- the comment documents this function
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error: empty line after outer attribute
|
LL | / #[crate_type = "lib"]
LL | |
| |_
| |_^
LL | fn first_in_crate() {}
| ------------------- the attribute applies to this function
|
@@ -20,7 +20,7 @@ error: empty line after outer attribute
|
LL | / #[inline]
LL | |
| |_
| |_^
LL | /// some comment
LL | fn with_one_newline_and_comment() {}
| --------------------------------- the attribute applies to this function
@@ -32,7 +32,7 @@ error: empty line after outer attribute
|
LL | / #[inline]
LL | |
| |_
| |_^
LL | fn with_one_newline() {}
| --------------------- the attribute applies to this function
|
@@ -44,7 +44,7 @@ error: empty lines after outer attribute
LL | / #[crate_type = "lib"]
LL | |
LL | |
| |_
| |_^
LL | fn with_two_newlines() {}
| ---------------------- the attribute applies to this function
|
@@ -59,7 +59,7 @@ error: empty line after outer attribute
|
LL | / #[doc = "doc attributes should be considered attributes"]
LL | |
| |_
| |_^
LL | enum Baz {
| -------- the attribute applies to this enum
|
@@ -70,7 +70,7 @@ error: empty line after outer attribute
|
LL | / #[repr(C)]
LL | |
| |_
| |_^
LL | struct Foo {
| ---------- the attribute applies to this struct
|
@@ -81,7 +81,7 @@ error: empty line after outer attribute
|
LL | / #[allow(dead_code)]
LL | |
| |_
| |_^
LL | mod foo {}
| ------- the attribute applies to this module
|
@@ -93,7 +93,7 @@ error: empty line after outer attribute
LL | / #[inline]
LL | | // Still lint cases where the empty line does not immediately follow the attribute
LL | |
| |_
| |_^
LL | fn comment_before_empty_line() {}
| ------------------------------ the attribute applies to this function
|
@@ -106,7 +106,7 @@ LL | / #[allow(unused)]
LL | |
LL | | // This comment is isolated
LL | |
| |_
| |_^
LL | pub fn isolated_comment() {}
| ------------------------- the attribute applies to this function
|
10 changes: 5 additions & 5 deletions src/tools/clippy/tests/ui/four_forward_slashes.stderr
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
|
LL | / //// whoops
LL | | fn a() {}
| |_
| |_^
|
= note: `-D clippy::four-forward-slashes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]`
@@ -18,7 +18,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
LL | / //// whoops
LL | | #[allow(dead_code)]
LL | | fn b() {}
| |_
| |_^
|
help: make this a doc comment by removing one `/`
|
@@ -32,7 +32,7 @@ LL | / //// whoops
LL | | //// two borked comments!
LL | | #[track_caller]
LL | | fn c() {}
| |_
| |_^
|
help: turn these into doc comments by removing one `/`
|
@@ -46,7 +46,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
LL | / //// between attributes
LL | | #[allow(dead_code)]
LL | | fn g() {}
| |_
| |_^
|
help: make this a doc comment by removing one `/`
|
@@ -58,7 +58,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
|
LL | / //// not very start of contents
LL | | fn h() {}
| |_
| |_^
|
help: make this a doc comment by removing one `/`
|
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
|
LL | / //// borked doc comment on the first line. doesn't combust!
LL | | fn a() {}
| |_
| |_^
|
= note: `-D clippy::four-forward-slashes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]`
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ LL | | /// A much longer explanation that goes into a lot more detail about
LL | | /// how the thing works, possibly with doclinks and so one,
LL | | /// and probably spanning a many rows. Blablabla, it needs to be over
LL | | /// 200 characters so I needed to write something longeeeeeeer.
| |_
| |_^
|
= note: `-D clippy::too-long-first-doc-paragraph` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`
4 changes: 2 additions & 2 deletions src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ error: first doc comment paragraph is too long
LL | / /// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
LL | | /// gravida non lacinia at, rhoncus eu lacus.
| |_
| |_^

error: first doc comment paragraph is too long
--> tests/ui/too_long_first_doc_paragraph.rs:36:1
@@ -32,7 +32,7 @@ LL | / /// Lorem
LL | | /// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
LL | | /// gravida non lacinia at, rhoncus eu lacus.
| |_
| |_^

error: aborting due to 3 previous errors

2 changes: 1 addition & 1 deletion tests/rustdoc-ui/invalid-syntax.stderr
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ warning: could not parse code block as Rust code
LL | /// \____/
| _________^
LL | | ///
| |_
| |_^
|
= note: error from rustc: unknown start of token: \

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion tests/ui/codemap_tests/huge_multispan_highlight.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//@ compile-flags: --error-format=human --color=always
//@ revisions: ascii unicode
//@ compile-flags: --color=always
//@[ascii] compile-flags: --error-format=human
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
//@ ignore-windows
fn main() {
let _ = match true {
116 changes: 116 additions & 0 deletions tests/ui/codemap_tests/huge_multispan_highlight.unicode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<Result<Result<(), Result<Result<(), Result<Result<(), Option<{integer}>>, ...>>, ...>>, ...> as Future>::Error == Foo`
--> $DIR/E0271.rs:18:5
--> $DIR/E0271.rs:20:5
|
LL | / Box::new(
LL | | Ok::<_, ()>(
@@ -11,7 +11,7 @@ LL | | )
| |_____^ type mismatch resolving `<Result<Result<(), Result<Result<(), ...>, ...>>, ...> as Future>::Error == Foo`
|
note: expected this to be `Foo`
--> $DIR/E0271.rs:8:18
--> $DIR/E0271.rs:10:18
|
LL | type Error = E;
| ^
6 changes: 4 additions & 2 deletions tests/ui/diagnostic-width/E0271.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ compile-flags: --diagnostic-width=40
//@ revisions: ascii unicode
//@[ascii] compile-flags: --diagnostic-width=40
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode --diagnostic-width=40
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
trait Future {
type Error;
@@ -15,7 +17,7 @@ impl<T> Future for Option<T> {
struct Foo;

fn foo() -> Box<dyn Future<Error=Foo>> {
Box::new( //~ ERROR E0271
Box::new( //[ascii]~ ERROR E0271
Ok::<_, ()>(
Err::<(), _>(
Ok::<_, ()>(
22 changes: 22 additions & 0 deletions tests/ui/diagnostic-width/E0271.unicode.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0271]: type mismatch resolving `<Result<Result<(), Result<Result<(), Result<Result<(), Option<{integer}>>, ...>>, ...>>, ...> as Future>::Error == Foo`
╭▸ $DIR/E0271.rs:20:5
LL │ ┏ Box::new(
LL │ ┃ Ok::<_, ()>(
LL │ ┃ Err::<(), _>(
LL │ ┃ Ok::<_, ()>(
‡ ┃
LL │ ┃ )
LL │ ┃ )
│ ┗━━━━━┛ type mismatch resolving `<Result<Result<(), Result<Result<(), ...>, ...>>, ...> as Future>::Error == Foo`
╰╴
note: expected this to be `Foo`
╭▸ $DIR/E0271.rs:10:18
LL │ type Error = E;
│ ━
╰ note: required for the cast from `Box<Result<Result<(), Result<Result<(), Result<Result<(), Option<{integer}>>, ()>>, ()>>, ()>>` to `Box<(dyn Future<Error = Foo> + 'static)>`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0271`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/flag-human.rs:7:17
--> $DIR/flag-human.rs:9:17
|
LL | ..._: () = 42;
| -- ^^ expected `()`, found integer
6 changes: 4 additions & 2 deletions tests/ui/diagnostic-width/flag-human.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//@ compile-flags: --diagnostic-width=20
//@ revisions: ascii unicode
//@[ascii] compile-flags: --diagnostic-width=20
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode --diagnostic-width=20

// This test checks that `-Z output-width` effects the human error output by restricting it to an
// arbitrarily low value so that the effect is visible.

fn main() {
let _: () = 42;
//~^ ERROR mismatched types
//[ascii]~^ ERROR mismatched types
}
11 changes: 11 additions & 0 deletions tests/ui/diagnostic-width/flag-human.unicode.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0308]: mismatched types
╭▸ $DIR/flag-human.rs:9:17
LL │ …t _: () = 42;
│ ┬─ ━━ expected `()`, found integer
│ │
╰╴ expected due to this

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/long-E0308.rs:44:9
--> $DIR/long-E0308.rs:46:9
|
LL | let x: Atype<
| _____________-
@@ -20,11 +20,11 @@ LL | | ))))))))))))))))))))))))))))));
|
= note: expected struct `Atype<Btype<..., ...>, ...>`
found enum `Result<Result<..., ...>, ...>`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.ascii/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
--> $DIR/long-E0308.rs:57:26
--> $DIR/long-E0308.rs:59:26
|
LL | ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
| __________________________^
@@ -36,11 +36,11 @@ LL | | ))))))))))))))))))))))));
|
= note: expected enum `Option<Result<..., ...>>`
found enum `Result<Result<..., ...>, ...>`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.ascii/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
--> $DIR/long-E0308.rs:88:9
--> $DIR/long-E0308.rs:90:9
|
LL | let x: Atype<
| ____________-
@@ -56,11 +56,11 @@ LL | | > = ();
|
= note: expected struct `Atype<Btype<..., ...>, ...>`
found unit type `()`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.ascii/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
--> $DIR/long-E0308.rs:91:17
--> $DIR/long-E0308.rs:93:17
|
LL | let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
| ____________--___^
@@ -74,7 +74,7 @@ LL | | ))))))))))))))))))))))));
|
= note: expected unit type `()`
found enum `Result<Result<..., ...>, ...>`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.ascii/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console

error: aborting due to 4 previous errors
4 changes: 3 additions & 1 deletion tests/ui/diagnostic-width/long-E0308.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
//@ revisions: ascii unicode
//@[ascii] compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
//@[unicode] compile-flags: -Zunstable-options=yes --json=diagnostic-unicode --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash"

mod a {
82 changes: 82 additions & 0 deletions tests/ui/diagnostic-width/long-E0308.unicode.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
error[E0308]: mismatched types
╭▸ $DIR/long-E0308.rs:46:9
LL │ let x: Atype<
│ ┌─────────────┘
LL │ │ Btype<
LL │ │ Ctype<
LL │ │ Atype<
‡ │
LL │ │ i32
LL │ │ > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O…
│ │┏━━━━━│━━━┛
│ └┃─────┤
│ ┃ expected due to this
LL │ ┃ Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O…
LL │ ┃ Ok("")
LL │ ┃ ))))))))))))))))))))))))))))))
LL │ ┃ ))))))))))))))))))))))))))))));
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ expected `Atype<Btype<..., ...>, ...>`, found `Result<Result<..., ...>, ...>`
├ note: expected struct `Atype<Btype<..., ...>, ...>`
│ found enum `Result<Result<..., ...>, ...>`
├ note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.unicode/long-E0308.long-type-hash.txt'
╰ note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
╭▸ $DIR/long-E0308.rs:59:26
LL │ ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(…
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┛
LL │ ┃ Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok…
LL │ ┃ Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
LL │ ┃ ))))))))))))))))))))))))))))))
LL │ ┃ ))))))))))))))))))))))));
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ expected `Option<Result<..., ...>>`, found `Result<Result<..., ...>, ...>`
├ note: expected enum `Option<Result<..., ...>>`
│ found enum `Result<Result<..., ...>, ...>`
├ note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.unicode/long-E0308.long-type-hash.txt'
╰ note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
╭▸ $DIR/long-E0308.rs:90:9
LL │ let x: Atype<
│ ┌────────────┘
LL │ │ Btype<
LL │ │ Ctype<
LL │ │ Atype<
‡ │
LL │ │ i32
LL │ │ > = ();
│ │ │ ━━ expected `Atype<Btype<..., ...>, ...>`, found `()`
│ └─────┤
│ expected due to this
├ note: expected struct `Atype<Btype<..., ...>, ...>`
│ found unit type `()`
├ note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.unicode/long-E0308.long-type-hash.txt'
╰ note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
╭▸ $DIR/long-E0308.rs:93:17
LL │ let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(…
│ ┏━━━━━━━━━━━━┬─━━━┛
│ ┃ │
│ ┃ expected due to this
LL │ ┃ Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok…
LL │ ┃ Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
LL │ ┃ ))))))))))))))))))))))))))))))
LL │ ┃ ))))))))))))))))))))))));
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ expected `()`, found `Result<Result<..., ...>, ...>`
├ note: expected unit type `()`
│ found enum `Result<Result<..., ...>, ...>`
├ note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308.unicode/long-E0308.long-type-hash.txt'
╰ note: consider using `--verbose` to print the full type name to the console

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0369]: cannot add `&str` to `&str`
--> $DIR/non-1-width-unicode-multiline-label.rs:5:260
--> $DIR/non-1-width-unicode-multiline-label.rs:7:260
|
LL | ...ཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇...࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
| -------------- ^ -------------- &str
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//@ revisions: ascii unicode
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
// ignore-tidy-linelength

fn main() {
let unicode_is_fun = "؁‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥";
let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
//~^ ERROR cannot add `&str` to `&str`
//[ascii]~^ ERROR cannot add `&str` to `&str`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0369]: cannot add `&str` to `&str`
╭▸ $DIR/non-1-width-unicode-multiline-label.rs:7:260
LL │ …ཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉…࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
│ ┬───────────── ┯ ────────────── &str
│ │ │
│ │ `+` cannot be used to concatenate two `&str` strings
│ &str
╰ note: string concatenation requires an owned `String` on the left
help: create an owned `String` from a string reference
╭╴
LL │ let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun.to_owned() + " really fun!";
╰╴ +++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0369`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/non-whitespace-trimming-2.rs:4:311
--> $DIR/non-whitespace-trimming-2.rs:6:311
|
LL | ...13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let ...
| -- ^^ expected `()`, found integer
4 changes: 3 additions & 1 deletion tests/ui/diagnostic-width/non-whitespace-trimming-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//@ revisions: ascii unicode
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
// ignore-tidy-linelength

fn main() {
let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _: usize = 4; let _: usize = 5; let _: usize = 6; let _: usize = 7; let _: usize = 8; let _: usize = 9; let _: usize = 10; let _: usize = 11; let _: usize = 12; let _: usize = 13; let _: usize = 14; let _: usize = 15;
//~^ ERROR mismatched types
//[ascii]~^ ERROR mismatched types
}
11 changes: 11 additions & 0 deletions tests/ui/diagnostic-width/non-whitespace-trimming-2.unicode.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0308]: mismatched types
╭▸ $DIR/non-whitespace-trimming-2.rs:6:311
LL │ …= 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _:…
│ ┬─ ━━ expected `()`, found integer
│ │
╰╴ expected due to this

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion tests/ui/error-emitter/highlighting.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/ui/error-emitter/highlighting.windows.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions tests/ui/error-emitter/unicode-output.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ compile-flags: -Zunstable-options=yes --error-format=human-unicode --color=always
//@ edition:2018
//@ only-linux

use core::pin::Pin;
use core::future::Future;
use core::any::Any;

fn query(_: fn(Box<(dyn Any + Send + '_)>) -> Pin<Box<(
dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
)>>) {}

fn wrapped_fn<'a>(_: Box<(dyn Any + Send)>) -> Pin<Box<(
dyn Future<Output = Result<Box<(dyn Any + 'static)>, String>> + Send + 'static
)>> {
Box::pin(async { Err("nope".into()) })
}

fn main() {
query(wrapped_fn);
}
72 changes: 72 additions & 0 deletions tests/ui/error-emitter/unicode-output.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/ui/parser/bad-char-literals.stderr
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ error: character constant must be escaped: `\n`
LL | '
| ______^
LL | | ';
| |_
| |_^
|
help: escape the character
|

0 comments on commit 42b2496

Please sign in to comment.