diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 3814c4237f1..975dc593b51 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2068,8 +2068,8 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us #[cfg(debug_assertions)] const fn compiletime_check(_src: *const T, _dst: *mut T, _count: usize) {} #[cfg(debug_assertions)] - // SAFETY: runtime debug-assertions are a best-effort basis; it's fine to - // not do them during compile time + // SAFETY: As per our safety precondition, we may assume that the `abort` above is never reached. + // Therefore, compiletime_check and runtime_check are observably equivalent. unsafe { const_eval_select((src, dst, count), compiletime_check, runtime_check); } @@ -2159,8 +2159,8 @@ pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { #[cfg(debug_assertions)] const fn compiletime_check(_src: *const T, _dst: *mut T) {} #[cfg(debug_assertions)] - // SAFETY: runtime debug-assertions are a best-effort basis; it's fine to - // not do them during compile time + // SAFETY: As per our safety precondition, we may assume that the `abort` above is never reached. + // Therefore, compiletime_check and runtime_check are observably equivalent. unsafe { const_eval_select((src, dst), compiletime_check, runtime_check); } diff --git a/library/core/src/slice/raw.rs b/library/core/src/slice/raw.rs index 81bb16d5401..a8667c3a8ca 100644 --- a/library/core/src/slice/raw.rs +++ b/library/core/src/slice/raw.rs @@ -149,8 +149,8 @@ const fn debug_check_data_len(data: *const T, len: usize) { // it is not required for safety (the safety must be guatanteed by // the `from_raw_parts[_mut]` caller). // - // Since the checks are not required, we ignore them in CTFE as they can't - // be done there (alignment does not make much sense there). + // As per our safety precondition, we may assume that assertion above never fails. + // Therefore, noop and rt_check are observably equivalent. unsafe { crate::intrinsics::const_eval_select((data,), noop, rt_check); }