Skip to content

Commit 49af5a1

Browse files
committed
aliasing rules also apply inside private fields
1 parent 581920f commit 49af5a1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/behavior-considered-undefined.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ r[undefined.alias]
3838
`&T` must point to memory that is not mutated while they are live (except for data inside an [`UnsafeCell<U>`]),
3939
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.
4040
`Box<T>` is treated similar to `&'static mut T` for the purpose of these rules.
41+
These rules apply to *all* references and `Box<T>`, including those inside private fields.
42+
4143
The exact liveness duration is not specified, but some bounds exist:
4244
* For references, the liveness duration is upper-bounded by the syntactic
4345
lifetime assigned by the borrow checker; it cannot be live any *longer* than that lifetime.

0 commit comments

Comments
 (0)