Skip to content

Commit 1701957

Browse files
committed
aliasing rule summary: use a bulleted list
1 parent 82da570 commit 1701957

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/behavior-considered-undefined.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ r[undefined.place-projection]
2424
r[undefined.alias]
2525
* Breaking the pointer aliasing rules. The exact aliasing rules are not determined yet, but here is an outline of the general principles:
2626

27-
`&T` must point to memory that is not mutated while they are live (except for data inside an [`UnsafeCell<U>`]), and `&mut T` must point to memory that is not read or written by any pointer not derived from the reference and that no other reference points to while they are live (with no exceptions). `Box<T>` is treated similar to `&'static mut T` for the purpose of these rules. These rules apply to *all* references and `Box<T>`, including those stored inside private fields (e.g., if your type has a private field of type `&mut T`, that reference must be unique in the sense described above for as long as values of your type are live).
27+
* `&T` must point to memory that is not mutated while they are live (except for data inside an [`UnsafeCell<U>`]).
28+
* `&mut T` must point to memory that is not read or written by any pointer not derived from the reference and that no other reference points to while they are live (with no exceptions).
29+
* `Box<T>` is treated similar to `&'static mut T` for the purpose of these rules.
30+
31+
These rules apply to *all* references and `Box<T>`, including those stored inside private fields (e.g., if your type has a private field of type `&mut T`, that reference must be unique in the sense described above for as long as values of your type are live).
2832

2933
The exact liveness duration is not specified, but some bounds exist:
3034

0 commit comments

Comments
 (0)