Description
The reference defines assignment expressions to have the grammar:
AssignmentExpression:
Expression = Expression
which makes sense. However, it becomes slightly more complicated when the assignee expression is an array, a tuple or a struct with fields, as these can contain wildcard/underscore and rest expressions (as shown below and on the Playground).
a += 1;
[a, b] = [1, 2];
S {
array: [_, a, ..],
slice: (b, ..),
} = S::default();
The wildcard/underscore expression is AFAIK only used to allow such assignments. The rest expression, is not listed and on a lexicographical level probably a range expression without limits.
While this works, it feels weird to me. When I think about assignments, I see the left-hand side as a pattern. Adding a wildcard/underscore expression just for assignments also doesn't feel quite right.
Rustc desugars such expressions into a let
-statement with a pattern and variables that are then reassigned. This can be seen with Show HIR on the Playground.
The question of this issue is, how should the assignee be represented in Marker?
- With expressions, like the grammar would indicate
- With patterns and some way of including place expressions in patterns