From fc63113f1fca416e88cafa10670f7743aaa82759 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 30 Aug 2018 16:19:05 +0200 Subject: [PATCH] clarify ZST comment --- src/libcore/intrinsics.rs | 12 ++++++------ src/libcore/ptr.rs | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 9748feddddf..c82eaa13eef 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -991,8 +991,8 @@ extern "rust-intrinsic" { /// in the region beginning at `*src` and the region beginning at `*dst` can /// [violate memory safety][read-ownership]. /// - /// These restrictions apply even if the effectively copied size (`count * - /// size_of::()`) is `0`. + /// Note that even if the effectively copied size (`count * size_of::()`) is + /// `0`, the pointers must be non-NULL and properly aligned. /// /// [`Copy`]: ../marker/trait.Copy.html /// [`read`]: ../ptr/fn.read.html @@ -1074,8 +1074,8 @@ extern "rust-intrinsic" { /// in the region beginning at `*src` and the region beginning at `*dst` can /// [violate memory safety][read-ownership]. /// - /// These restrictions apply even if the effectively copied size (`count * - /// size_of::()`) is `0`. + /// Note that even if the effectively copied size (`count * size_of::()`) is + /// `0`, the pointers must be non-NULL and properly aligned. /// /// [`Copy`]: ../marker/trait.Copy.html /// [`read`]: ../ptr/fn.read.html @@ -1121,8 +1121,8 @@ extern "rust-intrinsic" { /// value of `T`. Creating an invalid value of `T` can result in undefined /// behavior. /// - /// These restrictions apply even if the effectively written size (`count * - /// size_of::()`) is `0`. + /// Note that even if the effectively copied size (`count * size_of::()`) is + /// `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 07e8d253af8..98f5ab21f27 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -114,7 +114,7 @@ pub use intrinsics::write_bytes; /// again. [`write`] can be used to overwrite data without causing it to be /// dropped. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// [`Copy`]: ../marker/trait.Copy.html @@ -205,7 +205,7 @@ pub const fn null_mut() -> *mut T { 0 as *mut T } /// /// * Both `x` and `y` must be properly aligned. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// @@ -274,7 +274,7 @@ pub unsafe fn swap(x: *mut T, y: *mut T) { /// size_of::()` bytes must *not* overlap with the region of memory /// beginning at `y` with the same size. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// @@ -387,7 +387,7 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { /// /// * `dest` must be properly aligned. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// @@ -426,7 +426,7 @@ pub unsafe fn replace(dest: *mut T, mut src: T) -> T { /// * `src` must be properly aligned. Use [`read_unaligned`] if this is not the /// case. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// ## Ownership of the Returned Value /// @@ -542,7 +542,7 @@ pub unsafe fn read(src: *const T) -> T { /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned /// value and the value at `*src` can [violate memory safety][read-ownership]. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [`Copy`]: ../marker/trait.Copy.html /// [`read`]: ./fn.read.html @@ -620,7 +620,7 @@ pub unsafe fn read_unaligned(src: *const T) -> T { /// * `dst` must be properly aligned. Use [`write_unaligned`] if this is not the /// case. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// [`write_unaligned`]: ./fn.write_unaligned.html @@ -693,7 +693,7 @@ pub unsafe fn write(dst: *mut T, src: T) { /// /// * `dst` must be [valid] for writes. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// @@ -778,7 +778,7 @@ pub unsafe fn write_unaligned(dst: *mut T, src: T) { /// However, storing non-[`Copy`] types in volatile memory is almost certainly /// incorrect. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety /// [`Copy`]: ../marker/trait.Copy.html @@ -849,7 +849,7 @@ pub unsafe fn read_volatile(src: *const T) -> T { /// /// * `dst` must be properly aligned. /// -/// These restrictions apply even if `T` has size `0`. +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// [valid]: ../ptr/index.html#safety ///