Skip to content

Commit 148e24e

Browse files
committed
glossary: use level 3 headers
1 parent e8fae1d commit 148e24e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

reference/src/glossary.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Glossary
22

3-
#### Aliasing
3+
### Aliasing
44

55
*Aliasing* occurs when one pointer or reference points to a "span" of memory
66
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
5555
level detail of a particular Rust implementation. When programming Rust, the
5656
Abstract Rust Machine is intended to operate according to the definition here.
5757

58-
#### (Pointer) Provenance
58+
### (Pointer) Provenance
5959

6060
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).
6161
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
9595
Another example of pointer provenance is the "tag" from [Stacked Borrows][stacked-borrows].
9696
For some more information, see [this blog post](https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html).
9797

98-
#### Interior mutability
98+
### Interior mutability
9999

100100
*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.
101101
"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
109109
*Interior mutability* refers to the ability to perform interior mutation without causing UB.
110110
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.
111111

112-
#### Validity and safety invariant
112+
### Validity and safety invariant
113113

114114
The *validity invariant* is an invariant that all data must uphold any time it is accessed or copied in a typed manner.
115115
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
146146
To summarize: *Data must always be valid, but it only must be safe in safe code.*
147147
For some more information, see [this blog post](https://www.ralfj.de/blog/2018/08/22/two-kinds-of-invariants.html).
148148

149-
#### Undefined Behavior
149+
### Undefined Behavior
150150
[ub]: #undefined-behavior
151151

152152
*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.
160160

161161
Also see: [Soundness][soundness].
162162

163-
#### Soundness (of code / of a library)
163+
### Soundness (of code / of a library)
164164
[soundness]: #soundness-of-code--of-a-library
165165

166166
*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
170170
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.
171171
Conversely, the library/function is *unsound* if safe code *can* cause Undefined Behavior.
172172

173-
#### Layout
173+
### Layout
174174
[layout]: #layout
175175

176176
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
179179
Note: Originally, *layout* and *representation* were treated as synonyms, and Rust language features like the `#[repr]` attribute reflect this.
180180
In this document, *layout* and *representation* are not synonyms.
181181

182-
#### Niche
182+
### Niche
183183

184184
The *niche* of a type determines invalid bit-patterns that will be used by layout optimizations.
185185

@@ -193,7 +193,7 @@ niches. For example, the "all bits uninitialized" is an invalid bit-pattern for
193193
`&mut T`, but this bit-pattern cannot be used by layout optimizations, and is not a
194194
niche.
195195

196-
#### Zero-sized type / ZST
196+
### Zero-sized type / ZST
197197

198198
Types with zero size are called zero-sized types, which is abbreviated as "ZST".
199199
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
202202
For example, `()` is a "1-ZST" but `[u16; 0]` is not because it has an alignment
203203
requirement of 2.
204204

205-
#### Padding
205+
### Padding
206206
[padding]: #padding
207207

208208
*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
223223
This definition works fine for product types (structs, tuples, arrays, ...).
224224
The desired notion of "padding byte" for enums and unions is still unclear.
225225

226-
#### Place
226+
### Place
227227

228228
A *place* (called "lvalue" in C and "glvalue" in C++) is the result of computing a [*place expression*][place-value-expr].
229229
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:
235235
* 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.
236236
This is also the only way a place can be "stored": by converting it to a value first.
237237

238-
#### Value
238+
### Value
239239

240240
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].
241241
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
245245
Values are ephemeral; they arise during the computation of an instruction but are only ever persisted in memory through their representation.
246246
(This is comparable to how run-time data in a program is ephemeral and is only ever persisted in serialized form.)
247247

248-
#### Representation (relation)
248+
### Representation (relation)
249249
[representation relation]: #representation-relation
250250

251251
A *representation* of a [value](#value) is a list of bytes that is used to store or "represent" that value in memory.

0 commit comments

Comments
 (0)