Skip to content

Commit 5dcc418

Browse files
committed
Document the conditional existence of alloc::sync and alloc::task.
The wording is copied from `std::sync::atomic::AtomicPtr`, with additional advice on how to `#[cfg]` for it.
1 parent c3b7d7b commit 5dcc418

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

library/alloc/src/sync.rs

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
//! Thread-safe reference-counting pointers.
44
//!
55
//! See the [`Arc<T>`][Arc] documentation for more details.
6+
//!
7+
//! **Note**: This module is only available on platforms that support atomic
8+
//! loads and stores of pointers. This may be detected at compile time using
9+
//! `#[cfg(target_has_atomic = "ptr")]`.
610
711
use core::any::Any;
812
use core::borrow;
@@ -82,6 +86,11 @@ macro_rules! acquire {
8286
/// [`Mutex`][mutex], [`RwLock`][rwlock], or one of the [`Atomic`][atomic]
8387
/// types.
8488
///
89+
/// **Note**: This type is only available on platforms that support atomic
90+
/// loads and stores of pointers, which includes all platforms that support
91+
/// the `std` crate but not all those which only support [`alloc`](crate).
92+
/// This may be detected at compile time using `#[cfg(target_has_atomic = "ptr")]`.
93+
///
8594
/// ## Thread Safety
8695
///
8796
/// Unlike [`Rc<T>`], `Arc<T>` uses atomic operations for its reference

library/alloc/src/task.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![stable(feature = "wake_trait", since = "1.51.0")]
2+
23
//! Types and Traits for working with asynchronous tasks.
4+
//!
5+
//! **Note**: This module is only available on platforms that support atomic
6+
//! loads and stores of pointers. This may be detected at compile time using
7+
//! `#[cfg(target_has_atomic = "ptr")]`.
8+
39
use core::mem::ManuallyDrop;
410
use core::task::{RawWaker, RawWakerVTable, Waker};
511

0 commit comments

Comments
 (0)