Skip to content

Commit f63efdc

Browse files
committed
test: De-~mut the test suite. rs=demuting
1 parent a08eda4 commit f63efdc

21 files changed

+67
-121
lines changed

src/test/bench/msgsend-ring-mutex-arcs.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,12 @@ fn main() {
8787
for uint::range(1u, num_tasks) |i| {
8888
//error!("spawning %?", i);
8989
let (new_chan, num_port) = init();
90-
let num_chan2 = ~mut None;
91-
*num_chan2 <-> num_chan;
92-
let num_port = ~mut Some(num_port);
93-
let new_future = do future::spawn() || {
94-
let mut num_chan = None;
95-
num_chan <-> *num_chan2;
96-
let mut num_port1 = None;
97-
num_port1 <-> *num_port;
98-
thread_ring(i, msg_per_task,
99-
option::unwrap(num_chan),
100-
option::unwrap(num_port1))
90+
let num_chan2 = Cell(num_chan);
91+
let num_port = Cell(num_port);
92+
let new_future = do future::spawn() {
93+
let num_chan = num_chan2.take();
94+
let num_port1 = num_port.take();
95+
thread_ring(i, msg_per_task, num_chan, num_port1)
10196
};
10297
futures.push(new_future);
10398
num_chan = Some(new_chan);

src/test/bench/msgsend-ring-pipes.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
// This version uses automatically compiled channel contracts.
1818

1919
extern mod std;
20-
use std::time;
21-
use std::future;
2220

21+
use core::cell::Cell;
2322
use core::pipes::recv;
23+
use std::time;
24+
use std::future;
2425

2526
proto! ring (
2627
num:send {
@@ -80,17 +81,12 @@ fn main() {
8081
for uint::range(1u, num_tasks) |i| {
8182
//error!("spawning %?", i);
8283
let (new_chan, num_port) = ring::init();
83-
let num_chan2 = ~mut None;
84-
*num_chan2 <-> num_chan;
85-
let num_port = ~mut Some(num_port);
84+
let num_chan2 = Cell(num_chan);
85+
let num_port = Cell(num_port);
8686
let new_future = do future::spawn || {
87-
let mut num_chan = None;
88-
num_chan <-> *num_chan2;
89-
let mut num_port1 = None;
90-
num_port1 <-> *num_port;
91-
thread_ring(i, msg_per_task,
92-
option::unwrap(num_chan),
93-
option::unwrap(num_port1))
87+
let num_chan = num_chan2.take();
88+
let num_port1 = num_port.take();
89+
thread_ring(i, msg_per_task, num_chan, num_port1)
9490
};
9591
futures.push(new_future);
9692
num_chan = Some(new_chan);

src/test/bench/msgsend-ring-rw-arcs.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,12 @@ fn main() {
8787
for uint::range(1u, num_tasks) |i| {
8888
//error!("spawning %?", i);
8989
let (new_chan, num_port) = init();
90-
let num_chan2 = ~mut None;
91-
*num_chan2 <-> num_chan;
92-
let num_port = ~mut Some(num_port);
93-
let new_future = do future::spawn || {
94-
let mut num_chan = None;
95-
num_chan <-> *num_chan2;
96-
let mut num_port1 = None;
97-
num_port1 <-> *num_port;
98-
thread_ring(i, msg_per_task,
99-
option::unwrap(num_chan),
100-
option::unwrap(num_port1))
90+
let num_chan2 = Cell(num_chan);
91+
let num_port = Cell(num_port);
92+
let new_future = do future::spawn {
93+
let num_chan = num_chan2.take();
94+
let num_port1 = num_port.take();
95+
thread_ring(i, msg_per_task, num_chan, num_port1)
10196
};
10297
futures.push(new_future);
10398
num_chan = Some(new_chan);

src/test/bench/task-perf-jargon-metal-smoke.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
//
1818
// The filename is a song reference; google it in quotes.
1919

20+
use core::cell::Cell;
21+
2022
fn child_generation(gens_left: uint, -c: comm::Chan<()>) {
2123
// This used to be O(n^2) in the number of generations that ever existed.
2224
// With this code, only as many generations are alive at a time as tasks
2325
// alive at a time,
24-
let c = ~mut Some(c);
25-
do task::spawn_supervised || {
26-
let c = option::swap_unwrap(c);
26+
let c = Cell(c);
27+
do task::spawn_supervised {
28+
let c = c.take();
2729
if gens_left & 1 == 1 {
2830
task::yield(); // shake things up a bit
2931
}

src/test/compile-fail/mutable-huh-variance-deep.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// error-pattern: mismatched types
1212

1313
fn main() {
14-
let v = ~[mut @mut ~mut ~[0]];
14+
let v = @[mut @mut @mut @[0]];
1515

16-
fn f(&&v: ~[mut @mut ~mut ~[const int]]) {
16+
fn f(&&v: @[mut @mut @mut @[const int]]) {
1717
}
1818

1919
f(v);

src/test/compile-fail/mutable-huh-variance-unique.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/test/compile-fail/no-send-res-ports.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::cell::Cell;
12+
1113
struct Port<T>(@T);
1214

1315
fn main() {
@@ -25,11 +27,10 @@ fn main() {
2527
}
2628
}
2729

28-
let x = ~mut Some(foo(Port(@())));
30+
let x = Cell(foo(Port(@())));
2931

3032
do task::spawn {
31-
let mut y = None;
32-
*x <-> y; //~ ERROR value has non-owned type
33+
let y = x.take(); //~ ERROR value has non-owned type
3334
log(error, y);
3435
}
3536
}

src/test/compile-fail/unique-mut.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/test/run-pass/borrowck-preserve-box-in-uniq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn borrow(x: &int, f: fn(x: &int)) {
2020
struct F { f: ~int }
2121

2222
pub fn main() {
23-
let mut x = ~mut @F{f: ~3};
23+
let mut x = ~@F{f: ~3};
2424
do borrow(x.f) |b_x| {
2525
assert *b_x == 3;
2626
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));

src/test/run-pass/explicit-self-closures.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ impl Box {
2121
fn set_many2(@mut self, xs: &[uint]) {
2222
for xs.each |x| { self.x = *x; }
2323
}
24-
fn set_many3(~mut self, xs: &[uint]) {
25-
for xs.each |x| { self.x = *x; }
26-
}
2724
}
2825

2926
pub fn main() {}

0 commit comments

Comments
 (0)