From 7514d760b8fabd46e4874520b653ab8803c3517e Mon Sep 17 00:00:00 2001 From: Aria Beingessner Date: Sat, 26 Mar 2022 17:03:40 -0400 Subject: cleanup some of the less terrifying library code --- library/alloc/src/slice.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'library/alloc/src') diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index 7c892f03bfb..31365562ddb 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -1043,9 +1043,9 @@ where impl Drop for MergeHole { fn drop(&mut self) { - // `T` is not a zero-sized type, so it's okay to divide by its size. - let len = (self.end.addr() - self.start.addr()) / mem::size_of::(); + // `T` is not a zero-sized type, and these are pointers into a slice's elements. unsafe { + let len = self.end.offset_from(self.start) as usize; ptr::copy_nonoverlapping(self.start, self.dest, len); } } -- cgit 1.4.1-3-g733a5