summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-06-15 20:15:52 -0400
committerNiko Matsakis <niko@alum.mit.edu>2013-06-16 12:47:36 -0400
commite7b0b71197bb246c3213914919bdb959f39a8f74 (patch)
treeeec16ae22197e1b165db106b7b4d6fbb4757cdfd /src/libstd
parenteb48c296817be7529a1757ac8d4798112717eaa9 (diff)
downloadrust-e7b0b71197bb246c3213914919bdb959f39a8f74.tar.gz
rust-e7b0b71197bb246c3213914919bdb959f39a8f74.zip
Remove moves from *T and implement in another way
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/pipes.rs13
-rw-r--r--src/libstd/task/spawn.rs17
2 files changed, 9 insertions, 21 deletions
diff --git a/src/libstd/pipes.rs b/src/libstd/pipes.rs
index 012ad0ed80d..3448401e0b1 100644
--- a/src/libstd/pipes.rs
+++ b/src/libstd/pipes.rs
@@ -85,7 +85,8 @@ bounded and unbounded protocols allows for less code duplication.
 #[allow(missing_doc)];
 
 use container::Container;
-use cast::{forget, transmute, transmute_copy};
+use cast::{forget, transmute, transmute_copy, transmute_mut};
+use cast;
 use either::{Either, Left, Right};
 use iterator::IteratorUtil;
 use kinds::Owned;
@@ -102,10 +103,6 @@ use util::replace;
 
 static SPIN_COUNT: uint = 0;
 
-macro_rules! move_it (
-    { $x:expr } => ( unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } )
-)
-
 #[deriving(Eq)]
 enum State {
     Empty,
@@ -316,9 +313,11 @@ impl<T> Drop for BufferResource<T> {
     fn finalize(&self) {
         unsafe {
             // FIXME(#4330) Need self by value to get mutability.
-            let this: &mut BufferResource<T> = transmute(self);
+            let this: &mut BufferResource<T> = transmute_mut(self);
+
+            let null_buffer: ~Buffer<T> = transmute(ptr::null::<Buffer<T>>());
+            let mut b = replace(&mut this.buffer, null_buffer);
 
-            let mut b = move_it!(this.buffer);
             //let p = ptr::to_unsafe_ptr(*b);
             //error!("drop %?", p);
             let old_count = intrinsics::atomic_xsub_rel(
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,