about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-08-30 16:19:05 +0200
committerRalf Jung <post@ralfj.de>2018-08-30 16:19:05 +0200
commitfc63113f1fca416e88cafa10670f7743aaa82759 (patch)
tree38652258a5d0b33b825dc9b968ef53a9510852af
parent098bec82f6171c2e7e5b4136880eb52eda876bde (diff)
downloadrust-fc63113f1fca416e88cafa10670f7743aaa82759.tar.gz
rust-fc63113f1fca416e88cafa10670f7743aaa82759.zip
clarify ZST comment
-rw-r--r--src/libcore/intrinsics.rs12
-rw-r--r--src/libcore/ptr.rs20
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::<T>()`) is `0`.
+    /// Note that even if the effectively copied size (`count * size_of::<T>()`) 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::<T>()`) is `0`.
+    /// Note that even if the effectively copied size (`count * size_of::<T>()`) 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::<T>()`) is `0`.
+    /// Note that even if the effectively copied size (`count * size_of::<T>()`) 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<T>() -> *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<T>(x: *mut T, y: *mut T) {
 ///   size_of::<T>()` 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<T>(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<T>(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<T>(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<T>(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<T>(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<T>(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
 ///