about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-11-28 14:00:58 -0500
committerRalf Jung <post@ralfj.de>2021-11-28 14:00:58 -0500
commit85558ad5b39d435d3c57e3e0df5f4c160ee0c6e3 (patch)
treef5ab48ed6c5a3546708582676fe058b4f9c76602 /library/core/src
parent15a4ed693722b4bb6d2fa43272a58ab94acfec1a (diff)
downloadrust-85558ad5b39d435d3c57e3e0df5f4c160ee0c6e3.tar.gz
rust-85558ad5b39d435d3c57e3e0df5f4c160ee0c6e3.zip
adjust some const_eval_select safety comments
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/intrinsics.rs8
-rw-r--r--library/core/src/slice/raw.rs4
2 files changed, 6 insertions, 6 deletions
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<T>(src: *const T, dst: *mut T, count: us
     #[cfg(debug_assertions)]
     const fn compiletime_check<T>(_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<T>(src: *const T, dst: *mut T, count: usize) {
     #[cfg(debug_assertions)]
     const fn compiletime_check<T>(_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<T>(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);
     }