diff options
| author | Aria Beingessner <a.beingessner@gmail.com> | 2022-03-26 17:03:40 -0400 |
|---|---|---|
| committer | Aria Beingessner <a.beingessner@gmail.com> | 2022-03-29 20:18:27 -0400 |
| commit | 7514d760b8fabd46e4874520b653ab8803c3517e (patch) | |
| tree | ad06f9326522bc789d650376a836f1d49fbfeb83 /library/alloc/src | |
| parent | 31e1cde4b5bd70dfe892f5e7bc449ad3a6e1d773 (diff) | |
| download | rust-7514d760b8fabd46e4874520b653ab8803c3517e.tar.gz rust-7514d760b8fabd46e4874520b653ab8803c3517e.zip | |
cleanup some of the less terrifying library code
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/slice.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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<T> Drop for MergeHole<T> { 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>(); + // `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); } } |
