Skip to content

Commit 049d230

Browse files
committed
add missing safety in intrinsics
1 parent b44e14f commit 049d230

File tree

1 file changed

+22
-1
lines changed
  • library/core/src/intrinsics

1 file changed

+22
-1
lines changed

library/core/src/intrinsics/mod.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,10 @@ pub fn ptr_mask<T>(_ptr: *const T, _mask: usize) -> *const T {
20142014
/// The volatile parameter is set to `true`, so it will not be optimized out
20152015
/// unless size is equal to zero.
20162016
///
2017+
/// # Safety
2018+
///
2019+
/// The safety concerns are the same with [`copy_nonoverlapping`].
2020+
///
20172021
/// This intrinsic does not have a stable counterpart.
20182022
#[rustc_intrinsic]
20192023
#[rustc_intrinsic_must_be_overridden]
@@ -2042,6 +2046,16 @@ pub unsafe fn volatile_copy_memory<T>(_dst: *mut T, _src: *const T, _count: usiz
20422046
/// The volatile parameter is set to `true`, so it will not be optimized out
20432047
/// unless size is equal to zero.
20442048
///
2049+
/// # Safety
2050+
///
2051+
/// Behavior is undefined if any of the following conditions are violated:
2052+
///
2053+
/// * `_dst` must be [valid] for writes of `_count * size_of::<T>()` bytes.
2054+
///
2055+
/// * `_dst` must be properly aligned.
2056+
///
2057+
/// Note that even if `T` has size `0`, the pointer must be properly aligned.
2058+
///
20452059
/// This intrinsic does not have a stable counterpart.
20462060
#[rustc_intrinsic]
20472061
#[rustc_intrinsic_must_be_overridden]
@@ -3965,8 +3979,15 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
39653979
/// The stabilized form of this intrinsic is [`crate::mem::swap`].
39663980
///
39673981
/// # Safety
3982+
/// Behavior is undefined if any of the following conditions are violated:
3983+
///
3984+
/// * Both `x` and `y` must be [valid] for both reads and writes.
3985+
///
3986+
/// * Both `x` and `y` must be properly aligned.
3987+
///
3988+
/// * The region of memory beginning at `x` must *not* overlap with the region of memory
3989+
/// beginning at `y`.
39683990
///
3969-
/// `x` and `y` are readable and writable as `T`, and non-overlapping.
39703991
#[rustc_nounwind]
39713992
#[inline]
39723993
#[rustc_intrinsic]

0 commit comments

Comments
 (0)