about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-12-22 20:14:08 +0000
committervarkor <github@varkor.com>2019-12-23 11:17:55 +0000
commit5fa02ecc291f0a6b356fbb3b1e14649082b93a2f (patch)
tree609103e33c18049ba75063c6ce8c07ab701b5cdc /src/test
parentb7bfdbe68147f2ea8ca4870270643180bef76e02 (diff)
Add note about destructuring assignments
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/bad/bad-expr-lhs.stderr3
-rw-r--r--src/test/ui/bad/destructuring-assignment.rs21
-rw-r--r--src/test/ui/bad/destructuring-assignment.stderr111
3 files changed, 135 insertions, 0 deletions
diff --git a/src/test/ui/bad/bad-expr-lhs.stderr b/src/test/ui/bad/bad-expr-lhs.stderr
index 07cffbe97a8..61c25bb471c 100644
--- a/src/test/ui/bad/bad-expr-lhs.stderr
+++ b/src/test/ui/bad/bad-expr-lhs.stderr
@@ -29,6 +29,9 @@ LL |     (a, b) = (3, 4);
    |     ------^^^^^^^^^
    |     |
    |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
 
 error[E0070]: invalid left-hand side of assignment
   --> $DIR/bad-expr-lhs.rs:9:5
diff --git a/src/test/ui/bad/destructuring-assignment.rs b/src/test/ui/bad/destructuring-assignment.rs
new file mode 100644
index 00000000000..7112cedfd00
--- /dev/null
+++ b/src/test/ui/bad/destructuring-assignment.rs
@@ -0,0 +1,21 @@
+struct S { x: u8, y: u8 }
+
+fn main() {
+    let (a, b) = (1, 2);
+
+    (a, b) = (3, 4); //~ ERROR invalid left-hand side of assignment
+    (a, b) += (3, 4); //~ ERROR invalid left-hand side of assignment
+    //~^ ERROR binary assignment operation `+=` cannot be applied
+
+    [a, b] = [3, 4]; //~ ERROR invalid left-hand side of assignment
+    [a, b] += [3, 4]; //~ ERROR invalid left-hand side of assignment
+    //~^ ERROR binary assignment operation `+=` cannot be applied
+
+    let s = S { x: 3, y: 4 };
+
+    S { x: a, y: b } = s; //~ ERROR invalid left-hand side of assignment
+    S { x: a, y: b } += s; //~ ERROR invalid left-hand side of assignment
+    //~^ ERROR binary assignment operation `+=` cannot be applied
+
+    S { x: a, ..s } = S { x: 3, y: 4 }; //~ ERROR invalid left-hand side of assignment
+}
diff --git a/src/test/ui/bad/destructuring-assignment.stderr b/src/test/ui/bad/destructuring-assignment.stderr
new file mode 100644
index 00000000000..676576b7bc5
--- /dev/null
+++ b/src/test/ui/bad/destructuring-assignment.stderr
@@ -0,0 +1,111 @@
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:6:5
+   |
+LL |     (a, b) = (3, 4);
+   |     ------^^^^^^^^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error[E0368]: binary assignment operation `+=` cannot be applied to type `({integer}, {integer})`
+  --> $DIR/destructuring-assignment.rs:7:5
+   |
+LL |     (a, b) += (3, 4);
+   |     ------^^^^^^^^^^
+   |     |
+   |     cannot use `+=` on type `({integer}, {integer})`
+   |
+   = note: an implementation of `std::ops::AddAssign` might be missing for `({integer}, {integer})`
+
+error[E0067]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:7:12
+   |
+LL |     (a, b) += (3, 4);
+   |     ------ ^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:10:5
+   |
+LL |     [a, b] = [3, 4];
+   |     ------^^^^^^^^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error[E0368]: binary assignment operation `+=` cannot be applied to type `[{integer}; 2]`
+  --> $DIR/destructuring-assignment.rs:11:5
+   |
+LL |     [a, b] += [3, 4];
+   |     ------^^^^^^^^^^
+   |     |
+   |     cannot use `+=` on type `[{integer}; 2]`
+   |
+   = note: an implementation of `std::ops::AddAssign` might be missing for `[{integer}; 2]`
+
+error[E0067]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:11:12
+   |
+LL |     [a, b] += [3, 4];
+   |     ------ ^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:16:5
+   |
+LL |     S { x: a, y: b } = s;
+   |     ----------------^^^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error[E0368]: binary assignment operation `+=` cannot be applied to type `S`
+  --> $DIR/destructuring-assignment.rs:17:5
+   |
+LL |     S { x: a, y: b } += s;
+   |     ----------------^^^^^
+   |     |
+   |     cannot use `+=` on type `S`
+   |
+   = note: an implementation of `std::ops::AddAssign` might be missing for `S`
+
+error[E0067]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:17:22
+   |
+LL |     S { x: a, y: b } += s;
+   |     ---------------- ^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error[E0070]: invalid left-hand side of assignment
+  --> $DIR/destructuring-assignment.rs:20:5
+   |
+LL |     S { x: a, ..s } = S { x: 3, y: 4 };
+   |     ---------------^^^^^^^^^^^^^^^^^^^
+   |     |
+   |     cannot assign to this expression
+   |
+   = note: destructuring assignments are not yet supported
+   = note: for more information, see https://github.com/rust-lang/rfcs/issues/372
+
+error: aborting due to 10 previous errors
+
+Some errors have detailed explanations: E0067, E0070, E0368.
+For more information about an error, try `rustc --explain E0067`.