]> git.lizzy.rs Git - rust.git/commitdiff
test: More run-pass test fixes
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 6 Dec 2012 00:51:32 +0000 (16:51 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Thu, 6 Dec 2012 00:51:32 +0000 (16:51 -0800)
29 files changed:
src/test/auxiliary/cci_class_cast.rs
src/test/auxiliary/issue-2631-a.rs
src/test/auxiliary/issue_2242_a.rs
src/test/auxiliary/trait_inheritance_overloading_xc.rs
src/test/run-pass/alt-implicit-copy-unique.rs
src/test/run-pass/getopts_ref.rs
src/test/run-pass/issue-2633-2.rs
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-2804.rs
src/test/run-pass/istr.rs
src/test/run-pass/last-use-corner-cases.rs
src/test/run-pass/last-use-in-cap-clause.rs
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/morestack6.rs
src/test/run-pass/newtype-polymorphic.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/rec-auto.rs
src/test/run-pass/ret-break-cont-in-block.rs
src/test/run-pass/sendfn-generic-fn.rs
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
src/test/run-pass/stat.rs
src/test/run-pass/str-append.rs
src/test/run-pass/str-concat.rs
src/test/run-pass/syntax-extension-fmt.rs
src/test/run-pass/trait-inheritance-overloading.rs
src/test/run-pass/unique-assign-copy.rs
src/test/run-pass/unique-copy-box.rs
src/test/run-pass/unique-in-vec-copy.rs
src/test/run-pass/vec-ivec-deadlock.rs

index ca2af38758779ae32927f528e96a60975045d85d..32e0d87e85019016da52b0fcee4e898799b843f3 100644 (file)
@@ -13,7 +13,7 @@ struct cat {
 }
 
     impl cat : ToStr {
-       pure fn to_str() -> ~str { self.name }
+       pure fn to_str() -> ~str { copy self.name }
     }
 
     priv impl cat {
index 0ede9fb3f1926a0d200521d9afb6f414bed593ca..ad49866c005d85bcc4e894958a97157cc4b5f5e9 100644 (file)
@@ -12,5 +12,5 @@
 
 // the unused ty param is necessary so this gets monomorphized
 fn request<T: Copy>(req: header_map) {
-  let _x = *(*req.get(~"METHOD"))[0u];
+  let _x = *(copy *req.get(~"METHOD"))[0u];
 }
index ac7a8e47f26070b82e8187b7ec792ffa2d98d6fe..a03deaadf5749d082ae8ecbe9e81abe31b5cc7b6 100644 (file)
@@ -6,5 +6,5 @@ trait to_strz {
 }
 
 impl ~str: to_strz {
-    fn to_strz() -> ~str { self }
+    fn to_strz() -> ~str { copy self }
 }
index ceeee89de6a565502b9420ef45a34d63599d44e0..2c8cc190dbcc10be8dec5f3ad9265aec3796f206 100644 (file)
@@ -8,7 +8,7 @@ pub struct MyInt {
 }
 
 pub impl MyInt : Add<MyInt, MyInt> {
-    pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) }
+    pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
 }
 
 pub impl MyInt : Sub<MyInt, MyInt> {
index 502df31ad1769788aa2d5caecf74d9a10943824c..a2fb1678aa5ad2b657c72a92bae400e82a033752 100644 (file)
@@ -1,6 +1,8 @@
 fn main() {
     let x = ~{mut a: ~10, b: ~20};
     match x {
-      ~{ref a, ref b} => { assert **a == 10; (*x).a = ~30; assert **a == 30; }
+      ~{a: ref a, b: ref b} => {
+        assert **a == 10; (*x).a = ~30; assert **a == 30;
+      }
     }
 }
index 48bc054ad37c13c6c1cc1b7aa9f8575721cda42a..8ec7e06bd3e7a945ea4f2ba67f64577ccd5c1421 100644 (file)
@@ -9,7 +9,7 @@ fn main() {
     match getopts(args, opts) {
         result::Ok(ref m)  =>
             assert !opt_present(m, "b"),
-        result::Err(f) => fail fail_str(f)
+        result::Err(ref f) => fail fail_str(*f)
     };
 
-}
\ No newline at end of file
+}
index 1ff294a2d306e039b5f99554dd371fd46c28eed3..b6adfd1602f0849d8f263a2f7a8089fc24a3b53f 100644 (file)
@@ -4,5 +4,5 @@ fn a_val(&&x: ~int, +y: ~int) -> int {
 
 fn main() {
     let z = ~22;
-    a_val(z, z);
+    a_val(copy z, copy z);
 }
index e0955575d601e67e3b217962de82abac55b8d3f7..a829676675db91974defb9e9f07651dd1f773244 100644 (file)
@@ -17,5 +17,5 @@ fn nyan(kitty: cat, _kitty_info: kitty_info) {
 
 fn main() {
     let mut kitty = cat();
-    nyan(kitty, {kitty: kitty});
+    nyan(copy kitty, {kitty: copy kitty});
 }
index 867c023ccf1509694a07633b19baf496dfc45db4..d4d5e6d9d7282761edbf97157f30833dce1ca756 100644 (file)
@@ -13,9 +13,9 @@ fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str
 {
     match table.find(&key)
     {
-        option::Some(std::json::String(s)) =>
+        option::Some(std::json::String(copy s)) =>
         {
-            s
+            copy s
         }
         option::Some(value) =>
         {
@@ -33,9 +33,9 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str,
 {
     match &data
     {
-        &std::json::Object(interface) =>
+        &std::json::Object(copy interface) =>
         {
-            let name = lookup(interface, ~"ifDescr", ~"");
+            let name = lookup(copy interface, ~"ifDescr", ~"");
             let label = fmt!("%s-%s", managed_ip, name);
 
             (label, bool_value(false))
index c9e1c2886ea998157f0efceeabb8c4e2eb73bb14..e48a08cdf36092372b72b6ead98c98b6e6dce699 100644 (file)
@@ -1,6 +1,6 @@
 fn test_stack_assign() {
     let s: ~str = ~"a";
-    log(debug, s);
+    log(debug, copy s);
     let t: ~str = ~"a";
     assert (s == t);
     let u: ~str = ~"b";
@@ -39,7 +39,7 @@ fn test_append() {
 
     let mut s = ~"a";
     s += ~"b";
-    log(debug, s);
+    log(debug, copy s);
     assert (s == ~"ab");
 
     let mut s = ~"c";
index 510fc8ddeaa0fcd4a5bef25fc3a564695a618a92..c420ffac684b9d5682e212a1ad4250c4aaf51ac8 100644 (file)
@@ -21,7 +21,7 @@ fn main() {
     // Check that no false positives are found in loops.
     let mut q = ~40, p = 10;
     loop {
-        let i = q;
+        let i = copy q;
         p += *i;
         if p > 100 { break; }
     }
index baa03abeeb9c6d4f7c50a1327c4632d1aac00094..9fa814dd5cbddaffbf9668973618f15992a532e9 100644 (file)
@@ -2,7 +2,7 @@
 
 fn foo() -> fn@() -> int {
     let k = ~22;
-    let _u = {a: k};
+    let _u = {a: copy k};
     return fn@(move k) -> int { 22 };
 }
 
index 8dcb2f2cf8548c10ce676950b0dd0ca102cafb9a..ba49a5fd578e1f4c89c1cbdfe4ba6852bc87277b 100644 (file)
@@ -3,6 +3,6 @@
 fn main() {
     fn invoke(f: fn@()) { f(); }
     let k = ~22;
-    let _u = {a: k};
+    let _u = {a: copy k};
     invoke(|| log(error, k) )
 }
index 0d44e264688c6d8e7207992709db73c572191482..14acb23b89267e5e6a5b22a8cc51e5dadc2b63f5 100644 (file)
@@ -30,7 +30,7 @@ fn runtest2(f: fn~(), frame_backoff: u32, last_stk: *u8) -> u32 {
         // We switched stacks, go back and try to hit the dynamic linker
         frame_backoff
     } else {
-        let frame_backoff = runtest2(f, frame_backoff, curr_stk);
+        let frame_backoff = runtest2(copy f, frame_backoff, curr_stk);
         if frame_backoff > 1u32 {
             frame_backoff - 1u32
         } else if frame_backoff == 1u32 {
index 18f6557fdac0afc62c554d406874d208ba350193..4590542e3e86219b1e546143f46e21ae3a8c9eaa 100644 (file)
@@ -1,6 +1,6 @@
 enum myvec<X> = ~[X];
 
-fn myvec_deref<X: Copy>(mv: myvec<X>) -> ~[X] { return *mv; }
+fn myvec_deref<X: Copy>(mv: myvec<X>) -> ~[X] { return copy *mv; }
 
 fn myvec_elt<X: Copy>(mv: myvec<X>) -> X { return mv[0]; }
 
index 91d4a13a82981f9a44bf92dcebf719c2174ef745..9bdc137b29170037288520e16e3ee19a702ad8ff 100644 (file)
@@ -7,7 +7,7 @@ struct Point {
 }
 
 impl Point : ops::Add<Point,Point> {
-    pure fn add(other: &Point) -> Point {
+    pure fn add(&self, other: &Point) -> Point {
         Point {x: self.x + (*other).x, y: self.y + (*other).y}
     }
 }
index 0bb521c9dfba6a907f7bceefa7ed06118551ef28..8b409e244f096f03d2be594c27a3a6b680f24b25 100644 (file)
@@ -6,6 +6,6 @@
 // Issue #50.
 fn main() {
     let x = {foo: ~"hello", bar: ~"world"};
-    log(debug, x.foo);
-    log(debug, x.bar);
+    log(debug, copy x.foo);
+    log(debug, copy x.bar);
 }
index 4e7e978cf5567b933a949d701ae4b149a2f83861..126792847550b1d031c6e6b2f58cd9424d44d72a 100644 (file)
@@ -22,8 +22,8 @@ fn find_pos<T:Eq>(n: T, h: ~[T]) -> Option<uint> {
 
 fn bail_deep(x: ~[~[bool]]) {
     let mut seen = false;
-    for iter(x) |x| {
-        for iter(x) |x| {
+    for iter(copy x) |x| {
+        for iter(copy x) |x| {
             assert !seen;
             if x { seen = true; return; }
         }
index be00567af677b439a9c7396d1c9bc9aa91f39ef1..e9b6f2bca4c222cb960a43974278c48dba6d96b5 100644 (file)
@@ -16,12 +16,12 @@ fn make_generic_record<A: Copy, B: Copy>(a: A, b: B) -> pair<A,B> {
 
 fn test05_start(&&f: fn~(&&v: float, &&v: ~str) -> pair<float, ~str>) {
     let p = f(22.22f, ~"Hi");
-    log(debug, p);
+    log(debug, copy p);
     assert p.a == 22.22f;
     assert p.b == ~"Hi";
 
     let q = f(44.44f, ~"Ho");
-    log(debug, q);
+    log(debug, copy q);
     assert q.a == 44.44f;
     assert q.b == ~"Ho";
 }
index 1eb80950f9f5de377ff61eb72c89b9cefb933a37..8fcc4e8aeaf65363c3d6a7945c91c9e7f28a66b6 100644 (file)
@@ -25,6 +25,6 @@ fn main() {
     let p_: path_ = { global: true, idents: ~[~"hi"], types: ~[t] };
     let p: path = { data: p_, span: sp };
     let x = { sp: sp, path: p };
-    log(error, x.path);
-    log(error, x);
+    log(error, copy x.path);
+    log(error, copy x);
 }
index 2036e1bae783a62d02ad3efb32dedea8420ecbcc..9767370fe7f8257f24843c2e39415ce5a414ea8d 100644 (file)
@@ -8,7 +8,7 @@ fn main() {
 
     {
         match io::file_writer(&path, [io::Create, io::Truncate]) {
-            Err(e) => fail e,
+            Err(copy e) => fail e,
             Ok(f) => {
                 for uint::range(0, 1000) |_i| {
                     f.write_u8(0);
index 16e670b08b7628d7997c25831e26d6ad83c57e0d..496fb8dcb3f8ad732edd83bc80158446dca5974b 100644 (file)
@@ -6,7 +6,7 @@
 fn test1() {
     let mut s: ~str = ~"hello";
     s += ~"world";
-    log(debug, s);
+    log(debug, copy s);
     assert (s[9] == 'd' as u8);
 }
 
@@ -16,8 +16,8 @@ fn test2() {
     let ff: ~str = ~"abc";
     let a: ~str = ff + ~"ABC" + ff;
     let b: ~str = ~"ABC" + ff + ~"ABC";
-    log(debug, a);
-    log(debug, b);
+    log(debug, copy a);
+    log(debug, copy b);
     assert (a == ~"abcABCabc");
     assert (b == ~"ABCabcABC");
 }
index daba08e7378db6a57ae18c540210865a7753dc30..a493a1f1a5662e626d8d47b7278d5f616de91b44 100644 (file)
@@ -6,6 +6,6 @@ fn main() {
     let a: ~str = ~"hello";
     let b: ~str = ~"world";
     let s: ~str = a + b;
-    log(debug, s);
+    log(debug, copy s);
     assert (s[9] == 'd' as u8);
 }
index fe197cb6df0282f55a234dffd18fa83a1911d26a..34656859cf9a90ce2b7eb6344346436e37a486c2 100644 (file)
@@ -1,8 +1,8 @@
 extern mod std;
 
 fn test(actual: ~str, expected: ~str) {
-    log(debug, actual);
-    log(debug, expected);
+    log(debug, copy actual);
+    log(debug, copy expected);
     assert (actual == expected);
 }
 
@@ -249,4 +249,4 @@ fn more_floats() {
     assert ~"99"          == fmt!("%.0f", 98.5);
     assert ~"7.0000"      == fmt!("%.4f", 6.999999999);
     assert ~"3.141590000" == fmt!("%.9f", 3.14159);
-}
\ No newline at end of file
+}
index def37d1f9505c018777175fa837364fef1937751..5f5ca11ffb8c656169b70f9123e73b9535cea9a9 100644 (file)
@@ -5,7 +5,7 @@ trait MyNum : Add<self,self>, Sub<self,self>, Mul<self,self>, Eq { }
 struct MyInt { val: int }
 
 impl MyInt : Add<MyInt, MyInt> {
-    pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) }
+    pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
 }
 
 impl MyInt : Sub<MyInt, MyInt> {
index 2c152c9805ca53a7a9b0a89a52efa25963015040..0707b7a5a38c697af657b30ac9a4d876e7786fe7 100644 (file)
@@ -2,9 +2,9 @@ fn main() {
     let i = ~mut 1;
     // Should be a copy
     let mut j;
-    j = i;
+    j = copy i;
     *i = 2;
     *j = 3;
     assert *i == 2;
     assert *j == 3;
-}
\ No newline at end of file
+}
index e0ea3e6c0a316b8411e7640151f9d580d3499d6c..caf420bdefecaeb267e52fa533f8aa624a4c8052 100644 (file)
@@ -5,8 +5,8 @@ fn main() unsafe {
     let i = ~@1;
     let j = ~@2;
     let rc1 = refcount(*i);
-    let j = i;
+    let j = copy i;
     let rc2 = refcount(*i);
     error!("rc1: %u rc2: %u", rc1, rc2);
     assert rc1 + 1u == rc2;
-}
\ No newline at end of file
+}
index f16e4b5e412baf508d69f4a04f7c910692e07a3c..017d5ddc666095fa4ccf8b4ce859baf8140d1a2d 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     let a = ~[~mut 10];
-    let b = a;
+    let b = copy a;
 
     assert *a[0] == 10;
     assert *b[0] == 10;
@@ -10,4 +10,4 @@ fn main() {
 
     assert *a[0] == 20;
     assert *b[0] == 10;
-}
\ No newline at end of file
+}
index d8bef194e47956685d91285b1cc5b4f0af48eedd..b07481f20e9d780b677138e9d51f1c3d04c2cbd1 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
     let a = ~[1, 2, 3, 4, 5];
-    let mut b = ~[a, a];
+    let mut b = ~[copy a, copy a];
     b = b + b; // FIXME(#3387)---can't write b += b
 }