Skip to content

Commit abcdab7

Browse files
Update documentation of as_ptr to reflect that its usage must not lead to data races.
1 parent 4d051fb commit abcdab7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

library/core/src/sync/atomic.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,12 +3495,8 @@ macro_rules! atomic_int {
34953495
/// Doing non-atomic reads and writes on the resulting integer can be a data race.
34963496
/// This method is mostly useful for FFI, where the function signature may use
34973497
#[doc = concat!("`*mut ", stringify!($int_type), "` instead of `&", stringify!($atomic_type), "`.")]
3498-
///
3499-
/// Returning an `*mut` pointer from a shared reference to this atomic is safe because the
3500-
/// atomic types work with interior mutability. All modifications of an atomic change the value
3501-
/// through a shared reference, and can do so safely as long as they use atomic operations. Any
3502-
/// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same
3503-
/// restriction: operations on it must be atomic.
3498+
/// All modifications of an atomic change the value through a shared reference, and can do so safely
3499+
/// as long as they use atomic operations.
35043500
///
35053501
/// # Examples
35063502
///
@@ -3514,7 +3510,7 @@ macro_rules! atomic_int {
35143510
///
35153511
#[doc = concat!("let atomic = ", stringify!($atomic_type), "::new(1);")]
35163512
///
3517-
/// // SAFETY: Safe as long as `my_atomic_op` is atomic.
3513+
/// // SAFETY: `my_atomic_op` only uses atomic operations so it will not lead to a data race.
35183514
/// unsafe {
35193515
/// my_atomic_op(atomic.as_ptr());
35203516
/// }

0 commit comments

Comments
 (0)