diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-07-10 22:56:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-10 22:56:39 +0200 |
| commit | 115447a65dd421728d02478b9132d4a2ac3578c0 (patch) | |
| tree | 2f7758f7ea45462389d28a11c68db22130386178 /src | |
| parent | bfac782b691e61c20168aa473708dd16aa4a5eda (diff) | |
| parent | e769deca998479c7b78931af45a26c6c822c74f7 (diff) | |
Rollup merge of #52149 - willmo:transparent-atomics, r=cramertj
Add #[repr(transparent)] to Atomic* types This allows them to be used in `#[repr(C)]` structs without warnings. Since rust-lang/rfcs#1649 and rust-lang/rust#35603 they are already documented to have "the same in-memory representation as" their corresponding primitive types. This just makes that explicit. This was briefly part of #51395, but was controversial and therefore dropped. But it turns out that it's essentially already documented (which I had forgotten).
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/sync/atomic.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index e9d1fb89115..1e2b18bf9b0 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -124,6 +124,7 @@ pub fn spin_loop_hint() { /// [`bool`]: ../../../std/primitive.bool.html #[cfg(target_has_atomic = "8")] #[stable(feature = "rust1", since = "1.0.0")] +#[repr(transparent)] pub struct AtomicBool { v: UnsafeCell<u8>, } @@ -147,6 +148,7 @@ unsafe impl Sync for AtomicBool {} /// This type has the same in-memory representation as a `*mut T`. #[cfg(target_has_atomic = "ptr")] #[stable(feature = "rust1", since = "1.0.0")] +#[repr(transparent)] pub struct AtomicPtr<T> { p: UnsafeCell<*mut T>, } @@ -976,6 +978,7 @@ macro_rules! atomic_int { /// /// [module-level documentation]: index.html #[$stable] + #[repr(transparent)] pub struct $atomic_type { v: UnsafeCell<$int_type>, } |
