Skip to content

Commit 79b26a7

Browse files
committed
extend def.n of interior mutability
1 parent 7eabb5a commit 79b26a7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

reference/src/glossary.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
#### Interior mutability
44

5-
*Interior Mutability* means mutating memory where there also exists a live shared reference immediately (i.e., non-transitively) pointing to the same memory.
6-
This propagates recursively through references, but not through raw pointers.
5+
*Interior Mutability* 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.
6+
"live" here means a value that will be "used again" later.
7+
"derived from" means that the pointer was obtained by casting a shared reference and potentially adding an offset.
8+
This is not yet precisely defined, which will be fixed as part of developing a precise aliasing model.
9+
10+
Finding live shared references propagates recursively through references, but not through raw pointers.
711
So, for example, if data immediately pointed to by a `&T` or `& &mut T` is mutated, that's interior mutability.
812
If data immediately pointed to by a `*const T` or `&*const T` is mutated, that's *not* interior mutability.
913

10-
"live" here means a value that will be "used again" later.
11-
This is not yet precisely defined, this will be fixed as part of developing a precise aliasing model.
12-
1314
Interior mutability is only allowed inside [`UnsafeCell`](https://doc.rust-lang.org/core/cell/struct.UnsafeCell.html).
1415

1516
#### Validity and safety invariant

0 commit comments

Comments
 (0)