Skip to content

Commit fc63113

Browse files
committed
clarify ZST comment
1 parent 098bec8 commit fc63113

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/libcore/intrinsics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,8 @@ extern "rust-intrinsic" {
991991
/// in the region beginning at `*src` and the region beginning at `*dst` can
992992
/// [violate memory safety][read-ownership].
993993
///
994-
/// These restrictions apply even if the effectively copied size (`count *
995-
/// size_of::<T>()`) is `0`.
994+
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is
995+
/// `0`, the pointers must be non-NULL and properly aligned.
996996
///
997997
/// [`Copy`]: ../marker/trait.Copy.html
998998
/// [`read`]: ../ptr/fn.read.html
@@ -1074,8 +1074,8 @@ extern "rust-intrinsic" {
10741074
/// in the region beginning at `*src` and the region beginning at `*dst` can
10751075
/// [violate memory safety][read-ownership].
10761076
///
1077-
/// These restrictions apply even if the effectively copied size (`count *
1078-
/// size_of::<T>()`) is `0`.
1077+
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is
1078+
/// `0`, the pointers must be non-NULL and properly aligned.
10791079
///
10801080
/// [`Copy`]: ../marker/trait.Copy.html
10811081
/// [`read`]: ../ptr/fn.read.html
@@ -1121,8 +1121,8 @@ extern "rust-intrinsic" {
11211121
/// value of `T`. Creating an invalid value of `T` can result in undefined
11221122
/// behavior.
11231123
///
1124-
/// These restrictions apply even if the effectively written size (`count *
1125-
/// size_of::<T>()`) is `0`.
1124+
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is
1125+
/// `0`, the pointer must be non-NULL and properly aligned.
11261126
///
11271127
/// [valid]: ../ptr/index.html#safety
11281128
///

src/libcore/ptr.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub use intrinsics::write_bytes;
114114
/// again. [`write`] can be used to overwrite data without causing it to be
115115
/// dropped.
116116
///
117-
/// These restrictions apply even if `T` has size `0`.
117+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
118118
///
119119
/// [valid]: ../ptr/index.html#safety
120120
/// [`Copy`]: ../marker/trait.Copy.html
@@ -205,7 +205,7 @@ pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
205205
///
206206
/// * Both `x` and `y` must be properly aligned.
207207
///
208-
/// These restrictions apply even if `T` has size `0`.
208+
/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned.
209209
///
210210
/// [valid]: ../ptr/index.html#safety
211211
///
@@ -274,7 +274,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
274274
/// size_of::<T>()` bytes must *not* overlap with the region of memory
275275
/// beginning at `y` with the same size.
276276
///
277-
/// These restrictions apply even if `T` has size `0`.
277+
/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned.
278278
///
279279
/// [valid]: ../ptr/index.html#safety
280280
///
@@ -387,7 +387,7 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
387387
///
388388
/// * `dest` must be properly aligned.
389389
///
390-
/// These restrictions apply even if `T` has size `0`.
390+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
391391
///
392392
/// [valid]: ../ptr/index.html#safety
393393
///
@@ -426,7 +426,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
426426
/// * `src` must be properly aligned. Use [`read_unaligned`] if this is not the
427427
/// case.
428428
///
429-
/// These restrictions apply even if `T` has size `0`.
429+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
430430
///
431431
/// ## Ownership of the Returned Value
432432
///
@@ -542,7 +542,7 @@ pub unsafe fn read<T>(src: *const T) -> T {
542542
/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned
543543
/// value and the value at `*src` can [violate memory safety][read-ownership].
544544
///
545-
/// These restrictions apply even if `T` has size `0`.
545+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
546546
///
547547
/// [`Copy`]: ../marker/trait.Copy.html
548548
/// [`read`]: ./fn.read.html
@@ -620,7 +620,7 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
620620
/// * `dst` must be properly aligned. Use [`write_unaligned`] if this is not the
621621
/// case.
622622
///
623-
/// These restrictions apply even if `T` has size `0`.
623+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
624624
///
625625
/// [valid]: ../ptr/index.html#safety
626626
/// [`write_unaligned`]: ./fn.write_unaligned.html
@@ -693,7 +693,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
693693
///
694694
/// * `dst` must be [valid] for writes.
695695
///
696-
/// These restrictions apply even if `T` has size `0`.
696+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
697697
///
698698
/// [valid]: ../ptr/index.html#safety
699699
///
@@ -778,7 +778,7 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
778778
/// However, storing non-[`Copy`] types in volatile memory is almost certainly
779779
/// incorrect.
780780
///
781-
/// These restrictions apply even if `T` has size `0`.
781+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
782782
///
783783
/// [valid]: ../ptr/index.html#safety
784784
/// [`Copy`]: ../marker/trait.Copy.html
@@ -849,7 +849,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
849849
///
850850
/// * `dst` must be properly aligned.
851851
///
852-
/// These restrictions apply even if `T` has size `0`.
852+
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
853853
///
854854
/// [valid]: ../ptr/index.html#safety
855855
///

0 commit comments

Comments
 (0)