You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reference/src/glossary.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## Glossary
2
2
3
-
####Aliasing
3
+
### Aliasing
4
4
5
5
*Aliasing* occurs when one pointer or reference points to a "span" of memory
6
6
that overlaps with the span of another pointer or reference. A span of memory is
@@ -55,7 +55,7 @@ somewhat differently from this definition. However, that's considered a low
55
55
level detail of a particular Rust implementation. When programming Rust, the
56
56
Abstract Rust Machine is intended to operate according to the definition here.
57
57
58
-
####(Pointer) Provenance
58
+
### (Pointer) Provenance
59
59
60
60
The *provenance* of a pointer is used to distinguish pointers that point to the same memory address (i.e., pointers that, when cast to `usize`, will compare equal).
61
61
Provenance is extra state that only exists in the Rust Abstract Machine; it is needed to specify program behavior but not present any more when the program runs on real hardware.
@@ -95,7 +95,7 @@ For some more information, see [this document proposing a more precise definitio
95
95
Another example of pointer provenance is the "tag" from [Stacked Borrows][stacked-borrows].
96
96
For some more information, see [this blog post](https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html).
97
97
98
-
####Interior mutability
98
+
### Interior mutability
99
99
100
100
*Interior Mutation* means mutating memory where there also exists a live shared reference pointing to the same memory; or mutating memory through a pointer derived from a shared reference.
101
101
"live" here means a value that will be "used again" later.
@@ -109,7 +109,7 @@ If data immediately pointed to by a `*const T` or `&*const T` is mutated, that's
109
109
*Interior mutability* refers to the ability to perform interior mutation without causing UB.
110
110
All interior mutation in Rust has to happen inside an [`UnsafeCell`](https://doc.rust-lang.org/core/cell/struct.UnsafeCell.html), so all data structures that have interior mutability must (directly or indirectly) use `UnsafeCell` for this purpose.
111
111
112
-
####Validity and safety invariant
112
+
### Validity and safety invariant
113
113
114
114
The *validity invariant* is an invariant that all data must uphold any time it is accessed or copied in a typed manner.
115
115
This invariant is known to the compiler and exploited by optimizations such as improved enum layout or eliding in-bounds checks.
@@ -146,7 +146,7 @@ Moreover, such unsafe code must not return a non-UTF-8 string to the "outside" o
146
146
To summarize: *Data must always be valid, but it only must be safe in safe code.*
147
147
For some more information, see [this blog post](https://www.ralfj.de/blog/2018/08/22/two-kinds-of-invariants.html).
148
148
149
-
####Undefined Behavior
149
+
### Undefined Behavior
150
150
[ub]: #undefined-behavior
151
151
152
152
*Undefined Behavior* is a concept of the contract between the Rust programmer and the compiler:
@@ -160,7 +160,7 @@ For unsafe code, however, the burden is still on the programmer.
160
160
161
161
Also see: [Soundness][soundness].
162
162
163
-
####Soundness (of code / of a library)
163
+
### Soundness (of code / of a library)
164
164
[soundness]: #soundness-of-code--of-a-library
165
165
166
166
*Soundness* is a type system concept (actually originating from the study of logics) and means that the type system is "correct" in the sense that well-typed programs actually have the desired properties.
@@ -170,7 +170,7 @@ This promise only extends to safe code however; for `unsafe` code, it is up to t
170
170
Accordingly, we say that a library (or an individual function) is *sound* if it is impossible for safe code to cause Undefined Behavior using its public API.
171
171
Conversely, the library/function is *unsound* if safe code *can* cause Undefined Behavior.
172
172
173
-
####Layout
173
+
### Layout
174
174
[layout]: #layout
175
175
176
176
The *layout* of a type defines its size and alignment as well as the offsets of its subobjects (e.g. fields of structs/unions/enum/... or elements of arrays).
@@ -179,7 +179,7 @@ Moreover, the layout of a type records its *function call ABI* (or just *ABI* fo
179
179
Note: Originally, *layout* and *representation* were treated as synonyms, and Rust language features like the `#[repr]` attribute reflect this.
180
180
In this document, *layout* and *representation* are not synonyms.
181
181
182
-
####Niche
182
+
### Niche
183
183
184
184
The *niche* of a type determines invalid bit-patterns that will be used by layout optimizations.
185
185
@@ -193,7 +193,7 @@ niches. For example, the "all bits uninitialized" is an invalid bit-pattern for
193
193
`&mut T`, but this bit-pattern cannot be used by layout optimizations, and is not a
194
194
niche.
195
195
196
-
####Zero-sized type / ZST
196
+
### Zero-sized type / ZST
197
197
198
198
Types with zero size are called zero-sized types, which is abbreviated as "ZST".
199
199
This document also uses the "1-ZST" abbreviation, which stands for "one-aligned
@@ -202,7 +202,7 @@ zero-sized type", to refer to zero-sized types with an alignment requirement of
202
202
For example, `()` is a "1-ZST" but `[u16; 0]` is not because it has an alignment
203
203
requirement of 2.
204
204
205
-
####Padding
205
+
### Padding
206
206
[padding]: #padding
207
207
208
208
*Padding* (of a type `T`) refers to the space that the compiler leaves between fields of a struct or enum variant to satisfy alignment requirements, and before/after variants of a union or enum to make all variants equally sized.
@@ -223,7 +223,7 @@ In other words, the byte at index `i` is entirely ignored by `Vrel_T` (the value
223
223
This definition works fine for product types (structs, tuples, arrays, ...).
224
224
The desired notion of "padding byte" for enums and unions is still unclear.
225
225
226
-
####Place
226
+
### Place
227
227
228
228
A *place* (called "lvalue" in C and "glvalue" in C++) is the result of computing a [*place expression*][place-value-expr].
229
229
A place is basically a pointer (pointing to some location in memory, potentially carrying [provenance](#pointer-provenance)), but might contain more information such as size or alignment (the details will have to be determined as the Rust Abstract Machine gets specified more precisely).
@@ -235,7 +235,7 @@ The key operations on a place are:
235
235
* Converting between a place (of type `T`) and a pointer value (of type `&T`, `&mut T`, `*const T` or `*mut T`) using the `&` and `*` operators.
236
236
This is also the only way a place can be "stored": by converting it to a value first.
237
237
238
-
####Value
238
+
### Value
239
239
240
240
A *value* (called "value of the expression" or "rvalue" in C and "prvalue" in C++) is what gets stored in a [place](#place), and also the result of computing a [*value expression*][place-value-expr].
241
241
A value has a type, and it denotes the abstract mathematical concept that is represented by data in our programs.
@@ -245,7 +245,7 @@ Values can be (according to their type) turned into a list of bytes, which is ca
245
245
Values are ephemeral; they arise during the computation of an instruction but are only ever persisted in memory through their representation.
246
246
(This is comparable to how run-time data in a program is ephemeral and is only ever persisted in serialized form.)
0 commit comments