summaryrefslogtreecommitdiffstats
path: root/tests/ui/diagnostic-width
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/diagnostic-width')
-rw-r--r--tests/ui/diagnostic-width/E0271.rs33
-rw-r--r--tests/ui/diagnostic-width/E0271.stderr23
-rw-r--r--tests/ui/diagnostic-width/flag-human.rs9
-rw-r--r--tests/ui/diagnostic-width/flag-human.stderr11
-rw-r--r--tests/ui/diagnostic-width/flag-json.rs9
-rw-r--r--tests/ui/diagnostic-width/flag-json.stderr40
-rw-r--r--tests/ui/diagnostic-width/long-E0308.rs97
-rw-r--r--tests/ui/diagnostic-width/long-E0308.stderr80
-rw-r--r--tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs7
-rw-r--r--tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr18
-rw-r--r--tests/ui/diagnostic-width/non-whitespace-trimming-2.rs6
-rw-r--r--tests/ui/diagnostic-width/non-whitespace-trimming-2.stderr11
-rw-r--r--tests/ui/diagnostic-width/non-whitespace-trimming-unicode.rs6
-rw-r--r--tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr11
-rw-r--r--tests/ui/diagnostic-width/non-whitespace-trimming.rs6
-rw-r--r--tests/ui/diagnostic-width/non-whitespace-trimming.stderr11
-rw-r--r--tests/ui/diagnostic-width/tabs-trimming.rs13
-rw-r--r--tests/ui/diagnostic-width/tabs-trimming.stderr12
-rw-r--r--tests/ui/diagnostic-width/whitespace-trimming-2.rs8
-rw-r--r--tests/ui/diagnostic-width/whitespace-trimming-2.stderr11
-rw-r--r--tests/ui/diagnostic-width/whitespace-trimming.rs6
-rw-r--r--tests/ui/diagnostic-width/whitespace-trimming.stderr11
22 files changed, 439 insertions, 0 deletions
diff --git a/tests/ui/diagnostic-width/E0271.rs b/tests/ui/diagnostic-width/E0271.rs
new file mode 100644
index 000000000..7e6b71408
--- /dev/null
+++ b/tests/ui/diagnostic-width/E0271.rs
@@ -0,0 +1,33 @@
+// compile-flags: --diagnostic-width=40
+// normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
+trait Future {
+ type Error;
+}
+
+impl<T, E> Future for Result<T, E> {
+ type Error = E;
+}
+
+impl<T> Future for Option<T> {
+ type Error = ();
+}
+
+struct Foo;
+
+fn foo() -> Box<dyn Future<Error=Foo>> {
+ Box::new( //~ ERROR E0271
+ Ok::<_, ()>(
+ Err::<(), _>(
+ Ok::<_, ()>(
+ Err::<(), _>(
+ Ok::<_, ()>(
+ Err::<(), _>(Some(5))
+ )
+ )
+ )
+ )
+ )
+ )
+}
+fn main() {
+}
diff --git a/tests/ui/diagnostic-width/E0271.stderr b/tests/ui/diagnostic-width/E0271.stderr
new file mode 100644
index 000000000..ed7b6651d
--- /dev/null
+++ b/tests/ui/diagnostic-width/E0271.stderr
@@ -0,0 +1,23 @@
+error[E0271]: type mismatch resolving `<Result<Result<(), Result<Result<(), Result<Result<(), Option<{integer}>>, ...>>, ...>>, ...> as Future>::Error == Foo`
+ --> $DIR/E0271.rs:18: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:8:18
+ |
+LL | type Error = E;
+ | ^
+ = note: required for the cast from `Result<Result<..., ...>, ...>` to the object type `dyn Future<Error = Foo>`
+ = note: the full name for the casted type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271/E0271.long-type-hash.txt'
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/diagnostic-width/flag-human.rs b/tests/ui/diagnostic-width/flag-human.rs
new file mode 100644
index 000000000..289bfbabd
--- /dev/null
+++ b/tests/ui/diagnostic-width/flag-human.rs
@@ -0,0 +1,9 @@
+// compile-flags: --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
+}
diff --git a/tests/ui/diagnostic-width/flag-human.stderr b/tests/ui/diagnostic-width/flag-human.stderr
new file mode 100644
index 000000000..393dcf2b8
--- /dev/null
+++ b/tests/ui/diagnostic-width/flag-human.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/flag-human.rs:7:17
+ |
+LL | ..._: () = 42;
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic-width/flag-json.rs b/tests/ui/diagnostic-width/flag-json.rs
new file mode 100644
index 000000000..51a1fb447
--- /dev/null
+++ b/tests/ui/diagnostic-width/flag-json.rs
@@ -0,0 +1,9 @@
+// compile-flags: --diagnostic-width=20 --error-format=json
+
+// This test checks that `-Z output-width` effects the JSON error output by restricting it to an
+// arbitrarily low value so that the effect is visible.
+
+fn main() {
+ let _: () = 42;
+ //~^ ERROR arguments to this function are incorrect
+}
diff --git a/tests/ui/diagnostic-width/flag-json.stderr b/tests/ui/diagnostic-width/flag-json.stderr
new file mode 100644
index 000000000..b21391d16
--- /dev/null
+++ b/tests/ui/diagnostic-width/flag-json.stderr
@@ -0,0 +1,40 @@
+{"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.
+
+Erroneous code examples:
+
+```compile_fail,E0308
+fn plus_one(x: i32) -> i32 {
+ x + 1
+}
+
+plus_one(\"Not a number\");
+// ^^^^^^^^^^^^^^ expected `i32`, found `&str`
+
+if \"Not a bool\" {
+// ^^^^^^^^^^^^ expected `bool`, found `&str`
+}
+
+let x: f32 = \"Not a float\";
+// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
+// |
+// expected due to this
+```
+
+This error occurs when an expression was used in a place where the compiler
+expected an expression of a different type. It can occur in several cases, the
+most common being when calling a function and passing an argument which has a
+different type than the matching type in the function declaration.
+"},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":243,"byte_end":245,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":238,"byte_end":240,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
+ --> $DIR/flag-json.rs:7:17
+ |
+LL | ..._: () = 42;
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+"}
+{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
+
+"}
+{"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.
+"}
diff --git a/tests/ui/diagnostic-width/long-E0308.rs b/tests/ui/diagnostic-width/long-E0308.rs
new file mode 100644
index 000000000..f021f1029
--- /dev/null
+++ b/tests/ui/diagnostic-width/long-E0308.rs
@@ -0,0 +1,97 @@
+// compile-flags: --diagnostic-width=60
+// normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
+
+mod a {
+ // Force the "short path for unique types" machinery to trip up
+ pub struct Atype;
+ pub struct Btype;
+ pub struct Ctype;
+}
+
+mod b {
+ pub struct Atype<T, K>(T, K);
+ pub struct Btype<T, K>(T, K);
+ pub struct Ctype<T, K>(T, K);
+}
+
+use b::*;
+
+fn main() {
+ let x: Atype<
+ Btype<
+ Ctype<
+ Atype<
+ Btype<
+ Ctype<
+ Atype<
+ Btype<
+ Ctype<i32, i32>,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ > = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+ Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+ Ok("")
+ ))))))))))))))))))))))))))))))
+ ))))))))))))))))))))))))))))));
+ //~^^^^^ ERROR E0308
+
+ let _ = Some(Ok(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(
+ Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(
+ Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(Some(
+ Some(Some(Some(Some(Some(Some(Some(Some(Some("")))))))))
+ )))))))))))))))))
+ ))))))))))))))))))
+ ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+ Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+ Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
+ ))))))))))))))))))))))))))))))
+ ))))))))))))))))))))))));
+ //~^^^^^ ERROR E0308
+
+ let x: Atype<
+ Btype<
+ Ctype<
+ Atype<
+ Btype<
+ Ctype<
+ Atype<
+ Btype<
+ Ctype<i32, i32>,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ >,
+ i32
+ > = ();
+ //~^ ERROR E0308
+
+ let _: () = Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+ Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(
+ Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
+ ))))))))))))))))))))))))))))))
+ ))))))))))))))))))))))));
+ //~^^^^^ ERROR E0308
+}
diff --git a/tests/ui/diagnostic-width/long-E0308.stderr b/tests/ui/diagnostic-width/long-E0308.stderr
new file mode 100644
index 000000000..1c99898bc
--- /dev/null
+++ b/tests/ui/diagnostic-width/long-E0308.stderr
@@ -0,0 +1,80 @@
+error[E0308]: mismatched types
+ --> $DIR/long-E0308.rs:44: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...
+ | | _____-___^
+ | ||_____|
+ | | expected due to this
+LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok...
+LL | | Ok("")
+LL | | ))))))))))))))))))))))))))))))
+LL | | ))))))))))))))))))))))))))))));
+ | |__________________________________^ expected struct `Atype`, found enum `Result`
+ |
+ = note: expected struct `Atype<Btype<..., ...>, ...>`
+ the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+ found enum `Result<Result<..., ...>, ...>`
+ the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+
+error[E0308]: mismatched types
+ --> $DIR/long-E0308.rs:57:26
+ |
+LL | ))))))))))))))))) == Ok(Ok(Ok(Ok(Ok(Ok(Ok(Ok(O...
+ | __________________________^
+LL | | 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 enum `Option`, found enum `Result`
+ |
+ = note: expected enum `Option<Result<..., ...>>`
+ the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+ found enum `Result<Result<..., ...>, ...>`
+ the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+
+error[E0308]: mismatched types
+ --> $DIR/long-E0308.rs:88:9
+ |
+LL | let x: Atype<
+ | ____________-
+LL | | Btype<
+LL | | Ctype<
+LL | | Atype<
+... |
+LL | | i32
+LL | | > = ();
+ | | - ^^ expected struct `Atype`, found `()`
+ | |_____|
+ | expected due to this
+ |
+ = note: expected struct `Atype<Btype<..., ...>, ...>`
+ the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/long-E0308.rs:91:17
+ |
+LL | let _: () = 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(...
+LL | | Ok(Ok(Ok(Ok(Ok(Ok(Ok("")))))))
+LL | | ))))))))))))))))))))))))))))))
+LL | | ))))))))))))))))))))))));
+ | |____________________________^ expected `()`, found enum `Result`
+ |
+ = note: expected unit type `()`
+ found enum `Result<Result<..., ...>, ...>`
+ the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs b/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs
new file mode 100644
index 000000000..1989ea886
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs
@@ -0,0 +1,7 @@
+// ignore-tidy-linelength
+
+fn main() {
+ let unicode_is_fun = "؁‱ஹ௸௵꧄.ဪ꧅⸻𒈙𒐫﷽𒌄𒈟𒍼𒁎𒀱𒌧𒅃 𒈓𒍙𒊎𒄡𒅌𒁏𒀰𒐪𒐩𒈙𒐫𪚥";
+ let _ = "ༀ༁༂༃༄༅༆༇༈༉༊་༌།༎༏༐༑༒༓༔༕༖༗༘༙༚༛༜༝༞༟༠༡༢༣༤༥༦༧༨༩༪༫༬༭༮༯༰༱༲༳༴༵༶༷༸༹༺༻༼༽༾༿ཀཁགགྷངཅཆཇ཈ཉཊཋཌཌྷཎཏཐདདྷནཔཕབབྷམཙཚཛཛྷཝཞཟའཡརལཤཥསཧཨཀྵཪཫཬ཭཮཯཰ཱཱཱིིུུྲྀཷླྀཹེཻོཽཾཿ྄ཱྀྀྂྃ྅྆྇ྈྉྊྋྌྍྎྏྐྑྒྒྷྔྕྖྗ྘ྙྚྛྜྜྷྞྟྠྡྡྷྣྤྥྦྦྷྨྩྪྫྫྷྭྮྯྰྱྲླྴྵྶྷྸྐྵྺྻྼ྽྾྿࿀࿁࿂࿃࿄࿅࿆࿇࿈࿉࿊࿋࿌࿍࿎࿏࿐࿑࿒࿓࿔࿕࿖࿗࿘࿙࿚"; let _a = unicode_is_fun + " really fun!";
+ //~^ ERROR cannot add `&str` to `&str`
+}
diff --git a/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr b/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr
new file mode 100644
index 000000000..bf277362d
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.stderr
@@ -0,0 +1,18 @@
+error[E0369]: cannot add `&str` to `&str`
+ --> $DIR/non-1-width-unicode-multiline-label.rs:5: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 previous error
+
+For more information about this error, try `rustc --explain E0369`.
diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming-2.rs b/tests/ui/diagnostic-width/non-whitespace-trimming-2.rs
new file mode 100644
index 000000000..abd9e189a
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-whitespace-trimming-2.rs
@@ -0,0 +1,6 @@
+// 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
+}
diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming-2.stderr b/tests/ui/diagnostic-width/non-whitespace-trimming-2.stderr
new file mode 100644
index 000000000..5dbb9ce45
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-whitespace-trimming-2.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/non-whitespace-trimming-2.rs:4: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 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.rs b/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.rs
new file mode 100644
index 000000000..8d4d1b162
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.rs
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+ let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4🦀🦀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆♇♏♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♨♩♪♫♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4";
+//~^ ERROR mismatched types
+}
diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr b/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr
new file mode 100644
index 000000000..1e5ff9398
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-whitespace-trimming-unicode.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/non-whitespace-trimming-unicode.rs:4:415
+ |
+LL | ...♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄...
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming.rs b/tests/ui/diagnostic-width/non-whitespace-trimming.rs
new file mode 100644
index 000000000..f6c8d345c
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-whitespace-trimming.rs
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+ let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ();
+//~^ ERROR mismatched types
+}
diff --git a/tests/ui/diagnostic-width/non-whitespace-trimming.stderr b/tests/ui/diagnostic-width/non-whitespace-trimming.stderr
new file mode 100644
index 000000000..c4ff0e168
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-whitespace-trimming.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/non-whitespace-trimming.rs:4:241
+ |
+LL | ... () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ...
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic-width/tabs-trimming.rs b/tests/ui/diagnostic-width/tabs-trimming.rs
new file mode 100644
index 000000000..ade21753b
--- /dev/null
+++ b/tests/ui/diagnostic-width/tabs-trimming.rs
@@ -0,0 +1,13 @@
+// Test for #78438: ensure underline alignment with many tabs on the left, long line on the right
+
+// ignore-tidy-linelength
+// ignore-tidy-tab
+
+ fn main() {
+ let money = 42i32;
+ match money {
+ v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
+ //~^ ERROR variable `v` is not bound in all patterns
+ v => println!("Enough money {}", v),
+ }
+ }
diff --git a/tests/ui/diagnostic-width/tabs-trimming.stderr b/tests/ui/diagnostic-width/tabs-trimming.stderr
new file mode 100644
index 000000000..6c8d9afc7
--- /dev/null
+++ b/tests/ui/diagnostic-width/tabs-trimming.stderr
@@ -0,0 +1,12 @@
+error[E0408]: variable `v` is not bound in all patterns
+ --> $DIR/tabs-trimming.rs:9:16
+ |
+LL | ... v @ 1 | 2 | 3 => panic!("You gave me too little money {}", v), // Long text here: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
+ | - ^ ^ pattern doesn't bind `v`
+ | | |
+ | | pattern doesn't bind `v`
+ | variable not in all patterns
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0408`.
diff --git a/tests/ui/diagnostic-width/whitespace-trimming-2.rs b/tests/ui/diagnostic-width/whitespace-trimming-2.rs
new file mode 100644
index 000000000..c68f678aa
--- /dev/null
+++ b/tests/ui/diagnostic-width/whitespace-trimming-2.rs
@@ -0,0 +1,8 @@
+// ignore-tidy-linelength
+
+fn foo() -> usize {
+ ()
+//~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/tests/ui/diagnostic-width/whitespace-trimming-2.stderr b/tests/ui/diagnostic-width/whitespace-trimming-2.stderr
new file mode 100644
index 000000000..97a64e603
--- /dev/null
+++ b/tests/ui/diagnostic-width/whitespace-trimming-2.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/whitespace-trimming-2.rs:4:187
+ |
+LL | ...-> usize {
+ | ----- expected `usize` because of return type
+LL | ... ()
+ | ^^ expected `usize`, found `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic-width/whitespace-trimming.rs b/tests/ui/diagnostic-width/whitespace-trimming.rs
new file mode 100644
index 000000000..f747bcf17
--- /dev/null
+++ b/tests/ui/diagnostic-width/whitespace-trimming.rs
@@ -0,0 +1,6 @@
+// ignore-tidy-linelength
+
+fn main() {
+ let _: () = 42;
+//~^ ERROR mismatched types
+}
diff --git a/tests/ui/diagnostic-width/whitespace-trimming.stderr b/tests/ui/diagnostic-width/whitespace-trimming.stderr
new file mode 100644
index 000000000..e296d4889
--- /dev/null
+++ b/tests/ui/diagnostic-width/whitespace-trimming.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+ --> $DIR/whitespace-trimming.rs:4:193
+ |
+LL | ... let _: () = 42;
+ | -- ^^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.