Skip to content

Commit 8c9555c

Browse files
authored
Rollup merge of rust-lang#120823 - LegionMammal978:clarify-atomic-align, r=RalfJung
Clarify that atomic and regular integers can differ in alignment The documentation for atomic integers says that they have the "same in-memory representation" as their underlying integers. This might be misconstrued as implying that they have the same layout. Therefore, clarify that atomic integers' alignment is equal to their size.
2 parents 02caf1f + ea50f6e commit 8c9555c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/src/sync/atomic.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,16 @@ macro_rules! atomic_int {
21192119
/// This type has the same in-memory representation as the underlying
21202120
/// integer type, [`
21212121
#[doc = $s_int_type]
2122-
/// `]. For more about the differences between atomic types and
2122+
/// `].
2123+
#[doc = if_not_8_bit! {
2124+
$int_type,
2125+
concat!(
2126+
"However, the alignment of this type is always equal to its ",
2127+
"size, even on targets where [`", $s_int_type, "`] has a ",
2128+
"lesser alignment."
2129+
)
2130+
}]
2131+
/// For more about the differences between atomic types and
21232132
/// non-atomic types as well as information about the portability of
21242133
/// this type, please see the [module-level documentation].
21252134
///

0 commit comments

Comments
 (0)