Skip to content

Commit 51354e9

Browse files
committed
Add a compile-time test for the Send- and Sync-ness of Atomic*
1 parent e570e86 commit 51354e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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)