diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 9ef2c7cde02eb..0442e1639bac4 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2568,7 +2568,7 @@ pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) - let size = mem::size_of::() .checked_mul(count) .expect("is_nonoverlapping: `size_of::() * count` overflows a usize"); - let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize }; + let diff = src_usize.abs_diff(dst_usize); // If the absolute distance between the ptrs is at least as big as the size of the buffer, // they do not overlap. diff >= size