From fcf8aff1656921747d9edb1a58f415767c426a38 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 18 Apr 2026 22:19:04 +0200 Subject: [PATCH 1/2] place "place projection" definition in glossary The term is defined in 2 separate places, and the definitions do not match. --- src/behavior-considered-undefined.md | 6 ++---- src/glossary.md | 13 +++++++++++++ src/types/closure.md | 14 +------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index 068fd6ab0e..e29c46a678 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -28,10 +28,8 @@ r[undefined.pointer-access] a misaligned pointer]. r[undefined.place-projection] -* Performing a place projection that violates the requirements of [in-bounds - pointer arithmetic](pointer#method.offset). A place projection is a [field - expression][project-field], a [tuple index expression][project-tuple], or an - [array/slice index expression][project-slice]. +* Performing a [place projection][glossary.place-projection] that violates the requirements of [in-bounds + pointer arithmetic](pointer#method.offset). r[undefined.alias] * Breaking the pointer aliasing rules. The exact aliasing rules are not determined yet, but here is an outline of the general principles: diff --git a/src/glossary.md b/src/glossary.md index 9d39173e01..d06476ee9f 100644 --- a/src/glossary.md +++ b/src/glossary.md @@ -133,6 +133,14 @@ These were formerly known as *object safe* traits. 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. +### Place projection + +r[glossary.place-projection] +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. + +> [!NOTE] +> In `rustc`, pattern destructuring desugars into a series of dereferences and field or element accesses. + ### Prelude 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,6 +219,7 @@ r[glossary.uninhabited] 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). +[array or slice index]: expressions/array-expr.md#array-and-slice-indexing-expressions [`extern` blocks]: items.extern [`extern fn`]: items.fn.extern [alignment]: type-layout.md#size-and-alignment @@ -218,8 +227,10 @@ A type is uninhabited if it has no constructors and therefore can never be insta [attributes]: attributes.md [*entity*]: names.md [crate]: crates-and-source-files.md +[dereference]: expressions/operator-expr.md#the-dereference-operator [dyn compatibility]: items/traits.md#dyn-compatibility [enums]: items/enumerations.md +[field access]: expressions/field-expr.md [fields]: expressions/field-expr.md [free item]: #free-item [generic parameters]: items/generics.md @@ -243,11 +254,13 @@ A type is uninhabited if it has no constructors and therefore can never be insta [never type]: types/never.md [*path*]: paths.md [Paths]: paths.md +[pattern destructuring]: patterns.destructure [*scope*]: names/scopes.md [structs]: items/structs.md [trait object types]: types/trait-object.md [traits]: items/traits.md [turbofish test]: https://github.com/rust-lang/rust/blob/1.58.0/src/test/ui/parser/bastion-of-the-turbofish.rs +[tuple index]: expressions/tuple-expr.md#tuple-indexing-expressions [types of crates]: linkage.md [types]: types.md [undefined-behavior]: behavior-considered-undefined.md diff --git a/src/types/closure.md b/src/types/closure.md index ecc8c726ef..4843089f88 100644 --- a/src/types/closure.md +++ b/src/types/closure.md @@ -94,13 +94,7 @@ Async closures always capture all input arguments, regardless of whether or not ## Capture precision r[type.closure.capture.precision.capture-path] -A *capture path* is a sequence starting with a variable from the environment followed by zero or more place projections from that variable. - -r[type.closure.capture.precision.place-projection] -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. - -> [!NOTE] -> In `rustc`, pattern destructuring desugars into a series of dereferences and field or element accesses. +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. r[type.closure.capture.precision.intro] The closure borrows or moves the capture path, which may be truncated based on the rules described below. @@ -121,12 +115,6 @@ c(); 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`. -[field access]: ../expressions/field-expr.md -[pattern destructuring]: patterns.destructure -[tuple index]: ../expressions/tuple-expr.md#tuple-indexing-expressions -[dereference]: ../expressions/operator-expr.md#the-dereference-operator -[array or slice index]: ../expressions/array-expr.md#array-and-slice-indexing-expressions - r[type.closure.capture.precision.shared-prefix] ### Shared prefix From aecd061ee50fb700bf97e486ca9c4e596bb6f2dd Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 18 Apr 2026 22:21:48 +0200 Subject: [PATCH 2/2] unwrap --- src/behavior-considered-undefined.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index e29c46a678..40c0a61e13 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -28,8 +28,7 @@ r[undefined.pointer-access] a misaligned pointer]. r[undefined.place-projection] -* Performing a [place projection][glossary.place-projection] that violates the requirements of [in-bounds - pointer arithmetic](pointer#method.offset). +* Performing a [place projection][glossary.place-projection] that violates the requirements of [in-bounds pointer arithmetic](pointer#method.offset). r[undefined.alias] * Breaking the pointer aliasing rules. The exact aliasing rules are not determined yet, but here is an outline of the general principles: