Skip to content

Commit c2a14eb

Browse files
committed
place "place projection" definition in glossary
The term is defined in 2 separate places, and the definitions do not match.
1 parent 18d4246 commit c2a14eb

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/behavior-considered-undefined.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ r[undefined.pointer-access]
2828
a misaligned pointer].
2929

3030
r[undefined.place-projection]
31-
* Performing a place projection that violates the requirements of [in-bounds
32-
pointer arithmetic](pointer#method.offset). A place projection is a [field
33-
expression][project-field], a [tuple index expression][project-tuple], or an
34-
[array/slice index expression][project-slice].
31+
* Performing a [place projection][glossary.place-projection] that violates the requirements of [in-bounds
32+
pointer arithmetic](pointer#method.offset).
3533

3634
r[undefined.alias]
3735
* Breaking the pointer aliasing rules. The exact aliasing rules are not determined yet, but here is an outline of the general principles:

src/glossary.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ These were formerly known as *object safe* traits.
133133

134134
A [*path*] is a sequence of one or more path segments used to refer to an [entity](#entity) in the current scope or other levels of a [namespace](#namespace) hierarchy.
135135

136+
### Place projection
137+
138+
r[glossary.place-projection]
139+
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.
140+
141+
> [!NOTE]
142+
> In `rustc`, pattern destructuring desugars into a series of dereferences and field or element accesses.
143+
136144
### Prelude
137145

138146
Prelude, or The Rust Prelude, is a small collection of items - mostly traits - that are imported into every module of every crate. The traits in the prelude are pervasive.
@@ -211,15 +219,18 @@ r[glossary.uninhabited]
211219

212220
A type is uninhabited if it has no constructors and therefore can never be instantiated. An uninhabited type is "empty" in the sense that there are no values of the type. The canonical example of an uninhabited type is the [never type] `!`, or an enum with no variants `enum Never { }`. Opposite of [Inhabited](#inhabited).
213221

222+
[array or slice index]: ../expressions/array-expr.md#array-and-slice-indexing-expressions
214223
[`extern` blocks]: items.extern
215224
[`extern fn`]: items.fn.extern
216225
[alignment]: type-layout.md#size-and-alignment
217226
[associated item]: #associated-item
218227
[attributes]: attributes.md
219228
[*entity*]: names.md
220229
[crate]: crates-and-source-files.md
230+
[dereference]: ../expressions/operator-expr.md#the-dereference-operator
221231
[dyn compatibility]: items/traits.md#dyn-compatibility
222232
[enums]: items/enumerations.md
233+
[field access]: ../expressions/field-expr.md
223234
[fields]: expressions/field-expr.md
224235
[free item]: #free-item
225236
[generic parameters]: items/generics.md
@@ -243,11 +254,13 @@ A type is uninhabited if it has no constructors and therefore can never be insta
243254
[never type]: types/never.md
244255
[*path*]: paths.md
245256
[Paths]: paths.md
257+
[pattern destructuring]: patterns.destructure
246258
[*scope*]: names/scopes.md
247259
[structs]: items/structs.md
248260
[trait object types]: types/trait-object.md
249261
[traits]: items/traits.md
250262
[turbofish test]: https://github.com/rust-lang/rust/blob/1.58.0/src/test/ui/parser/bastion-of-the-turbofish.rs
263+
[tuple index]: ../expressions/tuple-expr.md#tuple-indexing-expressions
251264
[types of crates]: linkage.md
252265
[types]: types.md
253266
[undefined-behavior]: behavior-considered-undefined.md

src/types/closure.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,7 @@ Async closures always capture all input arguments, regardless of whether or not
9494
## Capture precision
9595

9696
r[type.closure.capture.precision.capture-path]
97-
A *capture path* is a sequence starting with a variable from the environment followed by zero or more place projections from that variable.
98-
99-
r[type.closure.capture.precision.place-projection]
100-
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.
101-
102-
> [!NOTE]
103-
> In `rustc`, pattern destructuring desugars into a series of dereferences and field or element accesses.
97+
A *capture path* is a sequence starting with a variable from the environment followed by zero or more [place projections][glossary.place-projection] from that variable.
10498

10599
r[type.closure.capture.precision.intro]
106100
The closure borrows or moves the capture path, which may be truncated based on the rules described below.
@@ -121,12 +115,6 @@ c();
121115

122116
Here the capture path is the local variable `s`, followed by a field access `.f1`, and then a tuple index `.1`. This closure captures an immutable borrow of `s.f1.1`.
123117

124-
[field access]: ../expressions/field-expr.md
125-
[pattern destructuring]: patterns.destructure
126-
[tuple index]: ../expressions/tuple-expr.md#tuple-indexing-expressions
127-
[dereference]: ../expressions/operator-expr.md#the-dereference-operator
128-
[array or slice index]: ../expressions/array-expr.md#array-and-slice-indexing-expressions
129-
130118
r[type.closure.capture.precision.shared-prefix]
131119
### Shared prefix
132120

0 commit comments

Comments
 (0)