@@ -622,6 +622,11 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
622
622
/// to not be elided or reordered by the compiler across other volatile
623
623
/// operations.
624
624
///
625
+ /// Memory read with `read_volatile` should almost always be written to using
626
+ /// [`write_volatile`].
627
+ ///
628
+ /// [`write_volatile`]: ./fn.write_volatile.html
629
+ ///
625
630
/// # Notes
626
631
///
627
632
/// Rust does not currently have a rigorously and formally defined memory model,
@@ -644,16 +649,13 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
644
649
///
645
650
/// * `src` must be properly aligned.
646
651
///
647
- /// Additionally, if `T` is not [`Copy`], only the returned value *or* the
648
- /// pointed-to value can be used or dropped after calling `read_volatile`.
649
- /// `read_volatile` creates a bitwise copy of `T`, regardless of whether `T:
650
- /// Copy`, which can result in undefined behavior if both copies are used.
651
- /// Note that `*src = foo` counts as a use because it will attempt to drop the
652
- /// value previously at `*src`. [`write_volatile`] can be used to overwrite
653
- /// data without causing it to be dropped.
652
+ /// Like [`read`], `read_volatile` creates a bitwise copy of the pointed-to
653
+ /// object, regardless of whether `T` is [`Copy`]. Using both values can cause
654
+ /// undefined behavior. However, storing non-[`Copy`] data in I/O memory is
655
+ /// almost certainly incorrect.
654
656
///
655
657
/// [`Copy`]: ../marker/trait.Copy.html
656
- /// [`write_volatile `]: ./fn.write_volatile .html
658
+ /// [`read `]: ./fn.read .html
657
659
///
658
660
/// # Examples
659
661
///
@@ -680,13 +682,18 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
680
682
/// to not be elided or reordered by the compiler across other volatile
681
683
/// operations.
682
684
///
685
+ /// Memory written with `write_volatile` should almost always be read from using
686
+ /// [`read_volatile`].
687
+ ///
683
688
/// `write_volatile` does not drop the contents of `dst`. This is safe, but it
684
689
/// could leak allocations or resources, so care must be taken not to overwrite
685
690
/// an object that should be dropped.
686
691
///
687
692
/// Additionally, it does not drop `src`. Semantically, `src` is moved into the
688
693
/// location pointed to by `dst`.
689
694
///
695
+ /// [`read_volatile`]: ./fn.read_volatile.html
696
+ ///
690
697
/// # Notes
691
698
///
692
699
/// Rust does not currently have a rigorously and formally defined memory model,
0 commit comments