Skip to content

Commit 2a1f97f

Browse files
committed
Explain why we don't use intrinsics::is_nonoverlapping
1 parent af49c4d commit 2a1f97f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/cell.rs

+2
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ impl<T> Cell<T> {
434434
#[inline]
435435
#[stable(feature = "move_cell", since = "1.17.0")]
436436
pub fn swap(&self, other: &Self) {
437+
// This function documents that it *will* panic, and intrinsics::is_nonoverlapping doesn't
438+
// do the check in const, so trying to use it here would be inviting unnecessary fragility.
437439
fn is_nonoverlapping<T>(src: *const T, dst: *const T) -> bool {
438440
let src_usize = src.addr();
439441
let dst_usize = dst.addr();

0 commit comments

Comments
 (0)