about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-05-06 00:42:54 -0400
committerAlex Crichton <alex@alexcrichton.com>2013-05-10 22:51:06 -0400
commit998fececd6516fa07d0cd0a0c4607ddef0bc40f0 (patch)
tree9597e6c2f0592136086f722338b95196f71104ec /src/test
parent7d22437ecdc5b52f8517ffde6207347739b26553 (diff)
downloadrust-998fececd6516fa07d0cd0a0c4607ddef0bc40f0.tar.gz
rust-998fececd6516fa07d0cd0a0c4607ddef0bc40f0.zip
Stop using the '<->' operator
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/core-std.rs3
-rw-r--r--src/test/bench/msgsend-ring-pipes.rs7
-rw-r--r--src/test/bench/shootout-k-nucleotide-pipes.rs4
-rw-r--r--src/test/compile-fail/liveness-assign-imm-local-in-swap.rs28
-rw-r--r--src/test/compile-fail/liveness-swap-uninit.rs16
-rw-r--r--src/test/compile-fail/moves-based-on-type-exprs.rs2
-rw-r--r--src/test/compile-fail/swap-no-lval.rs15
-rw-r--r--src/test/run-pass/borrowck-mut-uniq.rs6
-rw-r--r--src/test/run-pass/issue-2718.rs21
-rw-r--r--src/test/run-pass/regions-infer-borrow-scope-addr-of.rs4
-rw-r--r--src/test/run-pass/swap-1.rs5
-rw-r--r--src/test/run-pass/swap-2.rs6
-rw-r--r--src/test/run-pass/swap-overlapping.rs7
-rw-r--r--src/test/run-pass/unique-swap.rs4
-rw-r--r--src/test/run-pass/weird-exprs.rs4
15 files changed, 43 insertions, 89 deletions
diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs
index 95a83af93d5..e6b3b3bbe20 100644
--- a/src/test/bench/core-std.rs
+++ b/src/test/bench/core-std.rs
@@ -14,6 +14,7 @@ extern mod std;
 
 use std::time::precise_time_s;
 use core::rand::RngUtil;
+use core::util;
 
 macro_rules! bench (
     ($id:ident) => (maybe_run_test(argv, stringify!($id).to_owned(), $id))
@@ -115,7 +116,7 @@ fn vec_push_all() {
             v.push_all(rv);
         }
         else {
-            v <-> rv;
+            util::swap(&mut v, &mut rv);
             v.push_all(rv);
         }
     }
diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs
index aef5c18499a..f5191914679 100644
--- a/src/test/bench/msgsend-ring-pipes.rs
+++ b/src/test/bench/msgsend-ring-pipes.rs
@@ -20,6 +20,7 @@ extern mod std;
 
 use core::cell::Cell;
 use core::pipes::recv;
+use core::util;
 use std::time;
 use std::future;
 
@@ -42,10 +43,8 @@ fn thread_ring(i: uint,
     // Send/Receive lots of messages.
     for uint::range(0, count) |j| {
         //error!("task %?, iter %?", i, j);
-        let mut num_chan2 = None;
-        let mut num_port2 = None;
-        num_chan2 <-> num_chan;
-        num_port2 <-> num_port;
+        let num_chan2 = replace(&mut num_chan, None);
+        let num_port2 = replace(&mut num_port, None);
         num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
         let port = num_port2.unwrap();
         match recv(port) {
diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs
index d1f3dbf22ce..210bf5cb6de 100644
--- a/src/test/bench/shootout-k-nucleotide-pipes.rs
+++ b/src/test/bench/shootout-k-nucleotide-pipes.rs
@@ -17,6 +17,7 @@ use core::hashmap::HashMap;
 use core::io::ReaderUtil;
 use core::comm::{stream, Port, Chan};
 use core::cmp::Ord;
+use core::util;
 
 // given a map, print a sorted version of it
 fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
@@ -159,8 +160,7 @@ fn main() {
     let mut from_child = ~[];
     let to_child   = vec::mapi(sizes, |ii, sz| {
         let sz = *sz;
-        let mut stream = None;
-        stream <-> streams[ii];
+        let stream = util::replace(&mut streams[ii], None);
         let (from_child_, to_parent_) = stream.unwrap();
 
         from_child.push(from_child_);
diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-swap.rs b/src/test/compile-fail/liveness-assign-imm-local-in-swap.rs
deleted file mode 100644
index 40ccfca919b..00000000000
--- a/src/test/compile-fail/liveness-assign-imm-local-in-swap.rs
+++ /dev/null
@@ -1,28 +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.
-
-fn test1() {
-    let v: int;
-    let mut w: int;
-    v = 1; //~ NOTE prior assignment occurs here
-    w = 2;
-    v <-> w; //~ ERROR re-assignment of immutable variable
-}
-
-fn test2() {
-    let v: int;
-    let mut w: int;
-    v = 1; //~ NOTE prior assignment occurs here
-    w = 2;
-    w <-> v; //~ ERROR re-assignment of immutable variable
-}
-
-fn main() {
-}
diff --git a/src/test/compile-fail/liveness-swap-uninit.rs b/src/test/compile-fail/liveness-swap-uninit.rs
deleted file mode 100644
index b2d475dd789..00000000000
--- a/src/test/compile-fail/liveness-swap-uninit.rs
+++ /dev/null
@@ -1,16 +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.
-
-fn main() {
-    let mut x = 3;
-    let y;
-    x <-> y; //~ ERROR use of possibly uninitialized variable: `y`
-    copy x;
-}
diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs
index 7356c227360..5b733129ee5 100644
--- a/src/test/compile-fail/moves-based-on-type-exprs.rs
+++ b/src/test/compile-fail/moves-based-on-type-exprs.rs
@@ -87,7 +87,7 @@ fn f110() {
 
 fn f120() {
     let x = ~[~"hi", ~"ho"];
-    x[0] <-> x[1];
+    vec::swap(x, 0, 1);
     touch(&x[0]);
     touch(&x[1]);
 }
diff --git a/src/test/compile-fail/swap-no-lval.rs b/src/test/compile-fail/swap-no-lval.rs
deleted file mode 100644
index eca5fb0d315..00000000000
--- a/src/test/compile-fail/swap-no-lval.rs
+++ /dev/null
@@ -1,15 +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.
-
-fn main() {
-    5 <-> 3;
-    //~^ ERROR cannot assign
-    //~^^ ERROR cannot assign
-}
diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs
index 778637701c5..023eaae0a76 100644
--- a/src/test/run-pass/borrowck-mut-uniq.rs
+++ b/src/test/run-pass/borrowck-mut-uniq.rs
@@ -8,14 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::util;
+
 struct Ints {sum: ~int, values: ~[int]}
 
 fn add_int(x: &mut Ints, v: int) {
     *x.sum += v;
     let mut values = ~[];
-    x.values <-> values;
+    util::swap(&mut values, &mut x.values);
     values.push(v);
-    x.values <-> values;
+    util::swap(&mut values, &mut x.values);
 }
 
 fn iter_ints(x: &Ints, f: &fn(x: &int) -> bool) -> bool {
diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs
index acd26a88a73..60daaea57d7 100644
--- a/src/test/run-pass/issue-2718.rs
+++ b/src/test/run-pass/issue-2718.rs
@@ -10,8 +10,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::util;
+
 // tjc: I don't know why
 pub mod pipes {
+    use core::util;
     use core::cast::{forget, transmute};
 
     pub struct Stuff<T> {
@@ -104,8 +107,7 @@ pub mod pipes {
             match old_state {
               empty | blocked => { task::yield(); }
               full => {
-                let mut payload = None;
-                payload <-> (*p).payload;
+                let payload = util::replace(&mut p.payload, None);
                 return Some(payload.unwrap())
               }
               terminated => {
@@ -159,10 +161,9 @@ pub mod pipes {
         fn finalize(&self) {
             unsafe {
                 if self.p != None {
-                    let mut p = None;
                     let self_p: &mut Option<*packet<T>> =
                         cast::transmute(&self.p);
-                    p <-> *self_p;
+                    let p = util::replace(self_p, None);
                     sender_terminate(p.unwrap())
                 }
             }
@@ -171,9 +172,7 @@ pub mod pipes {
 
     pub impl<T:Owned> send_packet<T> {
         fn unwrap(&mut self) -> *packet<T> {
-            let mut p = None;
-            p <-> self.p;
-            p.unwrap()
+            util::replace(&mut self.p, None).unwrap()
         }
     }
 
@@ -192,10 +191,9 @@ pub mod pipes {
         fn finalize(&self) {
             unsafe {
                 if self.p != None {
-                    let mut p = None;
                     let self_p: &mut Option<*packet<T>> =
                         cast::transmute(&self.p);
-                    p <-> *self_p;
+                    let p = util::replace(self_p, None);
                     receiver_terminate(p.unwrap())
                 }
             }
@@ -204,9 +202,7 @@ pub mod pipes {
 
     pub impl<T:Owned> recv_packet<T> {
         fn unwrap(&mut self) -> *packet<T> {
-            let mut p = None;
-            p <-> self.p;
-            p.unwrap()
+            util::replace(&mut self.p, None).unwrap()
         }
     }
 
@@ -225,6 +221,7 @@ pub mod pipes {
 pub mod pingpong {
     use core::cast;
     use core::ptr;
+    use core::util;
 
     pub struct ping(::pipes::send_packet<pong>);
     pub struct pong(::pipes::send_packet<ping>);
diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs
index 39da08de6df..a87a899cafe 100644
--- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs
+++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::util;
+
 pub fn main() {
     let mut x = 4;
 
@@ -24,6 +26,6 @@ pub fn main() {
             }
         }
         let mut y = 4;
-        y <-> x;
+        util::swap(&mut y, &mut x);
     }
 }
diff --git a/src/test/run-pass/swap-1.rs b/src/test/run-pass/swap-1.rs
index feb7a88dc34..ed69fa41d71 100644
--- a/src/test/run-pass/swap-1.rs
+++ b/src/test/run-pass/swap-1.rs
@@ -8,7 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::util;
+
 pub fn main() {
     let mut x = 3; let mut y = 7;
-    x <-> y; assert!((x == 7)); assert!((y == 3));
+    util::swap(&mut x, &mut y);
+    assert!((x == 7)); assert!((y == 3));
 }
diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs
index 24794b03591..63b377b26d8 100644
--- a/src/test/run-pass/swap-2.rs
+++ b/src/test/run-pass/swap-2.rs
@@ -8,15 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn swap<T>(v: &mut [T], i: int, j: int) { v[i] <-> v[j]; }
+use core::util;
 
 pub fn main() {
     let mut a: ~[int] = ~[0, 1, 2, 3, 4, 5, 6];
-    swap(a, 2, 4);
+    vec::swap(a, 2, 4);
     assert!((a[2] == 4));
     assert!((a[4] == 2));
     let mut n = 42;
-    n <-> a[0];
+    util::swap(&mut n, &mut a[0]);
     assert!((a[0] == 42));
     assert!((n == 0));
 }
diff --git a/src/test/run-pass/swap-overlapping.rs b/src/test/run-pass/swap-overlapping.rs
index 90b2ceef71a..05f943bf928 100644
--- a/src/test/run-pass/swap-overlapping.rs
+++ b/src/test/run-pass/swap-overlapping.rs
@@ -10,6 +10,8 @@
 
 // Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
 
+use core::util;
+
 pub fn main() {
     let mut test = TestDescAndFn {
         desc: TestDesc {
@@ -22,7 +24,10 @@ pub fn main() {
 }
 
 fn do_swap(test: &mut TestDescAndFn) {
-    *test <-> *test;
+    unsafe {
+        util::swap_ptr(ptr::to_mut_unsafe_ptr(test),
+                       ptr::to_mut_unsafe_ptr(test));
+    }
 }
 
 pub enum TestName {
diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs
index 6cd7b358c55..bf58e2c7cb5 100644
--- a/src/test/run-pass/unique-swap.rs
+++ b/src/test/run-pass/unique-swap.rs
@@ -8,10 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::util;
+
 pub fn main() {
     let mut i = ~100;
     let mut j = ~200;
-    i <-> j;
+    util::swap(&mut i, &mut j);
     assert!(i == ~200);
     assert!(j == ~100);
 }
diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs
index ed0032b93ea..38aa56b6512 100644
--- a/src/test/run-pass/weird-exprs.rs
+++ b/src/test/run-pass/weird-exprs.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use core::util;
+
 // Just a grab bag of stuff that you wouldn't want to actually write.
 
 fn strange() -> bool { let _x: bool = return true; }
@@ -52,7 +54,7 @@ fn notsure() {
     let mut _y = (_x = 0) == (_x = 0);
     let mut _z = (_x = 0) < (_x = 0);
     let _a = (_x += 0) == (_x = 0);
-    let _b = (_y <-> _z) == (_y <-> _z);
+    let _b = util::swap(&mut _y, &mut _z) == util::swap(&mut _y, &mut _z);
 }
 
 fn canttouchthis() -> uint {