diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 7b31bbec7547c..bc621e8c1ea62 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -2014,6 +2014,10 @@ pub fn ptr_mask(_ptr: *const T, _mask: usize) -> *const T { /// The volatile parameter is set to `true`, so it will not be optimized out /// unless size is equal to zero. /// +/// # Safety +/// +/// The safety concerns are the same with [`copy_nonoverlapping`]. +/// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] #[rustc_intrinsic_must_be_overridden] @@ -2042,6 +2046,18 @@ pub unsafe fn volatile_copy_memory(_dst: *mut T, _src: *const T, _count: usiz /// The volatile parameter is set to `true`, so it will not be optimized out /// unless size is equal to zero. /// +/// # Safety +/// +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `_dst` must be [valid] for writes of `_count * size_of::()` bytes. +/// +/// * `_dst` must be properly aligned. +/// +/// Note that even if `T` has size `0`, the pointer must be properly aligned. +/// +/// [valid]: crate::ptr#safety +/// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] #[rustc_intrinsic_must_be_overridden] @@ -3965,8 +3981,16 @@ pub const fn is_val_statically_known(_arg: T) -> bool { /// The stabilized form of this intrinsic is [`crate::mem::swap`]. /// /// # Safety +/// Behavior is undefined if any of the following conditions are violated: /// -/// `x` and `y` are readable and writable as `T`, and non-overlapping. +/// * Both `x` and `y` must be [valid] for both reads and writes. +/// +/// * Both `x` and `y` must be properly aligned. +/// +/// * The region of memory beginning at `x` must *not* overlap with the region of memory +/// beginning at `y`. +/// +/// [valid]: crate::ptr#safety #[rustc_nounwind] #[inline] #[rustc_intrinsic]