summary refs log tree commit diff
path: root/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/moved-value-in-thread-loop-12041.rs')
-rw-r--r--tests/ui/borrowck/moved-value-in-thread-loop-12041.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs
new file mode 100644
index 00000000000..98f9cdbdef7
--- /dev/null
+++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs
@@ -0,0 +1,15 @@
+//! Regression test for https://github.com/rust-lang/rust/issues/12041
+
+use std::sync::mpsc::channel;
+use std::thread;
+
+fn main() {
+    let (tx, rx) = channel();
+    let _t = thread::spawn(move|| -> () {
+        loop {
+            let tx = tx;
+            //~^ ERROR: use of moved value: `tx`
+            tx.send(1);
+        }
+    });
+}