Skip to content

Commit 7756d39

Browse files
Rollup merge of #44854 - lucasem:atomic-docs, r=steveklabnik
docs improvement sync::atomic::Atomic* Addresses the `Atomic*` part of #29377. r? @steveklabnik
2 parents 7c3d376 + f7fd04a commit 7756d39

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/libcore/sync/atomic.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,24 @@ macro_rules! atomic_int {
926926
$stable_cxchg:meta,
927927
$stable_debug:meta,
928928
$stable_access:meta,
929+
$s_int_type:expr, $int_ref:expr,
929930
$int_type:ident $atomic_type:ident $atomic_init:ident) => {
930931
/// An integer type which can be safely shared between threads.
931932
///
932-
/// This type has the same in-memory representation as the underlying integer type.
933+
/// This type has the same in-memory representation as the underlying
934+
/// integer type, [`
935+
#[doc = $s_int_type]
936+
/// `](
937+
#[doc = $int_ref]
938+
/// ). For more about the differences between atomic types and
939+
/// non-atomic types, please see the [module-level documentation].
940+
///
941+
/// Please note that examples are shared between atomic variants of
942+
/// primitive integer types, so it's normal that they are all
943+
/// demonstrating [`AtomicIsize`].
944+
///
945+
/// [module-level documentation]: index.html
946+
/// [`AtomicIsize`]: struct.AtomicIsize.html
933947
#[$stable]
934948
pub struct $atomic_type {
935949
v: UnsafeCell<$int_type>,
@@ -1339,6 +1353,7 @@ atomic_int! {
13391353
unstable(feature = "integer_atomics", issue = "32976"),
13401354
unstable(feature = "integer_atomics", issue = "32976"),
13411355
unstable(feature = "integer_atomics", issue = "32976"),
1356+
"i8", "../../../std/primitive.i8.html",
13421357
i8 AtomicI8 ATOMIC_I8_INIT
13431358
}
13441359
#[cfg(target_has_atomic = "8")]
@@ -1348,6 +1363,7 @@ atomic_int! {
13481363
unstable(feature = "integer_atomics", issue = "32976"),
13491364
unstable(feature = "integer_atomics", issue = "32976"),
13501365
unstable(feature = "integer_atomics", issue = "32976"),
1366+
"u8", "../../../std/primitive.u8.html",
13511367
u8 AtomicU8 ATOMIC_U8_INIT
13521368
}
13531369
#[cfg(target_has_atomic = "16")]
@@ -1357,6 +1373,7 @@ atomic_int! {
13571373
unstable(feature = "integer_atomics", issue = "32976"),
13581374
unstable(feature = "integer_atomics", issue = "32976"),
13591375
unstable(feature = "integer_atomics", issue = "32976"),
1376+
"i16", "../../../std/primitive.i16.html",
13601377
i16 AtomicI16 ATOMIC_I16_INIT
13611378
}
13621379
#[cfg(target_has_atomic = "16")]
@@ -1366,6 +1383,7 @@ atomic_int! {
13661383
unstable(feature = "integer_atomics", issue = "32976"),
13671384
unstable(feature = "integer_atomics", issue = "32976"),
13681385
unstable(feature = "integer_atomics", issue = "32976"),
1386+
"u16", "../../../std/primitive.u16.html",
13691387
u16 AtomicU16 ATOMIC_U16_INIT
13701388
}
13711389
#[cfg(target_has_atomic = "32")]
@@ -1375,6 +1393,7 @@ atomic_int! {
13751393
unstable(feature = "integer_atomics", issue = "32976"),
13761394
unstable(feature = "integer_atomics", issue = "32976"),
13771395
unstable(feature = "integer_atomics", issue = "32976"),
1396+
"i32", "../../../std/primitive.i32.html",
13781397
i32 AtomicI32 ATOMIC_I32_INIT
13791398
}
13801399
#[cfg(target_has_atomic = "32")]
@@ -1384,6 +1403,7 @@ atomic_int! {
13841403
unstable(feature = "integer_atomics", issue = "32976"),
13851404
unstable(feature = "integer_atomics", issue = "32976"),
13861405
unstable(feature = "integer_atomics", issue = "32976"),
1406+
"u32", "../../../std/primitive.u32.html",
13871407
u32 AtomicU32 ATOMIC_U32_INIT
13881408
}
13891409
#[cfg(target_has_atomic = "64")]
@@ -1393,6 +1413,7 @@ atomic_int! {
13931413
unstable(feature = "integer_atomics", issue = "32976"),
13941414
unstable(feature = "integer_atomics", issue = "32976"),
13951415
unstable(feature = "integer_atomics", issue = "32976"),
1416+
"i64", "../../../std/primitive.i64.html",
13961417
i64 AtomicI64 ATOMIC_I64_INIT
13971418
}
13981419
#[cfg(target_has_atomic = "64")]
@@ -1402,6 +1423,7 @@ atomic_int! {
14021423
unstable(feature = "integer_atomics", issue = "32976"),
14031424
unstable(feature = "integer_atomics", issue = "32976"),
14041425
unstable(feature = "integer_atomics", issue = "32976"),
1426+
"u64", "../../../std/primitive.u64.html",
14051427
u64 AtomicU64 ATOMIC_U64_INIT
14061428
}
14071429
#[cfg(target_has_atomic = "ptr")]
@@ -1411,6 +1433,7 @@ atomic_int!{
14111433
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
14121434
stable(feature = "atomic_debug", since = "1.3.0"),
14131435
stable(feature = "atomic_access", since = "1.15.0"),
1436+
"isize", "../../../std/primitive.isize.html",
14141437
isize AtomicIsize ATOMIC_ISIZE_INIT
14151438
}
14161439
#[cfg(target_has_atomic = "ptr")]
@@ -1420,6 +1443,7 @@ atomic_int!{
14201443
stable(feature = "extended_compare_and_swap", since = "1.10.0"),
14211444
stable(feature = "atomic_debug", since = "1.3.0"),
14221445
stable(feature = "atomic_access", since = "1.15.0"),
1446+
"usize", "../../../std/primitive.usize.html",
14231447
usize AtomicUsize ATOMIC_USIZE_INIT
14241448
}
14251449

0 commit comments

Comments
 (0)