Skip to content

Commit

Permalink
Add new folder for destructuring assignment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Dec 23, 2019
1 parent 35979a9 commit 9a60224
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,7 @@ pub enum ExprKind {
Block(P<Block>, Option<Label>),

/// An assignment (e.g., `a = foo()`).
/// The `Span` argument is the span of the `=` token.
Assign(P<Expr>, P<Expr>, Span),
/// An assignment with an operator.
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
err.span_label(lhs.span, "cannot assign to this expression");
if self.is_destructuring_place_expr(lhs) {
err.note("destructuring assignments are not yet supported");
err.note("destructuring assignments are not currently supported");
err.note(
"for more information, see https://github.com/rust-lang/rfcs/issues/372",
);
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ pub enum ExprKind {
TryBlock(P<Block>),

/// An assignment (`a = foo()`).
/// The `Span` argument is the span of the `=` token.
Assign(P<Expr>, P<Expr>, Span),
/// An assignment with an operator.
///
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/bad/bad-expr-lhs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LL | (a, b) = (3, 4);
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently supported
= note: for more information, see https://github.com/rust-lang/rfcs/issues/372

error[E0070]: invalid left-hand side of assignment
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0070]: invalid left-hand side of assignment
--> $DIR/destructuring-assignment.rs:6:12
--> $DIR/note-unsupported.rs:6:12
|
LL | (a, b) = (3, 4);
| ------ ^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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
--> $DIR/note-unsupported.rs:7:5
|
LL | (a, b) += (3, 4);
| ------^^^^^^^^^^
Expand All @@ -20,29 +20,29 @@ LL | (a, b) += (3, 4);
= 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
--> $DIR/note-unsupported.rs:7:12
|
LL | (a, b) += (3, 4);
| ------ ^^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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:12
--> $DIR/note-unsupported.rs:10:12
|
LL | [a, b] = [3, 4];
| ------ ^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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
--> $DIR/note-unsupported.rs:11:5
|
LL | [a, b] += [3, 4];
| ------^^^^^^^^^^
Expand All @@ -52,29 +52,29 @@ LL | [a, b] += [3, 4];
= 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
--> $DIR/note-unsupported.rs:11:12
|
LL | [a, b] += [3, 4];
| ------ ^^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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:22
--> $DIR/note-unsupported.rs:16:22
|
LL | S { x: a, y: b } = s;
| ---------------- ^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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
--> $DIR/note-unsupported.rs:17:5
|
LL | S { x: a, y: b } += s;
| ----------------^^^^^
Expand All @@ -84,36 +84,36 @@ LL | S { x: a, y: b } += 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
--> $DIR/note-unsupported.rs:17:22
|
LL | S { x: a, y: b } += s;
| ---------------- ^^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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:21
--> $DIR/note-unsupported.rs:20:21
|
LL | S { x: a, ..s } = S { x: 3, y: 4 };
| --------------- ^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently 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:24:17
--> $DIR/note-unsupported.rs:24:17
|
LL | ((a, b), c) = ((3, 4), 5);
| ----------- ^
| |
| cannot assign to this expression
|
= note: destructuring assignments are not yet supported
= note: destructuring assignments are not currently supported
= note: for more information, see https://github.com/rust-lang/rfcs/issues/372

error: aborting due to 11 previous errors
Expand Down

0 comments on commit 9a60224

Please sign in to comment.