about summary refs log tree commit diff
path: root/tests/ui/traits/struct-negative-sync-impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/struct-negative-sync-impl.rs')
-rw-r--r--tests/ui/traits/struct-negative-sync-impl.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/traits/struct-negative-sync-impl.rs b/tests/ui/traits/struct-negative-sync-impl.rs
new file mode 100644
index 00000000000..d32846276f6
--- /dev/null
+++ b/tests/ui/traits/struct-negative-sync-impl.rs
@@ -0,0 +1,21 @@
+//! Test negative Sync implementation on structs.
+//!
+//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync.
+
+#![feature(negative_impls)]
+
+use std::marker::Sync;
+
+struct NotSync {
+    value: isize,
+}
+
+impl !Sync for NotSync {}
+
+fn requires_sync<T: Sync>(_: T) {}
+
+fn main() {
+    let not_sync = NotSync { value: 5 };
+    requires_sync(not_sync);
+    //~^ ERROR `NotSync` cannot be shared between threads safely [E0277]
+}