about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-25 08:03:37 +0100
committerGitHub <noreply@github.com>2025-01-25 08:03:37 +0100
commit2080d66a159e859a39806aee882d318324865b83 (patch)
treee4170e5c158d6c1d24a046f261603881aef9b1bb /tests
parent6cb2820b7e260659b959fa4be4626cdffcfb4a50 (diff)
parent91b759354c3a0f8496af6ae72b1b27fd2f880055 (diff)
downloadrust-2080d66a159e859a39806aee882d318324865b83.tar.gz
rust-2080d66a159e859a39806aee882d318324865b83.zip
Rollup merge of #136018 - estebank:long-moved-type, r=jieyouxu
Use short ty string for move errors

```
error[E0382]: use of moved value: `x`
  --> bay.rs:14:14
   |
12 | fn foo(x: D) {
   |        - move occurs because `x` has type `(((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)`, which does not implement the `Copy` trait
13 |     let _a = x;
   |              - value moved here
14 |     let _b = x; //~ ERROR use of moved value
   |              ^ value used here after move
   |
   = note: the full type name has been written to 'bay.long-type-14349227078439097973.txt'
   = note: consider using `--verbose` to print the full type name to the console
help: consider cloning the value if the performance cost is acceptable
   |
13 |     let _a = x.clone();
   |               ++++++++
```

Address 4th case in #135919.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/diagnostic-width/non-copy-type-moved.rs17
-rw-r--r--tests/ui/diagnostic-width/non-copy-type-moved.stderr20
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/diagnostic-width/non-copy-type-moved.rs b/tests/ui/diagnostic-width/non-copy-type-moved.rs
new file mode 100644
index 00000000000..a5593ad7b2a
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-copy-type-moved.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
+//@ normalize-stderr: "long-type-\d+" -> "long-type-hash"
+type A = (String, String, String, String);
+type B = (A, A, A, A);
+type C = (B, B, B, B);
+type D = (C, C, C, C);
+
+trait Trait {}
+
+fn require_trait<T: Trait>() {}
+
+fn foo(x: D) {
+    let _a = x;
+    let _b = x; //~ ERROR use of moved value
+}
+
+fn main() {}
diff --git a/tests/ui/diagnostic-width/non-copy-type-moved.stderr b/tests/ui/diagnostic-width/non-copy-type-moved.stderr
new file mode 100644
index 00000000000..da9385a5b4d
--- /dev/null
+++ b/tests/ui/diagnostic-width/non-copy-type-moved.stderr
@@ -0,0 +1,20 @@
+error[E0382]: use of moved value: `x`
+  --> $DIR/non-copy-type-moved.rs:14:14
+   |
+LL | fn foo(x: D) {
+   |        - move occurs because `x` has type `((..., ..., ..., ...), ..., ..., ...)`, which does not implement the `Copy` trait
+LL |     let _a = x;
+   |              - value moved here
+LL |     let _b = x;
+   |              ^ value used here after move
+   |
+   = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/non-copy-type-moved/non-copy-type-moved.long-type-hash.txt'
+   = note: consider using `--verbose` to print the full type name to the console
+help: consider cloning the value if the performance cost is acceptable
+   |
+LL |     let _a = x.clone();
+   |               ++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0382`.