@@ -60,18 +60,29 @@ complicates Rust's grammar and it is not clear that it is even technically feasi
60
60
handling some classes of expressions is much simpler, and is indistinguishable to users, who will
61
61
receive pattern-oriented diagnostics due to the desugaring of expressions into patterns.
62
62
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.
66
70
71
+ The class of assignee expressions is defined inductively:
72
+
73
+ - Place: ` place ` .
67
74
- 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 , .. } ` .
73
80
- Unit structs: ` path ` .
74
81
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
+
75
86
The general idea is that we will desugar the following complex assignments as demonstrated.
76
87
77
88
``` rust
0 commit comments