Skip to content

Commit 85558ad

Browse files
committed
adjust some const_eval_select safety comments
1 parent 15a4ed6 commit 85558ad

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

library/core/src/intrinsics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2068,8 +2068,8 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
20682068
#[cfg(debug_assertions)]
20692069
const fn compiletime_check<T>(_src: *const T, _dst: *mut T, _count: usize) {}
20702070
#[cfg(debug_assertions)]
2071-
// SAFETY: runtime debug-assertions are a best-effort basis; it's fine to
2072-
// not do them during compile time
2071+
// SAFETY: As per our safety precondition, we may assume that the `abort` above is never reached.
2072+
// Therefore, compiletime_check and runtime_check are observably equivalent.
20732073
unsafe {
20742074
const_eval_select((src, dst, count), compiletime_check, runtime_check);
20752075
}
@@ -2159,8 +2159,8 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
21592159
#[cfg(debug_assertions)]
21602160
const fn compiletime_check<T>(_src: *const T, _dst: *mut T) {}
21612161
#[cfg(debug_assertions)]
2162-
// SAFETY: runtime debug-assertions are a best-effort basis; it's fine to
2163-
// not do them during compile time
2162+
// SAFETY: As per our safety precondition, we may assume that the `abort` above is never reached.
2163+
// Therefore, compiletime_check and runtime_check are observably equivalent.
21642164
unsafe {
21652165
const_eval_select((src, dst), compiletime_check, runtime_check);
21662166
}

library/core/src/slice/raw.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ const fn debug_check_data_len<T>(data: *const T, len: usize) {
149149
// it is not required for safety (the safety must be guatanteed by
150150
// the `from_raw_parts[_mut]` caller).
151151
//
152-
// Since the checks are not required, we ignore them in CTFE as they can't
153-
// be done there (alignment does not make much sense there).
152+
// As per our safety precondition, we may assume that assertion above never fails.
153+
// Therefore, noop and rt_check are observably equivalent.
154154
unsafe {
155155
crate::intrinsics::const_eval_select((data,), noop, rt_check);
156156
}

0 commit comments

Comments
 (0)