Skip to content

Commit 5e50acf

Browse files
committed
Make the Atomic types repr(C) to ensure newtype
1 parent 01674fb commit 5e50acf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libcore/sync/atomic.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn spin_loop_hint() {
124124
/// [`bool`]: ../../../std/primitive.bool.html
125125
#[cfg(target_has_atomic = "8")]
126126
#[stable(feature = "rust1", since = "1.0.0")]
127-
#[repr(align(1))]
127+
#[repr(C, align(1))]
128128
pub struct AtomicBool {
129129
v: UnsafeCell<u8>,
130130
}
@@ -148,9 +148,9 @@ unsafe impl Sync for AtomicBool {}
148148
/// This type has the same in-memory representation as a `*mut T`.
149149
#[cfg(target_has_atomic = "ptr")]
150150
#[stable(feature = "rust1", since = "1.0.0")]
151-
#[cfg_attr(target_pointer_width = "16", repr(align(2)))]
152-
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
153-
#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
151+
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
152+
#[cfg_attr(target_pointer_width = "32", repr(C, align(4)))]
153+
#[cfg_attr(target_pointer_width = "64", repr(C, align(8)))]
154154
pub struct AtomicPtr<T> {
155155
p: UnsafeCell<*mut T>,
156156
}
@@ -1106,7 +1106,7 @@ macro_rules! atomic_int {
11061106
///
11071107
/// [module-level documentation]: index.html
11081108
#[$stable]
1109-
#[repr(align($align))]
1109+
#[repr(C, align($align))]
11101110
pub struct $atomic_type {
11111111
v: UnsafeCell<$int_type>,
11121112
}

0 commit comments

Comments
 (0)