about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2024-03-09 13:36:36 -0500
committerBen Kimock <kimockb@gmail.com>2024-03-09 13:36:36 -0500
commit2a1f97f77ff2a6f6e27aae983420f4ee57056527 (patch)
treeeea9fd25063bbbd7befc51b88c48bd5e2dbd2079
parentaf49c4df0a666f3ed0cefaae63851667dde9647d (diff)
downloadrust-2a1f97f77ff2a6f6e27aae983420f4ee57056527.tar.gz
rust-2a1f97f77ff2a6f6e27aae983420f4ee57056527.zip
Explain why we don't use intrinsics::is_nonoverlapping
-rw-r--r--library/core/src/cell.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index e8590ab1158..0e719e169de 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -434,6 +434,8 @@ impl<T> Cell<T> {
     #[inline]
     #[stable(feature = "move_cell", since = "1.17.0")]
     pub fn swap(&self, other: &Self) {
+        // This function documents that it *will* panic, and intrinsics::is_nonoverlapping doesn't
+        // do the check in const, so trying to use it here would be inviting unnecessary fragility.
         fn is_nonoverlapping<T>(src: *const T, dst: *const T) -> bool {
             let src_usize = src.addr();
             let dst_usize = dst.addr();