Skip to content

Commit 2f7e366

Browse files
committed
fix: additional wording nits
1 parent bedba77 commit 2f7e366

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

library/core/src/ptr/mod.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//! undefined behavior to perform two concurrent accesses to the same location from different
2929
//! threads unless both accesses only read from memory. Notice that this explicitly
3030
//! includes [`read_volatile`] and [`write_volatile`]: Volatile accesses cannot
31-
//! be used for inter-thread synchronization, regardless of whether it is acting on
31+
//! be used for inter-thread synchronization, regardless of whether they are acting on
3232
//! Rust memory or not.
3333
//! * The result of casting a reference to a pointer is valid for as long as the
3434
//! underlying allocation is live and no reference (just raw pointers) is used to
@@ -2036,11 +2036,10 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
20362036
/// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
20372037
/// [`read`], except for the additional guarantee that it won't be elided or reordered (see
20382038
/// above). This implies that the operation will actually access memory and not e.g. be lowered to
2039-
/// reusing data from a previous read, such as from a register on which previous load of that
2040-
/// memory was performed. Other than that, all the usual rules for memory accesses apply
2041-
/// (including provenance). In particular, just like in C, whether an operation is volatile has
2042-
/// no bearing whatsoever on questions involving concurrent access from multiple threads. Volatile
2043-
/// accesses behave exactly like non-atomic accesses in that regard.
2039+
/// reusing data from a previous read. Other than that, all the usual rules for memory accesses
2040+
/// apply (including provenance). In particular, just like in C, whether an operation is volatile
2041+
/// has no bearing whatsoever on questions involving concurrent accesses from multiple threads.
2042+
/// Volatile accesses behave exactly like non-atomic accesses in that regard.
20442043
///
20452044
/// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
20462045
/// allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
@@ -2050,10 +2049,11 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
20502049
/// Here, any address value is possible, including 0 and [`usize::MAX`], so long as the semantics
20512050
/// of such a read are well-defined by the target hardware. The provenance of the pointer is
20522051
/// irrelevant, and it can be created with [`without_provenance`]. The access must not trap. It
2053-
/// can cause side-effects, but those must not affect Rust-allocated memory in in any way. This
2052+
/// can cause side-effects, but those must not affect Rust-allocated memory in any way. This
20542053
/// access is still not considered [atomic], and as such it cannot be used for inter-thread
2055-
/// synchronization. Note that volatile memory operations where T is a zero-sized type are noops
2056-
/// and may be ignored.
2054+
/// synchronization.
2055+
///
2056+
/// Note that volatile memory operations where T is a zero-sized type are noops and may be ignored.
20572057
///
20582058
/// [allocation]: crate::ptr#allocated-object
20592059
/// [atomic]: crate::sync::atomic#memory-model-for-atomic-accesses
@@ -2121,7 +2121,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
21212121
/// usage that need to be distinguished:
21222122
///
21232123
/// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
2124-
/// [`write()`], except for the additional guarantee that it won't be elided or reordered (see
2124+
/// [`write`], except for the additional guarantee that it won't be elided or reordered (see
21252125
/// above). This implies that the operation will actually access memory and not e.g. be lowered to
21262126
/// a register access or stack pop. Other than that, all the usual rules for memory accesses apply
21272127
/// (including provenance). In particular, just like in C, whether an operation is volatile has no
@@ -2145,10 +2145,8 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
21452145
///
21462146
/// `write_volatile` does not drop the contents of `dst`. This is safe, but it could leak
21472147
/// allocations or resources, so care should be taken not to overwrite an object that should be
2148-
/// dropped when operating on Rust memory.
2149-
///
2150-
/// Additionally, it does not drop `src`. Semantically, `src` is moved into the location pointed to
2151-
/// by `dst`.
2148+
/// dropped when operating on Rust memory. Additionally, it does not drop `src`. Semantically, `src`
2149+
/// is moved into the location pointed to by `dst`.
21522150
///
21532151
/// [allocation]: crate::ptr#allocated-object
21542152
/// [atomic]: crate::sync::atomic#memory-model-for-atomic-accesses

0 commit comments

Comments
 (0)