mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Use a saturating_mul
instead of a checked_mul
and `unwrap` in `core::intrinsics`.
This commit is contained in:
parent
2a71115261
commit
d0603fdafa
@ -2519,7 +2519,7 @@ pub(crate) fn is_valid_allocation_size<T>(len: usize) -> bool {
|
||||
pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -> bool {
|
||||
let src_usize = src.addr();
|
||||
let dst_usize = dst.addr();
|
||||
let size = mem::size_of::<T>().checked_mul(count).unwrap();
|
||||
let size = mem::size_of::<T>().saturating_mul(count);
|
||||
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
|
||||
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
|
||||
// they do not overlap.
|
||||
|
Loading…
Reference in New Issue
Block a user