about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-06 13:09:59 +0100
committerGitHub <noreply@github.com>2025-02-06 13:09:59 +0100
commitc2c4d5ebfbf5ec9e028d50e5dbf363eb8ce47778 (patch)
tree3eb4dbaf3bcb6636c7b94df3b2cd1f56dedda94a /tests/ui
parentb62f318a3b77cce4809d26baa5c54dcf50ed1ce5 (diff)
parent382caf96a72443b9ad3dfa80b106212900397928 (diff)
downloadrust-c2c4d5ebfbf5ec9e028d50e5dbf363eb8ce47778.tar.gz
rust-c2c4d5ebfbf5ec9e028d50e5dbf363eb8ce47778.zip
Rollup merge of #136315 - estebank:long-ty-binop, r=SparrowLii
Use short ty string for binop and unop errors

```
error[E0369]: cannot add `(..., ..., ..., ...)` to `(..., ..., ..., ...)`
  --> $DIR/binop.rs:10:7
   |
LL |     x + x;
   |     - ^ - (..., ..., ..., ...)
   |     |
   |     (..., ..., ..., ...)
   |
   = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
   = note: consider using `--verbose` to print the full type name to the console
```
```
error[E0600]: cannot apply unary operator `!` to type `(..., ..., ..., ...)`
  --> $DIR/binop.rs:14:5
   |
LL |     !x;
   |     ^^ cannot apply unary operator `!`
   |
   = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
   = note: consider using `--verbose` to print the full type name to the console
```

CC #135919.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/diagnostic-width/binop.rs17
-rw-r--r--tests/ui/diagnostic-width/binop.stderr24
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/diagnostic-width/binop.rs b/tests/ui/diagnostic-width/binop.rs
new file mode 100644
index 00000000000..60ba40b8047
--- /dev/null
+++ b/tests/ui/diagnostic-width/binop.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
+// The regex below normalizes the long type file name to make it suitable for compare-modes.
+//@ normalize-stderr: "'\$TEST_BUILD_DIR/.*\.long-type-\d+.txt'" -> "'$$TEST_BUILD_DIR/$$FILE.long-type-hash.txt'"
+type A = (i32, i32, i32, i32);
+type B = (A, A, A, A);
+type C = (B, B, B, B);
+type D = (C, C, C, C);
+
+fn foo(x: D) {
+    x + x; //~ ERROR cannot add `(...
+}
+
+fn bar(x: D) {
+    !x; //~ ERROR cannot apply unary operator `!` to type `(...
+}
+
+fn main() {}
diff --git a/tests/ui/diagnostic-width/binop.stderr b/tests/ui/diagnostic-width/binop.stderr
new file mode 100644
index 00000000000..fd69129c33e
--- /dev/null
+++ b/tests/ui/diagnostic-width/binop.stderr
@@ -0,0 +1,24 @@
+error[E0369]: cannot add `(..., ..., ..., ...)` to `(..., ..., ..., ...)`
+  --> $DIR/binop.rs:10:7
+   |
+LL |     x + x;
+   |     - ^ - (..., ..., ..., ...)
+   |     |
+   |     (..., ..., ..., ...)
+   |
+   = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
+
+error[E0600]: cannot apply unary operator `!` to type `(..., ..., ..., ...)`
+  --> $DIR/binop.rs:14:5
+   |
+LL |     !x;
+   |     ^^ cannot apply unary operator `!`
+   |
+   = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0369, E0600.
+For more information about an error, try `rustc --explain E0369`.