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() {}

src/test/run-pass/intrinsic-atomics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern mod rusti {
2929

3030
pub fn main() {
3131
unsafe {
32-
let x = ~mut 1;
32+
let mut x = ~1;
3333

3434
assert rusti::atomic_cxchg(x, 1, 2) == 1;
3535
assert *x == 2;

src/test/run-pass/issue-2718.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,16 @@ pub fn main() {
318318
// Commented out because of option::get error
319319
320320
let (client_, server_) = pingpong::init();
321-
let client_ = ~mut Some(client_);
322-
let server_ = ~mut Some(server_);
321+
let client_ = Cell(client_);
322+
let server_ = Cell(server_);
323323
324324
task::spawn {|client_|
325-
let mut client__ = none;
326-
*client_ <-> client__;
327-
client(option::unwrap(client__));
325+
let client__ = client_.take();
326+
client(client__);
328327
};
329328
task::spawn {|server_|
330-
let mut server_ˊ = none;
331-
*server_ <-> server_ˊ;
332-
server(option::unwrap(server_ˊ));
329+
let server__ = server_.take();
330+
server(server_ˊ);
333331
};
334332
*/
335333
}

src/test/run-pass/pipe-pingpong-bounded.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// experiment with what code the compiler should generate for bounded
1515
// protocols.
1616

17+
use core::cell::Cell;
1718

1819
// This was generated initially by the pipe compiler, but it's been
1920
// modified in hopefully straightforward ways.
@@ -111,16 +112,14 @@ mod test {
111112

112113
pub fn main() {
113114
let (client_, server_) = ::pingpong::init();
114-
let client_ = ~mut Some(client_);
115-
let server_ = ~mut Some(server_);
116-
do task::spawn || {
117-
let mut client__ = None;
118-
*client_ <-> client__;
119-
test::client(option::unwrap(client__));
115+
let client_ = Cell(client_);
116+
let server_ = Cell(server_);
117+
do task::spawn {
118+
let client__ = client_.take();
119+
test::client(client__);
120120
};
121-
do task::spawn || {
122-
let mut server_ˊ = None;
123-
*server_ <-> server_ˊ;
124-
test::server(option::unwrap(server_ˊ));
121+
do task::spawn {
122+
let server__ = server_.take();
123+
test::server(server_ˊ);
125124
};
126125
}

src/test/run-pass/pipe-pingpong-proto.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// An example to make sure the protocol parsing syntax extension works.
1414

15+
use core::cell::Cell;
1516
use core::option;
1617

1718
proto! pingpong (
@@ -49,17 +50,15 @@ mod test {
4950

5051
pub fn main() {
5152
let (client_, server_) = pingpong::init();
52-
let client_ = ~mut Some(client_);
53-
let server_ = ~mut Some(server_);
53+
let client_ = Cell(client_);
54+
let server_ = Cell(server_);
5455

55-
do task::spawn || {
56-
let mut client__ = None;
57-
*client_ <-> client__;
58-
test::client(option::unwrap(client__));
56+
do task::spawn {
57+
let client__ = client_.take();
58+
test::client(client__);
5959
};
60-
do task::spawn || {
61-
let mut server_ˊ = None;
62-
*server_ <-> server_ˊ;
63-
test::server(option::unwrap(server_ˊ));
60+
do task::spawn {
61+
let server__ = server_.take();
62+
test::server(server_ˊ);
6463
};
6564
}

src/test/run-pass/pure-sum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pure fn sums_to(v: ~[int], sum: int) -> bool {
2020
}
2121

2222
pure fn sums_to_using_uniq(v: ~[int], sum: int) -> bool {
23-
let mut i = 0u, sum0 = ~mut 0;
23+
let mut i = 0u, sum0 = ~0;
2424
while i < v.len() {
2525
*sum0 += v[i];
2626
i += 1u;
@@ -40,7 +40,7 @@ pure fn sums_to_using_rec(v: ~[int], sum: int) -> bool {
4040
struct F<T> { f: T }
4141

4242
pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool {
43-
let mut i = 0u, sum0 = F {f: ~mut 0};
43+
let mut i = 0u, sum0 = F {f: ~0};
4444
while i < v.len() {
4545
*sum0.f += v[i];
4646
i += 1u;

src/test/run-pass/rcvr-borrowed-to-region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn main() {
3131
debug!("y=%d", y);
3232
assert y == 6;
3333

34-
let x = ~mut 6;
34+
let mut x = ~6;
3535
let y = x.get();
3636
debug!("y=%d", y);
3737
assert y == 6;

src/test/run-pass/task-killjoin-rsrc.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// A port of task-killjoin to use a class with a dtor to manage
1414
// the join.
1515

16+
use core::cell::Cell;
1617
use core::comm::*;
1718

1819
struct notify {
@@ -49,11 +50,9 @@ fn joinable(f: fn~()) -> Port<bool> {
4950
*b = true;
5051
}
5152
let (p, c) = stream();
52-
let c = ~mut Some(c);
53+
let c = Cell(c);
5354
do task::spawn_unlinked {
54-
let mut cc = None;
55-
*c <-> cc;
56-
let ccc = option::unwrap(cc);
55+
let ccc = c.take();
5756
wrapper(ccc, f)
5857
}
5958
p

src/test/run-pass/unique-assign-copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
pub fn main() {
12-
let i = ~mut 1;
12+
let mut i = ~1;
1313
// Should be a copy
1414
let mut j;
1515
j = copy i;

src/test/run-pass/unique-decl-init-copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
pub fn main() {
12-
let i = ~mut 1;
12+
let mut i = ~1;
1313
// Should be a copy
1414
let j = copy i;
1515
*i = 2;

src/test/run-pass/unique-in-vec-copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
pub fn main() {
12-
let a = ~[~mut 10];
12+
let mut a = ~[~10];
1313
let b = copy a;
1414

1515
assert *a[0] == 10;

src/test/run-pass/unique-mutable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
pub fn main() {
12-
let i = ~mut 0;
12+
let mut i = ~0;
1313
*i = 1;
1414
assert *i == 1;
1515
}

0 commit comments

Comments
 (0)