diff options
| author | kennytm <kennytm@gmail.com> | 2018-08-21 22:05:30 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-08-21 22:05:30 +0800 |
| commit | 0dd88c97975b2a2e4ea3e4a2bdc3670a9f40bd67 (patch) | |
| tree | 0ad62b121fcafe2d11ee95819caf64e975d4ad00 /src/librustc_data_structures | |
| parent | 9bbab65ebefbeb512445a759603b03f858e5e9b9 (diff) | |
| parent | 993fb934640b7e514f3c629c33a2698a83ed8c3e (diff) | |
Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJung
Replace usages of ptr::offset with ptr::{add,sub}.
Rust provides these helper methods – so let's use them!
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/array_vec.rs | 6 | ||||
| -rw-r--r-- | src/librustc_data_structures/small_vec.rs | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/librustc_data_structures/array_vec.rs b/src/librustc_data_structures/array_vec.rs index 56bb9613242..45fb5657061 100644 --- a/src/librustc_data_structures/array_vec.rs +++ b/src/librustc_data_structures/array_vec.rs @@ -139,7 +139,7 @@ impl<A: Array> ArrayVec<A> { // whole Drain iterator (like &mut T). let range_slice = { let arr = &mut self.values as &mut [ManuallyDrop<<A as Array>::Element>]; - slice::from_raw_parts_mut(arr.as_mut_ptr().offset(start as isize), + slice::from_raw_parts_mut(arr.as_mut_ptr().add(start), end - start) }; Drain { @@ -262,8 +262,8 @@ impl<'a, A: Array> Drop for Drain<'a, A> { { let arr = &mut source_array_vec.values as &mut [ManuallyDrop<<A as Array>::Element>]; - let src = arr.as_ptr().offset(tail as isize); - let dst = arr.as_mut_ptr().offset(start as isize); + let src = arr.as_ptr().add(tail); + let dst = arr.as_mut_ptr().add(start); ptr::copy(src, dst, self.tail_len); }; source_array_vec.set_len(start + self.tail_len); diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs index 6f101b20d88..689aad25b43 100644 --- a/src/librustc_data_structures/small_vec.rs +++ b/src/librustc_data_structures/small_vec.rs @@ -125,7 +125,7 @@ impl<A: Array> SmallVec<A> { // infallible // The spot to put the new value { - let p = self.as_mut_ptr().offset(index as isize); + let p = self.as_mut_ptr().add(index); // Shift everything over to make space. (Duplicating the // `index`th element into two consecutive places.) ptr::copy(p, p.offset(1), len - index); |
