about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-08-14 09:40:09 +0200
committerRalf Jung <post@ralfj.de>2023-08-14 09:40:09 +0200
commitb9c15c5d3bfb503676fffccab69fe27c5b532283 (patch)
tree190c42809cb32cb939bab0b85432d495581a1f63 /library/core/src
parent3071e0aef6dfd0a150c3fb1da0abad4ec86ca0aa (diff)
downloadrust-b9c15c5d3bfb503676fffccab69fe27c5b532283.tar.gz
rust-b9c15c5d3bfb503676fffccab69fe27c5b532283.zip
clarify safety documentation of ptr::swap and ptr::copy
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/intrinsics.rs3
-rw-r--r--library/core/src/ptr/mod.rs3
2 files changed, 6 insertions, 0 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs
index 9ef2c7cde02..84b9a3bba88 100644
--- a/library/core/src/intrinsics.rs
+++ b/library/core/src/intrinsics.rs
@@ -2709,6 +2709,9 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
 ///
 /// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes.
 ///
+/// * `src` must remain valid for reads even after `dst` is written, and vice versa.
+///   (In other words, there cannot be aliasing restrictions on the use of these pointers.)
+///
 /// * Both `src` and `dst` must be properly aligned.
 ///
 /// Like [`read`], `copy` creates a bitwise copy of `T`, regardless of
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index 5f094ac4e7e..f8badc4130d 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -797,6 +797,9 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
 ///
 /// * Both `x` and `y` must be [valid] for both reads and writes.
 ///
+/// * `x` must remain valid for reads and writes even after `y` is read/written, and vice versa.
+///   (In other words, there cannot be aliasing restrictions on the use of these pointers.)
+///
 /// * Both `x` and `y` must be properly aligned.
 ///
 /// Note that even if `T` has size `0`, the pointers must be non-null and properly aligned.