Skip to content

Commit a9f58bf

Browse files
authored
Rollup merge of #144072 - usamoi:docs, r=Mark-Simulacrum
update `Atomic*::from_ptr` and `Atomic*::as_ptr` docs Since #128778, it's allowed to perform atomic read and non-atomic read on the same atomic at the same time. Update the `Atomic*::from_ptr` and `Atomic*::as_ptr` documentation to remove expressions such as `not allowed to mix atomic and non-atomic accesses`. see also [std::sync::atomic](https://doc.rust-lang.org/std/sync/atomic/index.html#memory-model-for-atomic-accesses)
2 parents 733dab5 + fe42025 commit a9f58bf

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

library/core/src/sync/atomic.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ impl AtomicBool {
563563
/// `align_of::<AtomicBool>() == 1`).
564564
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
565565
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
566-
/// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes,
567-
/// without synchronization.
566+
/// allowed to mix conflicting atomic and non-atomic accesses, or atomic accesses of different
567+
/// sizes, without synchronization.
568568
///
569569
/// [valid]: crate::ptr#safety
570570
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
@@ -1246,7 +1246,7 @@ impl AtomicBool {
12461246
/// atomic types work with interior mutability. All modifications of an atomic change the value
12471247
/// through a shared reference, and can do so safely as long as they use atomic operations. Any
12481248
/// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same
1249-
/// restriction: operations on it must be atomic.
1249+
/// restriction in [Memory model for atomic accesses].
12501250
///
12511251
/// # Examples
12521252
///
@@ -1264,6 +1264,8 @@ impl AtomicBool {
12641264
/// }
12651265
/// # }
12661266
/// ```
1267+
///
1268+
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
12671269
#[inline]
12681270
#[stable(feature = "atomic_as_ptr", since = "1.70.0")]
12691271
#[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")]
@@ -1519,8 +1521,8 @@ impl<T> AtomicPtr<T> {
15191521
/// can be bigger than `align_of::<*mut T>()`).
15201522
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
15211523
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
1522-
/// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes,
1523-
/// without synchronization.
1524+
/// allowed to mix conflicting atomic and non-atomic accesses, or atomic accesses of different
1525+
/// sizes, without synchronization.
15241526
///
15251527
/// [valid]: crate::ptr#safety
15261528
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
@@ -2488,7 +2490,7 @@ impl<T> AtomicPtr<T> {
24882490
/// atomic types work with interior mutability. All modifications of an atomic change the value
24892491
/// through a shared reference, and can do so safely as long as they use atomic operations. Any
24902492
/// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same
2491-
/// restriction: operations on it must be atomic.
2493+
/// restriction in [Memory model for atomic accesses].
24922494
///
24932495
/// # Examples
24942496
///
@@ -2507,6 +2509,8 @@ impl<T> AtomicPtr<T> {
25072509
/// my_atomic_op(atomic.as_ptr());
25082510
/// }
25092511
/// ```
2512+
///
2513+
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
25102514
#[inline]
25112515
#[stable(feature = "atomic_as_ptr", since = "1.70.0")]
25122516
#[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")]
@@ -2698,8 +2702,8 @@ macro_rules! atomic_int {
26982702
}]
26992703
/// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`.
27002704
/// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not
2701-
/// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes,
2702-
/// without synchronization.
2705+
/// allowed to mix conflicting atomic and non-atomic accesses, or atomic accesses of different
2706+
/// sizes, without synchronization.
27032707
///
27042708
/// [valid]: crate::ptr#safety
27052709
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
@@ -3620,7 +3624,7 @@ macro_rules! atomic_int {
36203624
/// atomic types work with interior mutability. All modifications of an atomic change the value
36213625
/// through a shared reference, and can do so safely as long as they use atomic operations. Any
36223626
/// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same
3623-
/// restriction: operations on it must be atomic.
3627+
/// restriction in [Memory model for atomic accesses].
36243628
///
36253629
/// # Examples
36263630
///
@@ -3640,6 +3644,8 @@ macro_rules! atomic_int {
36403644
/// }
36413645
/// # }
36423646
/// ```
3647+
///
3648+
/// [Memory model for atomic accesses]: self#memory-model-for-atomic-accesses
36433649
#[inline]
36443650
#[stable(feature = "atomic_as_ptr", since = "1.70.0")]
36453651
#[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")]

0 commit comments

Comments
 (0)