about summary refs log tree commit diff
path: root/tests/ui/destructuring-assignment/bad-let-in-destructure.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/destructuring-assignment/bad-let-in-destructure.rs')
-rw-r--r--tests/ui/destructuring-assignment/bad-let-in-destructure.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/destructuring-assignment/bad-let-in-destructure.rs b/tests/ui/destructuring-assignment/bad-let-in-destructure.rs
new file mode 100644
index 00000000000..222557a8975
--- /dev/null
+++ b/tests/ui/destructuring-assignment/bad-let-in-destructure.rs
@@ -0,0 +1,14 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/141844>.
+
+fn main() {
+  // The following expression gets desugared into something like:
+  // ```
+  // let (lhs,) = x; (let x = 1) = lhs;
+  // ```
+  // This used to ICE since we haven't yet declared the type for `x` when
+  // checking the first desugared statement, whose RHS resolved to `x` since
+  // in the AST, the `let` expression was visited first.
+  (let x = 1,) = x;
+  //~^ ERROR expected expression, found `let` statement
+  //~| ERROR invalid left-hand side of assignment
+}