various updates based on review · qinheping/verify-rust-std@acd2526 (original) (raw)

`@@ -353,8 +353,8 @@ impl<T: ?Sized> *mut T {

`

353

353

`///

`

354

354

`/// If any of the following conditions are violated, the result is Undefined Behavior:

`

355

355

`///

`

356

``

`` -

/// * The computed offset, count * size_of::<T>() bytes (using unbounded arithmetic),

``

357

``

`` -

/// must fit in an isize.

``

``

356

`` +

/// * The offset in bytes, count * size_of::<T>(), computed on mathematical integers (without

``

``

357

`` +

/// "wrapping around"), must fit in an isize.

``

358

358

`///

`

359

359

`` /// * If the computed offset is non-zero, then self must be derived from a pointer to some

``

360

360

`` /// [allocated object], and the entire memory range between self and the result must be in

``

`@@ -399,7 +399,7 @@ impl<T: ?Sized> *mut T {

`

399

399

`unsafe { intrinsics::offset(self, count) }

`

400

400

`}

`

401

401

``

402

``

`-

/// Calculates the offset from a pointer in bytes.

`

``

402

`+

/// Adds a signed offset in bytes to a pointer.

`

403

403

`///

`

404

404

`` /// count is in units of bytes.

``

405

405

`///

`

`@@ -889,7 +889,11 @@ impl<T: ?Sized> *mut T {

`

889

889

`unsafe { (self as *const T).sub_ptr(origin) }

`

890

890

`}

`

891

891

``

892

``

`-

/// Adds an offset to a pointer.

`

``

892

`+

/// Adds an unsigned offset to a pointer.

`

``

893

`+

///

`

``

894

`+

/// This can only move the pointer forward (or not move it). If you need to move forward or

`

``

895

`` +

/// backward depending on the value, then you might want offset instead

``

``

896

`+

/// which takes a signed offset.

`

893

897

`///

`

894

898

`` /// count is in units of T; e.g., a count of 3 represents a pointer

``

895

899

`` /// offset of 3 * size_of::<T>() bytes.

``

`@@ -898,8 +902,8 @@ impl<T: ?Sized> *mut T {

`

898

902

`///

`

899

903

`/// If any of the following conditions are violated, the result is Undefined Behavior:

`

900

904

`///

`

901

``

`` -

/// * The computed offset, count * size_of::<T>() bytes (using unbounded arithmetic),

``

902

``

`` -

/// must fit in an isize.

``

``

905

`` +

/// * The offset in bytes, count * size_of::<T>(), computed on mathematical integers (without

``

``

906

`` +

/// "wrapping around"), must fit in an isize.

``

903

907

`///

`

904

908

`` /// * If the computed offset is non-zero, then self must be derived from a pointer to some

``

905

909

`` /// [allocated object], and the entire memory range between self and the result must be in

``

`@@ -942,7 +946,7 @@ impl<T: ?Sized> *mut T {

`

942

946

`unsafe { intrinsics::offset(self, count) }

`

943

947

`}

`

944

948

``

945

``

`` -

/// Calculates the offset from a pointer in bytes (convenience for .byte_offset(count as isize)).

``

``

949

`+

/// Adds an unsigned offset in bytes to a pointer.

`

946

950

`///

`

947

951

`` /// count is in units of bytes.

``

948

952

`///

`

`@@ -963,7 +967,11 @@ impl<T: ?Sized> *mut T {

`

963

967

`unsafe { self.cast::().add(count).with_metadata_of(self) }

`

964

968

`}

`

965

969

``

966

``

`-

/// Subtracts an offset from a pointer.

`

``

970

`+

/// Subtracts an unsigned offset from a pointer.

`

``

971

`+

///

`

``

972

`+

/// This can only move the pointer backward (or not move it). If you need to move forward or

`

``

973

`` +

/// backward depending on the value, then you might want offset instead

``

``

974

`+

/// which takes a signed offset.

`

967

975

`///

`

968

976

`` /// count is in units of T; e.g., a count of 3 represents a pointer

``

969

977

`` /// offset of 3 * size_of::<T>() bytes.

``

`@@ -972,8 +980,8 @@ impl<T: ?Sized> *mut T {

`

972

980

`///

`

973

981

`/// If any of the following conditions are violated, the result is Undefined Behavior:

`

974

982

`///

`

975

``

`` -

/// * The computed offset, count * size_of::<T>() bytes (using unbounded arithmetic),

``

976

``

`` -

/// must fit in an isize.

``

``

983

`` +

/// * The offset in bytes, count * size_of::<T>(), computed on mathematical integers (without

``

``

984

`` +

/// "wrapping around"), must fit in an isize.

``

977

985

`///

`

978

986

`` /// * If the computed offset is non-zero, then self must be derived from a pointer to some

``

979

987

`` /// [allocated object], and the entire memory range between self and the result must be in

``

`@@ -1024,8 +1032,7 @@ impl<T: ?Sized> *mut T {

`

1024

1032

`}

`

1025

1033

`}

`

1026

1034

``

1027

``

`-

/// Calculates the offset from a pointer in bytes (convenience for

`

1028

``

`` -

/// .byte_offset((count as isize).wrapping_neg())).

``

``

1035

`+

/// Subtracts an unsigned offset in bytes from a pointer.

`

1029

1036

`///

`

1030

1037

`` /// count is in units of bytes.

``

1031

1038

`///

`