about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-05-14 13:42:55 +0900
committerGitHub <noreply@github.com>2022-05-14 13:42:55 +0900
commite239fd2b88b5993ddec49cdc93ba7b3edb2c56f4 (patch)
tree141881e84d4465db2ce36b1081a02c60ca3ccf68 /src
parentec14d946ae0bfffebf15aa2b53504debfedfcb39 (diff)
parent6665a4328b4076285e4c233995b5a08aeff4b603 (diff)
Rollup merge of #97031 - eholk:drop-tracking-type-error, r=compiler-errors
Drop tracking: handle invalid assignments better

Previously this test case was crashing with an index out of bounds error deep in the call to `needs_drop`. We avoid this by detecting clearly invalid assignees in the `mutate` callback and ignoring these.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs14
-rw-r--r--src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr11
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs
new file mode 100644
index 00000000000..c3423ad629f
--- /dev/null
+++ b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.rs
@@ -0,0 +1,14 @@
+// edition:2018
+// compile-flags: -Zdrop-tracking
+// Regression test for issue #73741
+// Ensures that we don't emit spurious errors when
+// a type error ocurrs in an `async fn`
+
+async fn weird() {
+    1 = 2; //~ ERROR invalid left-hand side
+
+    let mut loop_count = 0;
+    async {}.await
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr
new file mode 100644
index 00000000000..d4e3b6c3bf4
--- /dev/null
+++ b/src/test/ui/async-await/issue-73741-type-err-drop-tracking.stderr
@@ -0,0 +1,11 @@
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/issue-73741-type-err-drop-tracking.rs:8:7
+   |
+LL |     1 = 2;
+   |     - ^
+   |     |
+   |     cannot assign to this expression
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0070`.