@@ -7,8 +7,9 @@ This discussion is meant to focus on two things:
7
7
- What guarantees does Rust make regarding the layout of data structures?
8
8
- What invariants does the compiler require from the various Rust types?
9
9
- the "validity invariant", as defined in [ Ralf's blog post] [ bp ]
10
- - What invariants can safe code expect to hold for the various Rust types?
11
- - the "safety invariant", as defined in [ Ralf's blog post] [ bp ]
10
+
11
+ NB. The discussion is ** not** meant to discuss the "safety invariant"
12
+ from [ Ralf's blog post] [ bp ] , as that can be handled later.
12
13
13
14
[ bp ] : https://www.ralfj.de/blog/2018/08/22/two-kinds-of-invariants.html
14
15
@@ -43,23 +44,10 @@ invariant, however, so as to leave room for future optimization.
43
44
As an example, a value of ` &T ` type can never be null -- therefore,
44
45
` Option<&T> ` can use null to represent ` None ` .
45
46
46
- ### Safety invariant
47
-
48
- The "safety invariant" for each type defines what must hold whenever
49
- safe code has access to a type.
50
-
51
- This invariant must ** at minimum** justify all the things that our
52
- type system allows without an ` unsafe ` keyword being required.
53
-
54
- For example, a value of ` &T ` must be dereferencable, since safe code
55
- could always choose to dereference it.
56
-
57
47
## Goals
58
48
59
49
- Define what we guarantee about the layout of various types
60
50
and the effect of ` #[repr] ` annotations.
61
- - Define the ** safety requirements** of various types that safe
62
- code requires (and which unsafe code must uphold at the safe/unsafe boundary).
63
51
- Define the ** validity requirements** of various types that unsafe
64
52
programmers must uphold at all times.
65
53
- Also examine when/how we could dynamically check these requirements.
0 commit comments