Skip to content

Commit 710f0ea

Browse files
committed
break Validity Invariant and Safety Invariant apart
1 parent 1c44b54 commit 710f0ea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

reference/src/glossary.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ If data immediately pointed to by a `*const T` or `&*const T` is mutated, that's
1414
*Interior mutability* refers to the ability to perform interior mutation without causing UB.
1515
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.
1616

17-
#### Validity and safety invariant
17+
#### Validity Invariant
1818

1919
The *validity invariant* is an invariant that all data must uphold any time it is accessed or copied in a typed manner.
2020
This invariant is known to the compiler and exploited by optimizations such as improved enum layout or eliding in-bounds checks.
@@ -31,6 +31,8 @@ fn main() { unsafe {
3131
} }
3232
```
3333

34+
#### Safety Invariant
35+
3436
The *safety* invariant is an invariant that safe code may assume all data to uphold.
3537
This invariant is used to justify which operations safe code can perform.
3638
The safety invariant can be temporarily violated by unsafe code, but must always be upheld when interfacing with unknown safe code.

0 commit comments

Comments
 (0)