summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-03 16:44:16 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-10 15:13:12 -0800
commit786dea207d5b891d37e596e96dd2f84c4cb59f49 (patch)
treef275936b26e6602b11363446fcac5ad3b09dbe92 /src/test
parent5aad292fb99f7e9a2730b35ed535bda0ab9c6117 (diff)
downloadrust-786dea207d5b891d37e596e96dd2f84c4cb59f49.tar.gz
rust-786dea207d5b891d37e596e96dd2f84c4cb59f49.zip
libextra: Another round of de-`Cell`-ing.
34 uses of `Cell` remain.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/msgsend-ring-mutex-arcs.rs7
-rw-r--r--src/test/bench/msgsend-ring-rw-arcs.rs7
-rw-r--r--src/test/bench/rt-messaging-ping-pong.rs22
-rw-r--r--src/test/bench/rt-parfib.rs4
-rw-r--r--src/test/bench/shootout-chameneos-redux.rs9
-rw-r--r--src/test/bench/task-perf-jargon-metal-smoke.rs3
-rw-r--r--src/test/compile-fail/no-send-res-ports.rs5
-rw-r--r--src/test/compile-fail/no_freeze-rc.rs6
-rw-r--r--src/test/run-pass/issue-2718.rs2
-rw-r--r--src/test/run-pass/sendfn-spawn-with-fn-arg.rs4
-rw-r--r--src/test/run-pass/task-killjoin-rsrc.rs4
-rw-r--r--src/test/run-pass/tempfile.rs8
-rw-r--r--src/test/run-pass/trait-bounds-in-arc.rs14
13 files changed, 33 insertions, 62 deletions
diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs
index facd8a3bd74..6eacbd12a70 100644
--- a/src/test/bench/msgsend-ring-mutex-arcs.rs
+++ b/src/test/bench/msgsend-ring-mutex-arcs.rs
@@ -20,7 +20,6 @@ extern mod extra;
 use extra::arc;
 use extra::future::Future;
 use extra::time;
-use std::cell::Cell;
 use std::os;
 use std::uint;
 
@@ -91,12 +90,8 @@ fn main() {
     for i in range(1u, num_tasks) {
         //error!("spawning %?", i);
         let (new_chan, num_port) = init();
-        let num_chan2 = Cell::new(num_chan);
-        let num_port = Cell::new(num_port);
         let new_future = do Future::spawn() {
-            let num_chan = num_chan2.take();
-            let num_port1 = num_port.take();
-            thread_ring(i, msg_per_task, num_chan, num_port1)
+            thread_ring(i, msg_per_task, num_chan, num_port)
         };
         futures.push(new_future);
         num_chan = new_chan;
diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs
index 2ce3a373f8b..b713652e31d 100644
--- a/src/test/bench/msgsend-ring-rw-arcs.rs
+++ b/src/test/bench/msgsend-ring-rw-arcs.rs
@@ -20,7 +20,6 @@ extern mod extra;
 use extra::arc;
 use extra::future::Future;
 use extra::time;
-use std::cell::Cell;
 use std::os;
 use std::uint;
 
@@ -87,12 +86,8 @@ fn main() {
     for i in range(1u, num_tasks) {
         //error!("spawning %?", i);
         let (new_chan, num_port) = init();
-        let num_chan2 = Cell::new(num_chan);
-        let num_port = Cell::new(num_port);
         let new_future = do Future::spawn {
-            let num_chan = num_chan2.take();
-            let num_port1 = num_port.take();
-            thread_ring(i, msg_per_task, num_chan, num_port1)
+            thread_ring(i, msg_per_task, num_chan, num_port)
         };
         futures.push(new_future);
         num_chan = new_chan;
diff --git a/src/test/bench/rt-messaging-ping-pong.rs b/src/test/bench/rt-messaging-ping-pong.rs
index 715043d5be6..8fa26b42e85 100644
--- a/src/test/bench/rt-messaging-ping-pong.rs
+++ b/src/test/bench/rt-messaging-ping-pong.rs
@@ -13,7 +13,6 @@ extern mod extra;
 use std::os;
 use std::uint;
 use std::rt::test::spawntask_later;
-use std::cell::Cell;
 
 // This is a simple bench that creates M pairs of of tasks. These
 // tasks ping-pong back and forth over a pair of streams. This is a
@@ -24,19 +23,14 @@ fn ping_pong_bench(n: uint, m: uint) {
 
     // Create pairs of tasks that pingpong back and forth.
     fn run_pair(n: uint) {
-            // Create a stream A->B
-            let (pa,ca) = stream::<()>();
-            // Create a stream B->A
-            let (pb,cb) = stream::<()>();
-
-            let pa = Cell::new(pa);
-            let ca = Cell::new(ca);
-            let pb = Cell::new(pb);
-            let cb = Cell::new(cb);
+        // Create a stream A->B
+        let (pa,ca) = stream::<()>();
+        // Create a stream B->A
+        let (pb,cb) = stream::<()>();
 
         do spawntask_later() || {
-            let chan = ca.take();
-            let port = pb.take();
+            let chan = ca;
+            let port = pb;
             n.times(|| {
                 chan.send(());
                 port.recv();
@@ -44,8 +38,8 @@ fn ping_pong_bench(n: uint, m: uint) {
         }
 
         do spawntask_later() || {
-            let chan = cb.take();
-            let port = pa.take();
+            let chan = cb;
+            let port = pa;
             n.times(|| {
                 port.recv();
                 chan.send(());
diff --git a/src/test/bench/rt-parfib.rs b/src/test/bench/rt-parfib.rs
index 1f2f163b8f0..e6519a78856 100644
--- a/src/test/bench/rt-parfib.rs
+++ b/src/test/bench/rt-parfib.rs
@@ -13,7 +13,6 @@ extern mod extra;
 use std::os;
 use std::uint;
 use std::rt::test::spawntask_later;
-use std::cell::Cell;
 use std::comm::oneshot;
 
 // A simple implementation of parfib. One subtree is found in a new
@@ -26,9 +25,8 @@ fn parfib(n: uint) -> uint {
     }
 
     let (port,chan) = oneshot::<uint>();
-    let chan = Cell::new(chan);
     do spawntask_later {
-        chan.take().send(parfib(n-1));
+        chan.send(parfib(n-1));
     };
     let m2 = parfib(n-2);
     return (port.recv() + m2);
diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs
index a489d17e92a..464bc664fb5 100644
--- a/src/test/bench/shootout-chameneos-redux.rs
+++ b/src/test/bench/shootout-chameneos-redux.rs
@@ -12,7 +12,6 @@
 
 extern mod extra;
 
-use std::cell::Cell;
 use std::comm::{stream, SharedChan};
 use std::option;
 use std::os;
@@ -156,9 +155,11 @@ fn rendezvous(nn: uint, set: ~[color]) {
             let to_rendezvous = to_rendezvous.clone();
             let to_rendezvous_log = to_rendezvous_log.clone();
             let (from_rendezvous, to_creature) = stream();
-            let from_rendezvous = Cell::new(from_rendezvous);
-            do task::spawn || {
-                creature(ii, col, from_rendezvous.take(), to_rendezvous.clone(),
+            do task::spawn {
+                creature(ii,
+                         col,
+                         from_rendezvous,
+                         to_rendezvous.clone(),
                          to_rendezvous_log.clone());
             }
             to_creature
diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs
index 889885c3388..8e7b48040cd 100644
--- a/src/test/bench/task-perf-jargon-metal-smoke.rs
+++ b/src/test/bench/task-perf-jargon-metal-smoke.rs
@@ -17,7 +17,6 @@
 //
 // The filename is a song reference; google it in quotes.
 
-use std::cell::Cell;
 use std::comm;
 use std::os;
 use std::task;
@@ -27,9 +26,7 @@ fn child_generation(gens_left: uint, c: comm::Chan<()>) {
     // This used to be O(n^2) in the number of generations that ever existed.
     // With this code, only as many generations are alive at a time as tasks
     // alive at a time,
-    let c = Cell::new(c);
     do spawn {
-        let c = c.take();
         if gens_left & 1 == 1 {
             task::deschedule(); // shake things up a bit
         }
diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs
index ce0e55f09f6..87173d77924 100644
--- a/src/test/compile-fail/no-send-res-ports.rs
+++ b/src/test/compile-fail/no-send-res-ports.rs
@@ -10,7 +10,6 @@
 
 #[feature(managed_boxes)];
 
-use std::cell::Cell;
 use std::task;
 
 struct Port<T>(@T);
@@ -31,10 +30,10 @@ fn main() {
         }
     }
 
-    let x = Cell::new(foo(Port(@())));
+    let x = foo(Port(@()));
 
     do task::spawn {
-        let y = x.take();   //~ ERROR does not fulfill `Send`
+        let y = x;   //~ ERROR does not fulfill `Send`
         error!("{:?}", y);
     }
 }
diff --git a/src/test/compile-fail/no_freeze-rc.rs b/src/test/compile-fail/no_freeze-rc.rs
index 6185ccf2e7e..dbf5d0fb3f9 100644
--- a/src/test/compile-fail/no_freeze-rc.rs
+++ b/src/test/compile-fail/no_freeze-rc.rs
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 use std::rc::Rc;
-use std::cell::Cell;
+use std::cell::RefCell;
 
 fn bar<T: Freeze>(_: T) {}
 
 fn main() {
-    let x = Rc::from_send(Cell::new(5));
-    bar(x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::cell::Cell<int>>`, which does not fulfill `Freeze`
+    let x = Rc::from_send(RefCell::new(5));
+    bar(x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Freeze`
 }
diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs
index 3bedbfa27b7..2c18361fd46 100644
--- a/src/test/run-pass/issue-2718.rs
+++ b/src/test/run-pass/issue-2718.rs
@@ -313,8 +313,6 @@ pub fn main() {
 //    Commented out because of option::get error
 
     let (client_, server_) = pingpong::init();
-    let client_ = Cell::new(client_);
-    let server_ = Cell::new(server_);
 
     task::spawn {|client_|
         let client__ = client_.take();
diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs
index 963f62a20a0..a39907d5c7e 100644
--- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs
+++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::cell::Cell;
 use std::task;
 
 pub fn main() { test05(); }
@@ -23,8 +22,7 @@ fn test05() {
         error!("{}", *three + n); // will copy x into the closure
         assert_eq!(*three, 3);
     };
-    let fn_to_send = Cell::new(fn_to_send);
     task::spawn(proc() {
-        test05_start(fn_to_send.take());
+        test05_start(fn_to_send);
     });
 }
diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs
index 94e402bfa90..a490cc6020f 100644
--- a/src/test/run-pass/task-killjoin-rsrc.rs
+++ b/src/test/run-pass/task-killjoin-rsrc.rs
@@ -13,7 +13,6 @@
 // A port of task-killjoin to use a class with a dtor to manage
 // the join.
 
-use std::cell::Cell;
 use std::comm::*;
 use std::ptr;
 use std::task;
@@ -55,9 +54,8 @@ fn joinable(f: proc()) -> Port<bool> {
         *b = true;
     }
     let (p, c) = stream();
-    let c = Cell::new(c);
     do task::spawn_unlinked {
-        let ccc = c.take();
+        let ccc = c;
         wrapper(ccc, f)
     }
     p
diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs
index dd5aa4bc8c6..663eafe1700 100644
--- a/src/test/run-pass/tempfile.rs
+++ b/src/test/run-pass/tempfile.rs
@@ -22,11 +22,10 @@
 extern mod extra;
 
 use extra::tempfile::TempDir;
+use std::io::fs;
+use std::io;
 use std::os;
 use std::task;
-use std::cell::Cell;
-use std::io;
-use std::io::fs;
 
 fn test_tempdir() {
     let path = {
@@ -51,9 +50,8 @@ fn test_rm_tempdir() {
 
     let tmp = TempDir::new("test_rm_tempdir").unwrap();
     let path = tmp.path().clone();
-    let cell = Cell::new(tmp);
     let f: proc() = proc() {
-        let _tmp = cell.take();
+        let _tmp = tmp;
         fail!("fail to unwind past `tmp`");
     };
     task::try(f);
diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs
index 1b7c3a1f52e..abd9ea1733f 100644
--- a/src/test/run-pass/trait-bounds-in-arc.rs
+++ b/src/test/run-pass/trait-bounds-in-arc.rs
@@ -16,10 +16,10 @@
 // xfail-fast
 
 extern mod extra;
+
 use extra::arc;
 use std::comm;
 use std::task;
-use std::cell;
 
 trait Pet {
     fn name(&self, blk: |&str|);
@@ -71,14 +71,14 @@ fn main() {
                          ~fishe  as ~Pet:Freeze+Send,
                          ~dogge2 as ~Pet:Freeze+Send]);
     let (p1,c1) = comm::stream();
-    let arc1 = cell::Cell::new(arc.clone());
-    do task::spawn { check_legs(arc1.take()); c1.send(()); }
+    let arc1 = arc.clone();
+    do task::spawn { check_legs(arc1); c1.send(()); }
     let (p2,c2) = comm::stream();
-    let arc2 = cell::Cell::new(arc.clone());
-    do task::spawn { check_names(arc2.take()); c2.send(()); }
+    let arc2 = arc.clone();
+    do task::spawn { check_names(arc2); c2.send(()); }
     let (p3,c3) = comm::stream();
-    let arc3 = cell::Cell::new(arc.clone());
-    do task::spawn { check_pedigree(arc3.take()); c3.send(()); }
+    let arc3 = arc.clone();
+    do task::spawn { check_pedigree(arc3); c3.send(()); }
     p1.recv();
     p2.recv();
     p3.recv();