Skip to content

Commit d417c1f

Browse files
Update documentation of as_ptr to reflect that its usage must not lead to data races.
1 parent 7d7de5b commit d417c1f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

library/core/src/sync/atomic.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -3401,12 +3401,8 @@ macro_rules! atomic_int {
34013401
/// Doing non-atomic reads and writes on the resulting integer can be a data race.
34023402
/// This method is mostly useful for FFI, where the function signature may use
34033403
#[doc = concat!("`*mut ", stringify!($int_type), "` instead of `&", stringify!($atomic_type), "`.")]
3404-
///
3405-
/// Returning an `*mut` pointer from a shared reference to this atomic is safe because the
3406-
/// atomic types work with interior mutability. All modifications of an atomic change the value
3407-
/// through a shared reference, and can do so safely as long as they use atomic operations. Any
3408-
/// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same
3409-
/// restriction: operations on it must be atomic.
3404+
/// All modifications of an atomic change the value through a shared reference, and can do so safely
3405+
/// as long as they use atomic operations.
34103406
///
34113407
/// # Examples
34123408
///
@@ -3420,7 +3416,7 @@ macro_rules! atomic_int {
34203416
///
34213417
#[doc = concat!("let atomic = ", stringify!($atomic_type), "::new(1);")]
34223418
///
3423-
/// // SAFETY: Safe as long as `my_atomic_op` is atomic.
3419+
/// // SAFETY: `my_atomic_op` only uses atomic operations so it will not lead to a data race.
34243420
/// unsafe {
34253421
/// my_atomic_op(atomic.as_ptr());
34263422
/// }

0 commit comments

Comments
 (0)