Skip to content

Commit ee58424

Browse files
committed
Clonify some of run-pass
1 parent 748c2c9 commit ee58424

39 files changed

+64
-61
lines changed

src/test/run-pass/alt-value-binding-in-guard-3291.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fn foo(x: Option<~int>, b: bool) -> int {
1212
match x {
1313
None => { 1 }
14-
Some(copy x) if b => { *x }
14+
Some(ref x) if b => { *x.clone() }
1515
Some(_) => { 0 }
1616
}
1717
}

src/test/run-pass/assignability-trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn main() {
4343
// Call a method
4444
for x.iterate() |y| { fail_unless!(x[*y] == *y); }
4545
// Call a parameterized function
46-
fail_unless!(length(copy x) == vec::len(x));
46+
fail_unless!(length(x.clone()) == vec::len(x));
4747
// Call a parameterized function, with type arguments that require
4848
// a borrow
4949
fail_unless!(length::<int, &[int]>(x) == vec::len(x));

src/test/run-pass/block-iter-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ fn iter_vec<T>(v: ~[T], f: &fn(&T)) { for v.each |x| { f(x); } }
1515
pub fn main() {
1616
let v = ~[1, 2, 3, 4, 5];
1717
let mut sum = 0;
18-
iter_vec(copy v, |i| {
19-
iter_vec(copy v, |j| {
18+
iter_vec(v.clone(), |i| {
19+
iter_vec(v.clone(), |j| {
2020
sum += *i * *j;
2121
});
2222
});

src/test/run-pass/block-vec-map2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ pub fn main() {
1515
vec::map2(~[1, 2, 3, 4, 5],
1616
~[true, false, false, true, true],
1717
|i, b| if *b { -(*i) } else { *i } );
18-
error!(copy v);
18+
error!(v.clone());
1919
fail_unless!((v == ~[-1, 2, 3, -4, -5]));
2020
}

src/test/run-pass/borrowck-borrow-from-expr-block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
1313
}
1414

1515
fn test1(x: @~int) {
16-
do borrow(copy *x) |p| {
16+
do borrow(&*x.clone()) |p| {
1717
let x_a = ptr::addr_of(&(**x));
1818
fail_unless!((x_a as uint) != ptr::to_uint(p));
1919
fail_unless!(unsafe{*x_a} == *p);

src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
fn switcher(x: Option<@int>) {
1414
let mut x = x;
1515
match x {
16-
Some(@y) => { copy y; x = None; }
16+
Some(@y) => { y.clone(); x = None; }
1717
None => { }
1818
}
1919
}

src/test/run-pass/class-exports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod kitty {
2222
}
2323

2424
pub impl cat {
25-
fn get_name(&self) -> ~str { copy self.name }
25+
fn get_name(&self) -> ~str { self.name.clone() }
2626
}
2727

2828
pub fn cat(in_name: ~str) -> cat {

src/test/run-pass/class-implement-traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
5353
cat {
5454
meows: in_x,
5555
how_hungry: in_y,
56-
name: copy in_name
56+
name: in_name.clone()
5757
}
5858
}
5959

src/test/run-pass/class-separate-impl.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// except according to those terms.
1010

1111
// xfail-fast
12-
use core::to_str::*;
13-
1412
struct cat {
1513
priv meows : uint,
1614

@@ -53,7 +51,12 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
5351
}
5452

5553
impl ToStr for cat {
56-
pure fn to_str(&self) -> ~str { copy self.name }
54+
pure fn to_str(&self) -> ~str {
55+
// FIXME #5384: this unsafe block is to work around purity
56+
unsafe {
57+
self.name.clone()
58+
}
59+
}
5760
}
5861

5962
fn print_out(thing: @ToStr, expected: ~str) {

src/test/run-pass/expr-alt-generic-unique1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// -*- rust -*-
1414
type compare<T> = @fn(~T, ~T) -> bool;
1515

16-
fn test_generic<T:Copy>(expected: ~T, eq: compare<T>) {
16+
fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
1717
let actual: ~T = match true {
18-
true => { copy expected },
18+
true => { expected.clone() },
1919
_ => fail!(~"wat")
2020
};
2121
fail_unless!((eq(expected, actual)));

0 commit comments

Comments
 (0)