mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
ptr::copy: fix docs for the overlapping case
This commit is contained in:
parent
13170cd787
commit
526d29865c
@ -1359,6 +1359,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
let src_alloc = self.get_alloc_raw(src_alloc_id)?;
|
let src_alloc = self.get_alloc_raw(src_alloc_id)?;
|
||||||
let src_range = alloc_range(src_offset, size);
|
let src_range = alloc_range(src_offset, size);
|
||||||
assert!(!self.memory.validation_in_progress, "we can't be copying during validation");
|
assert!(!self.memory.validation_in_progress, "we can't be copying during validation");
|
||||||
|
// For the overlapping case, it is crucial that we trigger the read hook
|
||||||
|
// before the write hook -- the aliasing model cares about the order.
|
||||||
M::before_memory_read(
|
M::before_memory_read(
|
||||||
tcx,
|
tcx,
|
||||||
&self.machine,
|
&self.machine,
|
||||||
|
@ -4364,13 +4364,11 @@ 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:
|
/// Behavior is undefined if any of the following conditions are violated:
|
||||||
///
|
///
|
||||||
/// * `src` must be [valid] for reads of `count * size_of::<T>()` bytes, and must remain valid even
|
/// * `src` must be [valid] for reads of `count * size_of::<T>()` bytes.
|
||||||
/// 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, and must remain valid even
|
/// * `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.
|
/// when `src` is read for `count * size_of::<T>()` bytes. (This means if the memory ranges
|
||||||
|
/// overlap, the `dst` pointer must not be invalidated by `src` reads.)
|
||||||
///
|
///
|
||||||
/// * Both `src` and `dst` must be properly aligned.
|
/// * Both `src` and `dst` must be properly aligned.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user