about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-10-19 21:38:40 +0200
committerGitHub <noreply@github.com>2022-10-19 21:38:40 +0200
commite500dcb8cb7b3c1d9d6045aeb38f8a51dcce89b5 (patch)
tree780e4a46de2f6f34a29514a3a21bf3bc330fd4da /src/test
parent433f736b86e67cea31fb4e72b092ec9b0364936c (diff)
parentd38dc68aa3f4a7e859b6a84242bcfd37c03d707b (diff)
downloadrust-e500dcb8cb7b3c1d9d6045aeb38f8a51dcce89b5.tar.gz
rust-e500dcb8cb7b3c1d9d6045aeb38f8a51dcce89b5.zip
Rollup merge of #103223 - compiler-errors:deref-sugg-slow, r=wesleywiser
Use already checked RHS ty for LHS deref suggestions

There's no reason to do the `check_lhs_assignable` and RHS `check_expr_with_hint` in that order, so invert them and use the typeck results to avoid exponential blowup on error.

Fixes #103219
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/typeck/slow-lhs-suggestion.rs26
-rw-r--r--src/test/ui/typeck/slow-lhs-suggestion.stderr187
2 files changed, 213 insertions, 0 deletions
diff --git a/src/test/ui/typeck/slow-lhs-suggestion.rs b/src/test/ui/typeck/slow-lhs-suggestion.rs
new file mode 100644
index 00000000000..80dfd683524
--- /dev/null
+++ b/src/test/ui/typeck/slow-lhs-suggestion.rs
@@ -0,0 +1,26 @@
+fn main() {
+    1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+    //~^ ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+    //~| ERROR invalid left-hand side of assignment
+}
diff --git a/src/test/ui/typeck/slow-lhs-suggestion.stderr b/src/test/ui/typeck/slow-lhs-suggestion.stderr
new file mode 100644
index 00000000000..c5bf795eeee
--- /dev/null
+++ b/src/test/ui/typeck/slow-lhs-suggestion.stderr
@@ -0,0 +1,187 @@
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:95
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                                             - ^
+   |                                                                                             |
+   |                                                                                             cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:91
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                                         - ^
+   |                                                                                         |
+   |                                                                                         cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:87
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                                     - ^
+   |                                                                                     |
+   |                                                                                     cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:83
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                                 - ^
+   |                                                                                 |
+   |                                                                                 cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:79
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                             - ^
+   |                                                                             |
+   |                                                                             cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:75
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                         - ^
+   |                                                                         |
+   |                                                                         cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:71
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                     - ^
+   |                                                                     |
+   |                                                                     cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:67
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                                 - ^
+   |                                                                 |
+   |                                                                 cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:63
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                             - ^
+   |                                                             |
+   |                                                             cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:59
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                         - ^
+   |                                                         |
+   |                                                         cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:55
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                     - ^
+   |                                                     |
+   |                                                     cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:51
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                                 - ^
+   |                                                 |
+   |                                                 cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:47
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                             - ^
+   |                                             |
+   |                                             cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:43
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                         - ^
+   |                                         |
+   |                                         cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:39
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                     - ^
+   |                                     |
+   |                                     cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:35
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                                 - ^
+   |                                 |
+   |                                 cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:31
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                             - ^
+   |                             |
+   |                             cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:27
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                         - ^
+   |                         |
+   |                         cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:23
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                     - ^
+   |                     |
+   |                     cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:19
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |                 - ^
+   |                 |
+   |                 cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:15
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |             - ^
+   |             |
+   |             cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:11
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |         - ^
+   |         |
+   |         cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/slow-lhs-suggestion.rs:2:7
+   |
+LL |     1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+   |     - ^
+   |     |
+   |     cannot assign to this expression
+
+error: aborting due to 23 previous errors
+
+For more information about this error, try `rustc --explain E0070`.