summaryrefslogtreecommitdiffstats
path: root/tests/ui/generator/not-send-sync.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/generator/not-send-sync.rs')
-rw-r--r--tests/ui/generator/not-send-sync.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/generator/not-send-sync.rs b/tests/ui/generator/not-send-sync.rs
new file mode 100644
index 000000000..8ca5565fb
--- /dev/null
+++ b/tests/ui/generator/not-send-sync.rs
@@ -0,0 +1,21 @@
+#![feature(generators)]
+
+use std::cell::Cell;
+
+fn main() {
+ fn assert_sync<T: Sync>(_: T) {}
+ fn assert_send<T: Send>(_: T) {}
+
+ assert_sync(|| {
+ //~^ ERROR: generator cannot be shared between threads safely
+ let a = Cell::new(2);
+ yield;
+ });
+
+ let a = Cell::new(2);
+ assert_send(|| {
+ //~^ ERROR: E0277
+ drop(&a);
+ yield;
+ });
+}