From 00d8db5b5d37e3039ff7cf170bc9c3473b3ab0de Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 25 Feb 2013 15:16:36 -0800 Subject: [PATCH] Revert "test: De-~mut the test suite. rs=demuting" This reverts commit f63efdc2100ff28e2a42600641835e7bd8bde591. --- src/test/bench/msgsend-ring-mutex-arcs.rs | 17 +++++++++------ src/test/bench/msgsend-ring-pipes.rs | 20 +++++++++++------- src/test/bench/msgsend-ring-rw-arcs.rs | 17 +++++++++------ .../bench/task-perf-jargon-metal-smoke.rs | 8 +++---- .../compile-fail/mutable-huh-variance-deep.rs | 4 ++-- .../mutable-huh-variance-unique.rs | 21 +++++++++++++++++++ src/test/compile-fail/no-send-res-ports.rs | 7 +++---- src/test/compile-fail/unique-mut.rs | 14 +++++++++++++ .../run-pass/borrowck-preserve-box-in-uniq.rs | 2 +- src/test/run-pass/explicit-self-closures.rs | 3 +++ src/test/run-pass/intrinsic-atomics.rs | 2 +- src/test/run-pass/issue-2718.rs | 14 +++++++------ src/test/run-pass/pipe-pingpong-bounded.rs | 19 +++++++++-------- src/test/run-pass/pipe-pingpong-proto.rs | 19 +++++++++-------- src/test/run-pass/pure-sum.rs | 4 ++-- src/test/run-pass/rcvr-borrowed-to-region.rs | 2 +- src/test/run-pass/task-killjoin-rsrc.rs | 7 ++++--- src/test/run-pass/unique-assign-copy.rs | 2 +- src/test/run-pass/unique-decl-init-copy.rs | 2 +- src/test/run-pass/unique-in-vec-copy.rs | 2 +- src/test/run-pass/unique-mutable.rs | 2 +- 21 files changed, 121 insertions(+), 67 deletions(-) create mode 100644 src/test/compile-fail/mutable-huh-variance-unique.rs create mode 100644 src/test/compile-fail/unique-mut.rs diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 22045007134a..9b6fee5e23bc 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -87,12 +87,17 @@ fn main() { for uint::range(1u, num_tasks) |i| { //error!("spawning %?", i); let (new_chan, num_port) = init(); - 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) + 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)) }; 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 dfe5c6de832c..0f7c41f5997a 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -17,12 +17,11 @@ // This version uses automatically compiled channel contracts. extern mod std; - -use core::cell::Cell; -use core::pipes::recv; use std::time; use std::future; +use core::pipes::recv; + proto! ring ( num:send { num(uint) -> num @@ -81,12 +80,17 @@ fn main() { for uint::range(1u, num_tasks) |i| { //error!("spawning %?", i); let (new_chan, num_port) = ring::init(); - let num_chan2 = Cell(num_chan); - let num_port = Cell(num_port); + let num_chan2 = ~mut None; + *num_chan2 <-> num_chan; + let num_port = ~mut Some(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) + 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)) }; 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 98c0129918a4..eaae8370d6b8 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -87,12 +87,17 @@ fn main() { for uint::range(1u, num_tasks) |i| { //error!("spawning %?", i); let (new_chan, num_port) = init(); - 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) + 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)) }; 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 9bdc5aae3f28..49a06fd491cd 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -17,15 +17,13 @@ // // 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 = Cell(c); - do task::spawn_supervised { - let c = c.take(); + let c = ~mut Some(c); + do task::spawn_supervised || { + let c = option::swap_unwrap(c); 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 51d5a6177f6a..4f0c6d7a4c87 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 new file mode 100644 index 000000000000..f2188911346e --- /dev/null +++ b/src/test/compile-fail/mutable-huh-variance-unique.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , 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 0d7e2d2377c2..4954bbfa09d0 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::cell::Cell; - struct Port(@T); fn main() { @@ -27,10 +25,11 @@ fn main() { } } - let x = Cell(foo(Port(@()))); + let x = ~mut Some(foo(Port(@()))); do task::spawn { - let y = x.take(); //~ ERROR value has non-owned type + let mut y = None; + *x <-> y; //~ 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 new file mode 100644 index 000000000000..a3a197505a34 --- /dev/null +++ b/src/test/compile-fail/unique-mut.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , 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 b11a5356f698..9724717f2d58 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 = ~@F{f: ~3}; + let mut x = ~mut @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 d40b2f72ae8b..4c12b6ad47c2 100644 --- a/src/test/run-pass/explicit-self-closures.rs +++ b/src/test/run-pass/explicit-self-closures.rs @@ -21,6 +21,9 @@ 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 7d5bf65dad7c..eb10a51c0bd6 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 mut x = ~1; + let x = ~mut 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 b97ebb04f716..249d1c21376b 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -318,16 +318,18 @@ pub fn main() { // Commented out because of option::get error let (client_, server_) = pingpong::init(); - let client_ = Cell(client_); - let server_ = Cell(server_); + let client_ = ~mut Some(client_); + let server_ = ~mut Some(server_); task::spawn {|client_| - let client__ = client_.take(); - client(client__); + let mut client__ = none; + *client_ <-> client__; + client(option::unwrap(client__)); }; task::spawn {|server_| - let server__ = server_.take(); - server(server_ˊ); + let mut server_ˊ = none; + *server_ <-> server_ˊ; + server(option::unwrap(server_ˊ)); }; */ } diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 23f2bc10046b..2ada6df76a6a 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -14,7 +14,6 @@ // 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. @@ -112,14 +111,16 @@ mod test { pub fn main() { let (client_, server_) = ::pingpong::init(); - let client_ = Cell(client_); - let server_ = Cell(server_); - do task::spawn { - let client__ = client_.take(); - test::client(client__); + let client_ = ~mut Some(client_); + let server_ = ~mut Some(server_); + do task::spawn || { + let mut client__ = None; + *client_ <-> client__; + test::client(option::unwrap(client__)); }; - do task::spawn { - let server__ = server_.take(); - test::server(server_ˊ); + do task::spawn || { + let mut server_ˊ = None; + *server_ <-> server_ˊ; + test::server(option::unwrap(server_ˊ)); }; } diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index a4a1c562bcaf..050ff76ef9b7 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -12,7 +12,6 @@ // An example to make sure the protocol parsing syntax extension works. -use core::cell::Cell; use core::option; proto! pingpong ( @@ -50,15 +49,17 @@ mod test { pub fn main() { let (client_, server_) = pingpong::init(); - let client_ = Cell(client_); - let server_ = Cell(server_); + let client_ = ~mut Some(client_); + let server_ = ~mut Some(server_); - do task::spawn { - let client__ = client_.take(); - test::client(client__); + do task::spawn || { + let mut client__ = None; + *client_ <-> client__; + test::client(option::unwrap(client__)); }; - do task::spawn { - let server__ = server_.take(); - test::server(server_ˊ); + do task::spawn || { + let mut server_ˊ = None; + *server_ <-> server_ˊ; + test::server(option::unwrap(server_ˊ)); }; } diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index cac6b4ef3493..f4c92c869e46 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 = ~0; + let mut i = 0u, sum0 = ~mut 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 { f: T } pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool { - let mut i = 0u, sum0 = F {f: ~0}; + let mut i = 0u, sum0 = F {f: ~mut 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 7011f5ba1add..61cb473bf8fb 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 mut x = ~6; + let x = ~mut 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 991025a1ad28..b90c39ab34e5 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 core::cell::Cell; use core::comm::*; struct notify { @@ -50,9 +49,11 @@ fn joinable(f: fn~()) -> Port { *b = true; } let (p, c) = stream(); - let c = Cell(c); + let c = ~mut Some(c); do task::spawn_unlinked { - let ccc = c.take(); + let mut cc = None; + *c <-> cc; + let ccc = option::unwrap(cc); 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 1bb04aef2868..4723356dcd0c 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 mut i = ~1; + let i = ~mut 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 a0b7fc336e25..628eb7265a5c 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 mut i = ~1; + let i = ~mut 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 ac8796674abb..54ea0258c7c6 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 mut a = ~[~10]; + let a = ~[~mut 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 8784dbeb0af4..c52d3b563ac5 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 mut i = ~0; + let i = ~mut 0; *i = 1; assert *i == 1; }