diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-21 16:54:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-21 16:54:07 +0200 |
| commit | a45f69f27dce51b1124f2262c819da1f6221bdf6 (patch) | |
| tree | b88bba1bcb832134a3563db7d4102e040df7cdea /compiler/rustc_serialize/src | |
| parent | fd403f5d1780388a89fc70a3dd8bdac3c0e606c1 (diff) | |
| parent | e4720e1cf26b6a9804615f79dc6ff1a006399cf1 (diff) | |
| download | rust-a45f69f27dce51b1124f2262c819da1f6221bdf6.tar.gz rust-a45f69f27dce51b1124f2262c819da1f6221bdf6.zip | |
Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm
Replace most uses of `pointer::offset` with `add` and `sub` As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts. This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things. r? ````@scottmcm```` _split off from #100746_
Diffstat (limited to 'compiler/rustc_serialize/src')
| -rw-r--r-- | compiler/rustc_serialize/src/serialize.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index 36585b8d77e..9bd5550038f 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -273,7 +273,7 @@ impl<D: Decoder, T: Decodable<D>> Decodable<D> for Vec<T> { unsafe { let ptr: *mut T = vec.as_mut_ptr(); for i in 0..len { - std::ptr::write(ptr.offset(i as isize), Decodable::decode(d)); + std::ptr::write(ptr.add(i), Decodable::decode(d)); } vec.set_len(len); } |
