Skip to content

Commit ff995bb

Browse files
committed
Add notion of "assignee expression"
1 parent 821dcc8 commit ff995bb

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

text/0000-destructuring-assignment.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,29 @@ complicates Rust's grammar and it is not clear that it is even technically feasi
6060
handling some classes of expressions is much simpler, and is indistinguishable to users, who will
6161
receive pattern-oriented diagnostics due to the desugaring of expressions into patterns.
6262

63-
In effect, we are extending the [place
64-
expressions](https://doc.rust-lang.org/reference/expressions.html#place-expressions-and-value-expressions) (also called "lvalues")
65-
that Rust accepts by the following:
63+
To describe the context of destructuring assignments more precisely, we add a new class of
64+
expressions, which we call "assignee expressions".
65+
Assignee expressions are analogous to [place
66+
expressions](https://doc.rust-lang.org/reference/expressions.html#place-expressions-and-value-expressions)
67+
(also called "lvalues") in that they refer to expressions representing a memory location, but may
68+
only appear on the left-hand side of an assignment (unlike place expressions). Every place
69+
expression is also an assignee expression.
6670

71+
The class of assignee expressions is defined inductively:
72+
73+
- Place: `place`.
6774
- Underscore: `_`.
68-
- Tuples: `(place, place, place)`, `(place, .., place)`, `(.., place, place)`, `(place, place, ..)`.
69-
- Slices: `[place, place, place]`, `[place, .., place]`, `[.., place, place]`, `[place, place, ..]`.
70-
- Tuple structs: `path(place, place, place)`, `path(place, .., place)`, `path(.., place, place)`,
71-
`path(place, place, ..)`.
72-
- Structs: `path { field: place, field: place }`, `path { field: place, field: place, .. }`.
75+
- Tuples: `(assignee, assignee, assignee)`, `(assignee, .., assignee)`, `(.., assignee, assignee)`, `(assignee, assignee, ..)`.
76+
- Slices: `[assignee, assignee, assignee]`, `[assignee, .., assignee]`, `[.., assignee, assignee]`, `[assignee, assignee, ..]`.
77+
- Tuple structs: `path(assignee, assignee, assignee)`, `path(assignee, .., assignee)`, `path(.., assignee, assignee)`,
78+
`path(assignee, assignee, ..)`.
79+
- Structs: `path { field: assignee, field: assignee }`, `path { field: assignee, field: assignee, .. }`.
7380
- Unit structs: `path`.
7481

82+
The place expression "The left operand of an assignment or compound assignment expression." ibid.
83+
is changed to "The left operand of a compound assignment expression.", while
84+
"The left operand of an assignment expression." is now an assignee expression.
85+
7586
The general idea is that we will desugar the following complex assignments as demonstrated.
7687

7788
```rust

0 commit comments

Comments
 (0)