From 2a1f97f77ff2a6f6e27aae983420f4ee57056527 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 9 Mar 2024 13:36:36 -0500 Subject: [PATCH] Explain why we don't use intrinsics::is_nonoverlapping --- library/core/src/cell.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index e8590ab115860..0e719e169deb6 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -434,6 +434,8 @@ impl Cell { #[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(src: *const T, dst: *const T) -> bool { let src_usize = src.addr(); let dst_usize = dst.addr();