mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 17:40:16 +00:00
Parse move exprs as a bottom expr instead of a prefix expr
`move(…)` is obviously meant to be a normal expr but since it was incorrectly treated as a prefix expr in the compiler, it meant it couldn't be used as the (left) operand of what I personally call "higher postfix operations"[^1], namely *Try*, *Call* / *Index* & "*Dot*" (*Field*, *Await*, …).
More concretely, it would mean we'd reject expressions like `move(…)?` (*Try*), `move(…)(…)` (*Call*), `move(…)[…]` (*Index*), `move(…).field` (*Field*), `move(…).method(…)` (*MethodCall*) or `move(…).await` (*Await*).
Furthermore, it would mean we'd parse `return move(0).field` like `(return move(0)).field` instead of `return ((move(0)).field)`.
---
It's immaterial whether the final version of move exprs continues to use syntax `move(…)` (a syntax much contended over at the RFC) or if it gets changed along the way (to e.g., `move { … }` (also quite controversial)), it remains a fact that move exprs are not prefix exprs!
---
CC @TaKO8Ki @nikomatsakis (https://github.com/rust-lang/rust/pull/155023)
Part of https://github.com/rust-lang/rust/issues/155050.
<sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
[^1]: I.e., operations where the corresponding operator precedence is higher than or equal to the one of *Try*.