diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-02-25 14:04:32 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-02-25 15:15:42 -0800 |
| commit | f63efdc2100ff28e2a42600641835e7bd8bde591 (patch) | |
| tree | 6778c6e2d96aae292679b6eee58df79ac154a46a | |
| parent | a08eda4b6318af0df153322d10d9b907b13d0cdc (diff) | |
| download | rust-f63efdc2100ff28e2a42600641835e7bd8bde591.tar.gz rust-f63efdc2100ff28e2a42600641835e7bd8bde591.zip | |
test: De-~mut the test suite. rs=demuting
21 files changed, 67 insertions, 121 deletions
diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 9b6fee5e23b..22045007134 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -87,17 +87,12 @@ fn main() { for uint::range(1u, num_tasks) |i| { //error!("spawning %?", i); let (new_chan, num_port) = init(); - let num_chan2 = ~mut None; - *num_chan2 <-> num_chan; - let num_port = ~mut Some(num_port); - let new_future = do future::spawn() || { - let mut num_chan = None; - num_chan <-> *num_chan2; - let mut num_port1 = None; - num_port1 <-> *num_port; - thread_ring(i, msg_per_task, - option::unwrap(num_chan), - option::unwrap(num_port1)) + let num_chan2 = Cell(num_chan); + let num_port = Cell(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) }; futures.push(new_future); num_chan = Some(new_chan); diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index 0f7c41f5997..dfe5c6de832 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -17,10 +17,11 @@ // This version uses automatically compiled channel contracts. extern mod std; -use std::time; -use std::future; +use core::cell::Cell; use core::pipes::recv; +use std::time; +use std::future; proto! ring ( num:send { @@ -80,17 +81,12 @@ fn main() { for uint::range(1u, num_tasks) |i| { //error!("spawning %?", i); let (new_chan, num_port) = ring::init(); - let num_chan2 = ~mut None; - *num_chan2 <-> num_chan; - let num_port = ~mut Some(num_port); + let num_chan2 = Cell(num_chan); + let num_port = Cell(num_port); let new_future = do future::spawn || { - let mut num_chan = None; - num_chan <-> *num_chan2; - let mut num_port1 = None; - num_port1 <-> *num_port; - thread_ring(i, msg_per_task, - option::unwrap(num_chan), - option::unwrap(num_port1)) + let num_chan = num_chan2.take(); + let num_port1 = num_port.take(); + thread_ring(i, msg_per_task, num_chan, num_port1) }; futures.push(new_future); num_chan = Some(new_chan); diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index eaae8370d6b..98c0129918a 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -87,17 +87,12 @@ fn main() { for uint::range(1u, num_tasks) |i| { //error!("spawning %?", i); let (new_chan, num_port) = init(); - let num_chan2 = ~mut None; - *num_chan2 <-> num_chan; - let num_port = ~mut Some(num_port); - let new_future = do future::spawn || { - let mut num_chan = None; - num_chan <-> *num_chan2; - let mut num_port1 = None; - num_port1 <-> *num_port; - thread_ring(i, msg_per_task, - option::unwrap(num_chan), - option::unwrap(num_port1)) + let num_chan2 = Cell(num_chan); + let num_port = Cell(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) }; futures.push(new_future); num_chan = Some(new_chan); diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 49a06fd491c..9bdc5aae3f2 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -17,13 +17,15 @@ // // The filename is a song reference; google it in quotes. +use core::cell::Cell; + 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 = ~mut Some(c); - do task::spawn_supervised || { - let c = option::swap_unwrap(c); + let c = Cell(c); + do task::spawn_supervised { + let c = c.take(); if gens_left & 1 == 1 { task::yield(); // shake things up a bit } diff --git a/src/test/compile-fail/mutable-huh-variance-deep.rs b/src/test/compile-fail/mutable-huh-variance-deep.rs index 4f0c6d7a4c8..51d5a6177f6 100644 --- a/src/test/compile-fail/mutable-huh-variance-deep.rs +++ b/src/test/compile-fail/mutable-huh-variance-deep.rs @@ -11,9 +11,9 @@ // error-pattern: mismatched types fn main() { - let v = ~[mut @mut ~mut ~[0]]; + let v = @[mut @mut @mut @[0]]; - fn f(&&v: ~[mut @mut ~mut ~[const int]]) { + fn f(&&v: @[mut @mut @mut @[const int]]) { } f(v); diff --git a/src/test/compile-fail/mutable-huh-variance-unique.rs b/src/test/compile-fail/mutable-huh-variance-unique.rs deleted file mode 100644 index f2188911346..00000000000 --- a/src/test/compile-fail/mutable-huh-variance-unique.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -fn main() { - let v = ~mut ~[0]; - - fn f(&&v: ~mut ~[const int]) { - *v = ~[mut 3] - } - - f(v); -} diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index 4954bbfa09d..0d7e2d2377c 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::cell::Cell; + struct Port<T>(@T); fn main() { @@ -25,11 +27,10 @@ fn main() { } } - let x = ~mut Some(foo(Port(@()))); + let x = Cell(foo(Port(@()))); do task::spawn { - let mut y = None; - *x <-> y; //~ ERROR value has non-owned type + let y = x.take(); //~ ERROR value has non-owned type log(error, y); } } diff --git a/src/test/compile-fail/unique-mut.rs b/src/test/compile-fail/unique-mut.rs deleted file mode 100644 index a3a197505a3..00000000000 --- a/src/test/compile-fail/unique-mut.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//error-pattern:mismatched types -fn main() { - let i: ~int = ~mut 0; -} diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 9724717f2d5..b11a5356f69 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -20,7 +20,7 @@ fn borrow(x: &int, f: fn(x: &int)) { struct F { f: ~int } pub fn main() { - let mut x = ~mut @F{f: ~3}; + let mut x = ~@F{f: ~3}; do borrow(x.f) |b_x| { assert *b_x == 3; assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)); diff --git a/src/test/run-pass/explicit-self-closures.rs b/src/test/run-pass/explicit-self-closures.rs index 4c12b6ad47c..d40b2f72ae8 100644 --- a/src/test/run-pass/explicit-self-closures.rs +++ b/src/test/run-pass/explicit-self-closures.rs @@ -21,9 +21,6 @@ impl Box { fn set_many2(@mut self, xs: &[uint]) { for xs.each |x| { self.x = *x; } } - fn set_many3(~mut self, xs: &[uint]) { - for xs.each |x| { self.x = *x; } - } } pub fn main() {} diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index eb10a51c0bd..7d5bf65dad7 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -29,7 +29,7 @@ extern mod rusti { pub fn main() { unsafe { - let x = ~mut 1; + let mut x = ~1; assert rusti::atomic_cxchg(x, 1, 2) == 1; assert *x == 2; diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 249d1c21376..b97ebb04f71 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -318,18 +318,16 @@ pub fn main() { // Commented out because of option::get error let (client_, server_) = pingpong::init(); - let client_ = ~mut Some(client_); - let server_ = ~mut Some(server_); + let client_ = Cell(client_); + let server_ = Cell(server_); task::spawn {|client_| - let mut client__ = none; - *client_ <-> client__; - client(option::unwrap(client__)); + let client__ = client_.take(); + client(client__); }; task::spawn {|server_| - let mut server_ˊ = none; - *server_ <-> server_ˊ; - server(option::unwrap(server_ˊ)); + let server__ = server_.take(); + server(server_ˊ); }; */ } diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 2ada6df76a6..23f2bc10046 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -14,6 +14,7 @@ // experiment with what code the compiler should generate for bounded // protocols. +use core::cell::Cell; // This was generated initially by the pipe compiler, but it's been // modified in hopefully straightforward ways. @@ -111,16 +112,14 @@ mod test { pub fn main() { let (client_, server_) = ::pingpong::init(); - let client_ = ~mut Some(client_); - let server_ = ~mut Some(server_); - do task::spawn || { - let mut client__ = None; - *client_ <-> client__; - test::client(option::unwrap(client__)); + let client_ = Cell(client_); + let server_ = Cell(server_); + do task::spawn { + let client__ = client_.take(); + test::client(client__); }; - do task::spawn || { - let mut server_ˊ = None; - *server_ <-> server_ˊ; - test::server(option::unwrap(server_ˊ)); + do task::spawn { + let server__ = server_.take(); + test::server(server_ˊ); }; } diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index 050ff76ef9b..a4a1c562bca 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -12,6 +12,7 @@ // An example to make sure the protocol parsing syntax extension works. +use core::cell::Cell; use core::option; proto! pingpong ( @@ -49,17 +50,15 @@ mod test { pub fn main() { let (client_, server_) = pingpong::init(); - let client_ = ~mut Some(client_); - let server_ = ~mut Some(server_); + let client_ = Cell(client_); + let server_ = Cell(server_); - do task::spawn || { - let mut client__ = None; - *client_ <-> client__; - test::client(option::unwrap(client__)); + do task::spawn { + let client__ = client_.take(); + test::client(client__); }; - do task::spawn || { - let mut server_ˊ = None; - *server_ <-> server_ˊ; - test::server(option::unwrap(server_ˊ)); + do task::spawn { + let server__ = server_.take(); + test::server(server_ˊ); }; } diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index f4c92c869e4..cac6b4ef349 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -20,7 +20,7 @@ pure fn sums_to(v: ~[int], sum: int) -> bool { } pure fn sums_to_using_uniq(v: ~[int], sum: int) -> bool { - let mut i = 0u, sum0 = ~mut 0; + let mut i = 0u, sum0 = ~0; while i < v.len() { *sum0 += v[i]; i += 1u; @@ -40,7 +40,7 @@ pure fn sums_to_using_rec(v: ~[int], sum: int) -> bool { struct F<T> { f: T } pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool { - let mut i = 0u, sum0 = F {f: ~mut 0}; + let mut i = 0u, sum0 = F {f: ~0}; while i < v.len() { *sum0.f += v[i]; i += 1u; diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index 61cb473bf8f..7011f5ba1ad 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -31,7 +31,7 @@ pub fn main() { debug!("y=%d", y); assert y == 6; - let x = ~mut 6; + let mut x = ~6; let y = x.get(); debug!("y=%d", y); assert y == 6; diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index b90c39ab34e..991025a1ad2 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -13,6 +13,7 @@ // A port of task-killjoin to use a class with a dtor to manage // the join. +use core::cell::Cell; use core::comm::*; struct notify { @@ -49,11 +50,9 @@ fn joinable(f: fn~()) -> Port<bool> { *b = true; } let (p, c) = stream(); - let c = ~mut Some(c); + let c = Cell(c); do task::spawn_unlinked { - let mut cc = None; - *c <-> cc; - let ccc = option::unwrap(cc); + let ccc = c.take(); wrapper(ccc, f) } p diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index 4723356dcd0..1bb04aef286 100644 --- a/src/test/run-pass/unique-assign-copy.rs +++ b/src/test/run-pass/unique-assign-copy.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = ~mut 1; + let mut i = ~1; // Should be a copy let mut j; j = copy i; diff --git a/src/test/run-pass/unique-decl-init-copy.rs b/src/test/run-pass/unique-decl-init-copy.rs index 628eb7265a5..a0b7fc336e2 100644 --- a/src/test/run-pass/unique-decl-init-copy.rs +++ b/src/test/run-pass/unique-decl-init-copy.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = ~mut 1; + let mut i = ~1; // Should be a copy let j = copy i; *i = 2; diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index 54ea0258c7c..ac8796674ab 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let a = ~[~mut 10]; + let mut a = ~[~10]; let b = copy a; assert *a[0] == 10; diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index c52d3b563ac..8784dbeb0af 100644 --- a/src/test/run-pass/unique-mutable.rs +++ b/src/test/run-pass/unique-mutable.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = ~mut 0; + let mut i = ~0; *i = 1; assert *i == 1; } |
