about summary refs log tree commit diff
path: root/src/libstd/task
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-16 09:54:59 -0700
committerbors <bors@rust-lang.org>2013-06-16 09:54:59 -0700
commitae23beb52f637b8c8640706ee8c6d2d4a5796bc8 (patch)
tree86c72c3bb92054b0ba9aff59cbe9c0391eb88c99 /src/libstd/task
parent900de0ffaded223c0ed75188226e499e332416be (diff)
parentbada191309d43d481d265bb1ff9c3a14e827babf (diff)
downloadrust-ae23beb52f637b8c8640706ee8c6d2d4a5796bc8.tar.gz
rust-ae23beb52f637b8c8640706ee8c6d2d4a5796bc8.zip
auto merge of #7167 : nikomatsakis/rust/ref-bindings-explicit-copy-in-generics, r=brson
Two changes:

1. Make type parameters move by default, even if they have a Copy bound. After all, they could be bound to `~T` or `~[]`. Also, this is a necessary step towards removing `copy` keyword and replacing with clone.

2. Make it illegal to move from `*T`. This is dangerous in a "moves-by-default" scenario, because it's very easy to move when working with a `*T` pointer. Also, it requires zeroing memory, which we hope to do away with someday.
Diffstat (limited to 'src/libstd/task')
-rw-r--r--src/libstd/task/spawn.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 30ad4ee2a89..fa1790d79cb 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -98,10 +98,6 @@ use iterator::{IteratorUtil};
 #[cfg(test)] use comm;
 #[cfg(test)] use task;
 
-macro_rules! move_it (
-    { $x:expr } => ( unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } )
-)
-
 type TaskSet = HashSet<*rust_task>;
 
 fn new_taskset() -> TaskSet {
@@ -638,23 +634,16 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
                           notify_chan: Option<Chan<TaskResult>>,
                           f: ~fn())
                        -> ~fn() {
-        let child_data = Cell::new((child_arc, ancestors));
+        let child_data = Cell::new((notify_chan, child_arc, ancestors));
         let result: ~fn() = || {
             // Agh. Get move-mode items into the closure. FIXME (#2829)
-            let mut (child_arc, ancestors) = child_data.take();
+            let mut (notify_chan, child_arc, ancestors) = child_data.take();
             // Child task runs this code.
 
             // Even if the below code fails to kick the child off, we must
             // send Something on the notify channel.
 
-            //let mut notifier = None;//notify_chan.map(|c| AutoNotify(c));
-            let notifier = match notify_chan {
-                Some(ref notify_chan_value) => {
-                    let moved_ncv = move_it!(*notify_chan_value);
-                    Some(AutoNotify(moved_ncv))
-                }
-                _ => None
-            };
+            let notifier = notify_chan.map_consume(|c| AutoNotify(c));
 
             if enlist_many(child, &child_arc, &mut ancestors) {
                 let group = @@mut TCB(child,