Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/behavior-considered-undefined.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ 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:
Expand Down
13 changes: 13 additions & 0 deletions src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -211,15 +219,18 @@ 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
[associated item]: #associated-item
[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
Expand All @@ -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
Expand Down
14 changes: 1 addition & 13 deletions src/types/closure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
Loading