diff options
| author | bendn <bend.n@outlook.com> | 2025-02-23 20:26:28 +0700 |
|---|---|---|
| committer | bendn <bend.n@outlook.com> | 2025-02-23 23:11:00 +0700 |
| commit | c813d8f3e49aa4c85c9eded426b6507701a2ff94 (patch) | |
| tree | e40e0f5366b247f274c1107760ae404bac216b57 /library/alloc/src/vec | |
| parent | 1805b3348341e0918912ab61cb1dffad41648d23 (diff) | |
| download | rust-c813d8f3e49aa4c85c9eded426b6507701a2ff94.tar.gz rust-c813d8f3e49aa4c85c9eded426b6507701a2ff94.zip | |
rename sub_ptr 😅
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/drain.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/vec/in_place_collect.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/vec/in_place_drop.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/vec/into_iter.rs | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/library/alloc/src/vec/drain.rs b/library/alloc/src/vec/drain.rs index 9362cef2a1b..8705a9c3d26 100644 --- a/library/alloc/src/vec/drain.rs +++ b/library/alloc/src/vec/drain.rs @@ -232,7 +232,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> { // it from the original vec but also avoid creating a &mut to the front since that could // invalidate raw pointers to it which some unsafe code might rely on. let vec_ptr = vec.as_mut().as_mut_ptr(); - let drop_offset = drop_ptr.sub_ptr(vec_ptr); + let drop_offset = drop_ptr.offset_from_unsigned(vec_ptr); let to_drop = ptr::slice_from_raw_parts_mut(vec_ptr.add(drop_offset), drop_len); ptr::drop_in_place(to_drop); } diff --git a/library/alloc/src/vec/in_place_collect.rs b/library/alloc/src/vec/in_place_collect.rs index a7dba16944e..dffd85f13aa 100644 --- a/library/alloc/src/vec/in_place_collect.rs +++ b/library/alloc/src/vec/in_place_collect.rs @@ -379,7 +379,7 @@ where let sink = self.try_fold::<_, _, Result<_, !>>(sink, write_in_place_with_drop(end)).into_ok(); // iteration succeeded, don't drop head - unsafe { ManuallyDrop::new(sink).dst.sub_ptr(dst_buf) } + unsafe { ManuallyDrop::new(sink).dst.offset_from_unsigned(dst_buf) } } } diff --git a/library/alloc/src/vec/in_place_drop.rs b/library/alloc/src/vec/in_place_drop.rs index 4d5b4e47d39..997c4c7525b 100644 --- a/library/alloc/src/vec/in_place_drop.rs +++ b/library/alloc/src/vec/in_place_drop.rs @@ -14,7 +14,7 @@ pub(super) struct InPlaceDrop<T> { impl<T> InPlaceDrop<T> { fn len(&self) -> usize { - unsafe { self.dst.sub_ptr(self.inner) } + unsafe { self.dst.offset_from_unsigned(self.inner) } } } diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index 9a6745fdbc0..52597e41c1c 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -179,7 +179,7 @@ impl<T, A: Allocator> IntoIter<T, A> { // say that they're all at the beginning of the "allocation". 0..this.len() } else { - this.ptr.sub_ptr(this.buf)..this.end.sub_ptr(buf) + this.ptr.offset_from_unsigned(this.buf)..this.end.offset_from_unsigned(buf) }; let cap = this.cap; let alloc = ManuallyDrop::take(&mut this.alloc); @@ -230,7 +230,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> { let exact = if T::IS_ZST { self.end.addr().wrapping_sub(self.ptr.as_ptr().addr()) } else { - unsafe { non_null!(self.end, T).sub_ptr(self.ptr) } + unsafe { non_null!(self.end, T).offset_from_unsigned(self.ptr) } }; (exact, Some(exact)) } |
