Skip to content

Commit 1c9c88b

Browse files
committed
Add admonition about the desugaring of destructuring
For our purposes in describing capture paths, we define place projections. For the text that follows in the sections below to hold, we need destructuring to be treated as a place projection for this purpose. However, it might seem surprising for destructuring to be in this list. While it is believed to have the same effect as a projection expression, we might not consider an instance of pattern destructuring to be a projection expression exactly. To better contextualize this, let's add an admonition that mentions that pattern destructuring desugars into the kind of field accesses that we would more likely think about as projection operations.
1 parent 4bb220f commit 1c9c88b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/types/closure.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ A *capture path* is a sequence starting with a variable from the environment fol
103103
r[type.closure.capture.precision.place-projection]
104104
A *place projection* is a [field access], [tuple index], [dereference] (and automatic dereferences), [array or slice index] expression, or [pattern destructuring] applied to a variable.
105105

106+
> [!NOTE]
107+
> In `rustc`, pattern destructuring desugars into a series of dereferences and field or element accesses.
108+
106109
r[type.closure.capture.precision.intro]
107110
The closure borrows or moves the capture path, which may be truncated based on the rules described below.
108111

0 commit comments

Comments
 (0)