@@ -119,10 +119,13 @@ mod mut_ptr;
119
119
///
120
120
/// Behavior is undefined if any of the following conditions are violated:
121
121
///
122
- /// * `to_drop` must be [valid] for reads.
122
+ /// * `to_drop` must be [valid] for both reads and writes .
123
123
///
124
124
/// * `to_drop` must be properly aligned.
125
125
///
126
+ /// * The value `to_drop` points to must be valid for dropping, which may mean it must uphold
127
+ /// additional invariants - this is type-dependent.
128
+ ///
126
129
/// Additionally, if `T` is not [`Copy`], using the pointed-to value after
127
130
/// calling `drop_in_place` can cause undefined behavior. Note that `*to_drop =
128
131
/// foo` counts as a use because it will cause the value to be dropped
@@ -289,7 +292,7 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
289
292
///
290
293
/// Behavior is undefined if any of the following conditions are violated:
291
294
///
292
- /// * Both `x` and `y` must be [valid] for reads and writes.
295
+ /// * Both `x` and `y` must be [valid] for both reads and writes.
293
296
///
294
297
/// * Both `x` and `y` must be properly aligned.
295
298
///
@@ -355,7 +358,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
355
358
///
356
359
/// Behavior is undefined if any of the following conditions are violated:
357
360
///
358
- /// * Both `x` and `y` must be [valid] for reads and writes of `count *
361
+ /// * Both `x` and `y` must be [valid] for both reads and writes of `count *
359
362
/// size_of::<T>()` bytes.
360
363
///
361
364
/// * Both `x` and `y` must be properly aligned.
@@ -471,10 +474,12 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
471
474
///
472
475
/// Behavior is undefined if any of the following conditions are violated:
473
476
///
474
- /// * `dst` must be [valid] for writes.
477
+ /// * `dst` must be [valid] for both reads and writes.
475
478
///
476
479
/// * `dst` must be properly aligned.
477
480
///
481
+ /// * `dst` must point to a properly initialized value of type `T`.
482
+ ///
478
483
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
479
484
///
480
485
/// [valid]: ../ptr/index.html#safety
@@ -514,6 +519,8 @@ pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
514
519
/// * `src` must be properly aligned. Use [`read_unaligned`] if this is not the
515
520
/// case.
516
521
///
522
+ /// * `src` must point to a properly initialized value of type `T`.
523
+ ///
517
524
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
518
525
///
519
526
/// # Examples
@@ -628,6 +635,8 @@ pub unsafe fn read<T>(src: *const T) -> T {
628
635
///
629
636
/// * `src` must be [valid] for reads.
630
637
///
638
+ /// * `src` must point to a properly initialized value of type `T`.
639
+ ///
631
640
/// Like [`read`], `read_unaligned` creates a bitwise copy of `T`, regardless of
632
641
/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned
633
642
/// value and the value at `*src` can [violate memory safety][read-ownership].
@@ -922,6 +931,8 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
922
931
///
923
932
/// * `src` must be properly aligned.
924
933
///
934
+ /// * `src` must point to a properly initialized value of type `T`.
935
+ ///
925
936
/// Like [`read`], `read_volatile` creates a bitwise copy of `T`, regardless of
926
937
/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned
927
938
/// value and the value at `*src` can [violate memory safety][read-ownership].
0 commit comments