Skip to content

Commit 6e9a52c

Browse files
authored
Rollup merge of #110388 - JohnBobbo96:remove-intrinsic-unwrap, r=the8472
Add a message for if an overflow occurs in `core::intrinsics::is_nonoverlapping`.
2 parents ee9b804 + 3dba587 commit 6e9a52c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/core/src/intrinsics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2519,7 +2519,9 @@ pub(crate) fn is_valid_allocation_size<T>(len: usize) -> bool {
25192519
pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -> bool {
25202520
let src_usize = src.addr();
25212521
let dst_usize = dst.addr();
2522-
let size = mem::size_of::<T>().checked_mul(count).unwrap();
2522+
let size = mem::size_of::<T>()
2523+
.checked_mul(count)
2524+
.expect("is_nonoverlapping: `size_of::<T>() * count` overflows a usize");
25232525
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
25242526
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
25252527
// they do not overlap.

0 commit comments

Comments
 (0)