mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 13:02:50 +00:00
Rollup merge of #114794 - RalfJung:swap-safety, r=m-ou-se
clarify safety documentation of ptr::swap and ptr::copy Closes https://github.com/rust-lang/rust/issues/81005
This commit is contained in:
commit
14c57f1adb
@ -2707,9 +2707,13 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
|
||||
///
|
||||
/// Behavior is undefined if any of the following conditions are violated:
|
||||
///
|
||||
/// * `src` must be [valid] for reads of `count * size_of::<T>()` bytes.
|
||||
/// * `src` must be [valid] for reads of `count * size_of::<T>()` bytes, and must remain valid even
|
||||
/// when `dst` is written for `count * size_of::<T>()` bytes. (This means if the memory ranges
|
||||
/// overlap, the two pointers must not be subject to aliasing restrictions relative to each
|
||||
/// other.)
|
||||
///
|
||||
/// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes.
|
||||
/// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes, and must remain valid even
|
||||
/// when `src` is read for `count * size_of::<T>()` bytes.
|
||||
///
|
||||
/// * Both `src` and `dst` must be properly aligned.
|
||||
///
|
||||
|
@ -795,7 +795,9 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
|
||||
///
|
||||
/// Behavior is undefined if any of the following conditions are violated:
|
||||
///
|
||||
/// * Both `x` and `y` must be [valid] for both reads and writes.
|
||||
/// * Both `x` and `y` must be [valid] for both reads and writes. They must remain valid even when the
|
||||
/// other pointer is written. (This means if the memory ranges overlap, the two pointers must not
|
||||
/// be subject to aliasing restrictions relative to each other.)
|
||||
///
|
||||
/// * Both `x` and `y` must be properly aligned.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user