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)));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

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)));

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

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

16-
fn test_generic<T:Copy>(expected: ~T, eq: compare<T>) {
17-
let actual: ~T = { copy expected };
16+
fn test_generic<T:Copy+Clone>(expected: ~T, eq: compare<T>) {
17+
let actual: ~T = { expected.clone() };
1818
fail_unless!((eq(expected, actual)));
1919
}
2020

src/test/run-pass/generic-alias-unique.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn id<T:Copy + Owned>(t: T) -> T { return t; }
1414

1515
pub fn main() {
1616
let expected = ~100;
17-
let actual = id::<~int>(copy expected);
17+
let actual = id::<~int>(expected.clone());
1818
debug!(*actual);
1919
fail_unless!((*expected == *actual));
2020
}

src/test/run-pass/hashmap-memory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ mod map_reduce {
3838
fn start_mappers(ctrl: SharedChan<ctrl_proto>, inputs: ~[~str]) {
3939
for inputs.each |i| {
4040
let ctrl = ctrl.clone();
41-
let i = copy *i;
42-
task::spawn(|| map_task(ctrl.clone(), copy i) );
41+
let i = i.clone();
42+
task::spawn(|| map_task(ctrl.clone(), i.clone()) );
4343
}
4444
}
4545

@@ -79,7 +79,7 @@ mod map_reduce {
7979

8080
reducers = oldmap::HashMap();
8181

82-
start_mappers(ctrl_chan, copy inputs);
82+
start_mappers(ctrl_chan, inputs.clone());
8383

8484
let mut num_mappers = vec::len(inputs) as int;
8585

src/test/run-pass/issue-2487-a.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Drop for socket {
2020
pub impl socket {
2121
fn set_identity(&self) {
2222
do closure {
23-
setsockopt_bytes(copy self.sock)
23+
setsockopt_bytes(self.sock.clone())
2424
}
2525
}
2626
}

src/test/run-pass/issue-2633-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ fn a_val(&&x: ~int, +y: ~int) -> int {
1414

1515
pub fn main() {
1616
let z = ~22;
17-
a_val(copy z, copy z);
17+
a_val(z.clone(), z.clone());
1818
}

src/test/run-pass/issue-3389.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ pub fn main() {
2727
let v = ~[~"123", ~"abc"];
2828
node.content = ~[~"123", ~"abc"];
2929
print_str_vector(v);
30-
print_str_vector(copy node.content);
30+
print_str_vector(node.content.clone());
3131

3232
}

src/test/run-pass/issue-3609.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn foo(name: ~str, samples_chan: Chan<Msg>) {
1919
for uint::range(0, buffer.len())
2020
|i| {error!("%?: %f", i, buffer[i])}
2121
};
22-
samples_chan.send(GetSamples(copy name, callback));
22+
samples_chan.send(GetSamples(name.clone(), callback));
2323
};
2424
}
2525

src/test/run-pass/issue-4541.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn parse_args() -> ~str {
1414
let mut n = 0;
1515

1616
while n < args.len() {
17-
match copy args[n] {
17+
match args[n].clone() {
1818
~"-v" => (),
1919
s => {
2020
return s;

src/test/run-pass/issue-4542.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// xfail-test
1212
pub fn main() {
1313
for os::args().each |arg| {
14-
match copy *arg {
14+
match arg.clone() {
1515
s => { }
1616
}
1717
}

src/test/run-pass/istr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
fn test_stack_assign() {
1212
let s: ~str = ~"a";
13-
debug!(copy s);
13+
debug!(s.clone());
1414
let t: ~str = ~"a";
1515
fail_unless!((s == t));
1616
let u: ~str = ~"b";
@@ -49,7 +49,7 @@ fn test_append() {
4949
5050
let mut s = ~"a";
5151
s += ~"b";
52-
debug!(copy s);
52+
debug!(s.clone());
5353
fail_unless!((s == ~"ab"));
5454
5555
let mut s = ~"c";

src/test/run-pass/last-use-in-cap-clause.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct A { a: ~int }
1414

1515
fn foo() -> @fn() -> int {
1616
let k = ~22;
17-
let _u = A {a: copy k};
17+
let _u = A {a: k.clone()};
1818
let result: @fn() -> int = || 22;
1919
result
2020
}

src/test/run-pass/last-use-is-capture.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ struct A { a: ~int }
1515
pub fn main() {
1616
fn invoke(f: @fn()) { f(); }
1717
let k = ~22;
18-
let _u = A {a: copy k};
19-
invoke(|| error!(copy k) )
18+
let _u = A {a: k.clone()};
19+
invoke(|| error!(k.clone()) )
2020
}

src/test/run-pass/monad.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn main() {
4343
fail_unless!(transform(Some(10)) == Some(~"11"));
4444
fail_unless!(transform(None) == None);
4545
fail_unless!((~[~"hi"])
46-
.bind(|x| ~[copy *x, *x + ~"!"] )
47-
.bind(|x| ~[copy *x, *x + ~"?"] ) ==
46+
.bind(|x| ~[x.clone(), *x + ~"!"] )
47+
.bind(|x| ~[x.clone(), *x + ~"?"] ) ==
4848
~[~"hi", ~"hi?", ~"hi!", ~"hi!?"]);
4949
}

src/test/run-pass/propagate-expected-type-through-block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pub fn main() {
66
let y = ~3;
77
let foo: @fn(&int) -> int = {
8-
let y = copy y;
8+
let y = y.clone();
99
|x| *x + *y
1010
};
1111
fail_unless!(foo(@22) == 25);

src/test/run-pass/rec-auto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ struct X { foo: ~str, bar: ~str }
1919

2020
pub fn main() {
2121
let x = X {foo: ~"hello", bar: ~"world"};
22-
debug!(copy x.foo);
23-
debug!(copy x.bar);
22+
debug!(x.foo.clone());
23+
debug!(x.bar.clone());
2424
}

src/test/run-pass/reflect-visit-data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,10 @@ pub fn main() {
647647
let v = @v as @TyVisitor;
648648
visit_tydesc(td, v);
649649

650-
for (copy u.vals).each |s| {
650+
for (u.vals.clone()).each |s| {
651651
io::println(fmt!("val: %s", *s));
652652
}
653-
error!("%?", copy u.vals);
653+
error!("%?", u.vals.clone());
654654
fail_unless!(u.vals == ~[
655655
~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3", ~"12"
656656
]);

src/test/run-pass/reflect-visit-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub fn main() {
150150
visit_ty::<i16>(vv);
151151
visit_ty::<~[int]>(vv);
152152

153-
for (copy v.types).each {|s|
153+
for (v.types.clone()).each {|s|
154154
io::println(fmt!("type: %s", s));
155155
}
156156
fail_unless!(v.types == ["bool", "int", "i8", "i16",

src/test/run-pass/ret-break-cont-in-block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ fn iter<T>(v: ~[T], it: &fn(&T) -> bool) {
2020
}
2121
}
2222

23-
fn find_pos<T:Eq + Copy>(n: T, h: ~[T]) -> Option<uint> {
23+
fn find_pos<T:Eq + Copy + Clone>(n: T, h: ~[T]) -> Option<uint> {
2424
let mut i = 0u;
25-
for iter(copy h) |e| {
25+
for iter(h.clone()) |e| {
2626
if *e == n { return Some(i); }
2727
i += 1u;
2828
}
@@ -31,8 +31,8 @@ fn find_pos<T:Eq + Copy>(n: T, h: ~[T]) -> Option<uint> {
3131

3232
fn bail_deep(x: ~[~[bool]]) {
3333
let mut seen = false;
34-
for iter(copy x) |x| {
35-
for iter(copy *x) |x| {
34+
for iter(x.clone()) |x| {
35+
for iter(x.clone()) |x| {
3636
fail_unless!(!seen);
3737
if *x { seen = true; return; }
3838
}

src/test/run-pass/stat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn main() {
2020

2121
{
2222
match io::file_writer(&path, [io::Create, io::Truncate]) {
23-
Err(copy e) => fail!(e),
23+
Err(ref e) => fail!(e.clone()),
2424
Ok(f) => {
2525
for uint::range(0, 1000) |_i| {
2626
f.write_u8(0);

src/test/run-pass/str-append.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern mod std;
1616
fn test1() {
1717
let mut s: ~str = ~"hello";
1818
s += ~"world";
19-
debug!(copy s);
19+
debug!(s.clone());
2020
fail_unless!((s[9] == 'd' as u8));
2121
}
2222

@@ -26,8 +26,8 @@ fn test2() {
2626
let ff: ~str = ~"abc";
2727
let a: ~str = ff + ~"ABC" + ff;
2828
let b: ~str = ~"ABC" + ff + ~"ABC";
29-
debug!(copy a);
30-
debug!(copy b);
29+
debug!(a.clone());
30+
debug!(b.clone());
3131
fail_unless!((a == ~"abcABCabc"));
3232
fail_unless!((b == ~"ABCabcABC"));
3333
}

src/test/run-pass/str-concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ pub fn main() {
1616
let a: ~str = ~"hello";
1717
let b: ~str = ~"world";
1818
let s: ~str = a + b;
19-
debug!(copy s);
19+
debug!(s.clone());
2020
fail_unless!((s[9] == 'd' as u8));
2121
}

src/test/run-pass/syntax-extension-fmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
extern mod std;
1212

1313
fn test(actual: ~str, expected: ~str) {
14-
debug!(copy actual);
15-
debug!(copy expected);
14+
debug!(actual.clone());
15+
debug!(expected.clone());
1616
fail_unless!((actual == expected));
1717
}
1818

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl to_str for int {
1717
fn to_str(&self) -> ~str { int::to_str(*self) }
1818
}
1919
impl to_str for ~str {
20-
fn to_str(&self) -> ~str { copy *self }
20+
fn to_str(&self) -> ~str { self.clone() }
2121
}
2222
impl to_str for () {
2323
fn to_str(&self) -> ~str { ~"()" }

src/test/run-pass/unique-assign-copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn main() {
1212
let mut i = ~1;
1313
// Should be a copy
1414
let mut j;
15-
j = copy i;
15+
j = i.clone();
1616
*i = 2;
1717
*j = 3;
1818
fail_unless!(*i == 2);

src/test/run-pass/unique-decl-init-copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pub fn main() {
1212
let mut i = ~1;
1313
// Should be a copy
14-
let mut j = copy i;
14+
let mut j = i.clone();
1515
*i = 2;
1616
*j = 3;
1717
fail_unless!(*i == 2);

0 commit comments

Comments
 (0)