Skip to content

Commit 81fc328

Browse files
committed
Rollup merge of #28314 - tbu-:pr_atomics_are_send, r=brson
2 parents c9fefb8 + 51354e9 commit 81fc328

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/libcore/sync/atomic.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl Default for AtomicBool {
9292
}
9393
}
9494

95+
// Send is implicitly implemented for AtomicBool.
9596
unsafe impl Sync for AtomicBool {}
9697

9798
/// A signed integer type which can be safely shared between threads.
@@ -106,6 +107,7 @@ impl Default for AtomicIsize {
106107
}
107108
}
108109

110+
// Send is implicitly implemented for AtomicIsize.
109111
unsafe impl Sync for AtomicIsize {}
110112

111113
/// An unsigned integer type which can be safely shared between threads.
@@ -120,6 +122,7 @@ impl Default for AtomicUsize {
120122
}
121123
}
122124

125+
// Send is implicitly implemented for AtomicUsize.
123126
unsafe impl Sync for AtomicUsize {}
124127

125128
/// A raw pointer type which can be safely shared between threads.

src/libcoretest/atomic.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use core::sync::atomic::*;
1212
use core::sync::atomic::Ordering::SeqCst;
13+
use core::marker::{Send, Sync};
1314

1415
#[test]
1516
fn bool_() {
@@ -82,3 +83,13 @@ fn static_init() {
8283
assert!(S_INT.load(SeqCst) == 0);
8384
assert!(S_UINT.load(SeqCst) == 0);
8485
}
86+
87+
#[test]
88+
fn static_sync_and_send() {
89+
fn ensure_sync_and_send<T:Sync+Send>() { }
90+
91+
ensure_sync_and_send::<AtomicBool>();
92+
ensure_sync_and_send::<AtomicUsize>();
93+
ensure_sync_and_send::<AtomicIsize>();
94+
ensure_sync_and_send::<AtomicPtr>();
95+
}

0 commit comments

Comments
 (0)