Skip to content

Commit 64de336

Browse files
committed
fix box doc for aliasing rules
1 parent 58c2dd9 commit 64de336

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/alloc/src/boxed.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,8 @@ impl<T: ?Sized> Box<T> {
10111011
/// function is called twice on the same raw pointer.
10121012
///
10131013
/// The raw pointer must point to a block of memory allocated by the global allocator.
1014+
/// And you should enforce the aliasing rule by ensuring nothing else uses the
1015+
/// raw pointer after calling this function.
10141016
///
10151017
/// The safety conditions are described in the [memory layout] section.
10161018
///
@@ -1060,6 +1062,8 @@ impl<T: ?Sized> Box<T> {
10601062
/// function is called twice on the same `NonNull` pointer.
10611063
///
10621064
/// The non-null pointer must point to a block of memory allocated by the global allocator.
1065+
/// And you should enforce the aliasing rule by ensuring nothing else uses the
1066+
/// non-null pointer after calling this function.
10631067
///
10641068
/// The safety conditions are described in the [memory layout] section.
10651069
///
@@ -1116,6 +1120,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11161120
/// function is called twice on the same raw pointer.
11171121
///
11181122
/// The raw pointer must point to a block of memory allocated by `alloc`.
1123+
/// If the `alloc` is a global allocator, you should enforce the aliasing rule
1124+
/// by ensuring nothing else uses the raw pointer after calling this function.
11191125
///
11201126
/// # Examples
11211127
///
@@ -1169,6 +1175,8 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
11691175
/// function is called twice on the same raw pointer.
11701176
///
11711177
/// The non-null pointer must point to a block of memory allocated by `alloc`.
1178+
/// If the `alloc` is a global allocator, you should enforce the aliasing rule
1179+
/// by ensuring nothing else uses the non-null pointer after calling this function.
11721180
///
11731181
/// # Examples
11741182
///

0 commit comments

Comments
 (0)