diff --git a/tokio/src/io/util/read_to_end.rs b/tokio/src/io/util/read_to_end.rs index cbe9d112119..67aa8618a1c 100644 --- a/tokio/src/io/util/read_to_end.rs +++ b/tokio/src/io/util/read_to_end.rs @@ -146,13 +146,9 @@ fn reserve(buf: &mut Vec, read: &R, bytes: usize) { fn get_unused_capacity(buf: &mut Vec) -> &mut [MaybeUninit] { let prepare_from = buf.len(); let prepare_len = buf.capacity() - prepare_from; - // safety: prepare_from is the length of a vector, so it can't overflow isize, - // and the pointer will stay inside the allocation. - let ptr = unsafe { - buf.as_mut_ptr() - .offset(prepare_from as isize) - .cast::>() - }; + // safety: prepare_from is the length of the vector, so it will stay inside the + // allocation. + let ptr = unsafe { buf.as_mut_ptr().add(prepare_from).cast::>() }; // safety: The memory is properly allocated due to the invariants provided by // Vec, and since the item type is MaybeUninit, it is safe for the