Skip to content

Commit

Permalink
Explain why we don't use intrinsics::is_nonoverlapping
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Mar 9, 2024
1 parent af49c4d commit 2a1f97f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2a1f97f

Please sign in to comment.