diff options
Diffstat (limited to 'src/test')
82 files changed, 283 insertions, 283 deletions
diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index beca0adbe3c..61a3ca1559c 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -11,10 +11,10 @@ use std::comm::*; use std::task; -pub fn foo<T:Send + Copy>(x: T) -> Port<T> { +pub fn foo<T:Send + Clone>(x: T) -> Port<T> { let (p, c) = stream(); do task::spawn() { - c.send(copy x); + c.send(x.clone()); } p } diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 1e82b85f728..c1e23f1f5c8 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -18,7 +18,7 @@ pub mod kitty { } impl ToStr for cat { - fn to_str(&self) -> ~str { copy self.name } + fn to_str(&self) -> ~str { self.name.clone() } } impl cat { diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index 2c9b28e6282..d53b7d825cb 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -18,26 +18,28 @@ pub struct alist<A,B> { data: @mut ~[Entry<A,B>] } -pub fn alist_add<A:Copy,B:Copy>(lst: &alist<A,B>, k: A, v: B) { +pub fn alist_add<A,B>(lst: &alist<A,B>, k: A, v: B) { lst.data.push(Entry{key:k, value:v}); } -pub fn alist_get<A:Copy,B:Copy>(lst: &alist<A,B>, k: A) -> B { +pub fn alist_get<A:Clone,B:Clone>(lst: &alist<A,B>, k: A) -> B { let eq_fn = lst.eq_fn; for lst.data.iter().advance |entry| { - if eq_fn(copy entry.key, copy k) { return copy entry.value; } + if eq_fn(entry.key.clone(), k.clone()) { + return entry.value.clone(); + } } fail!(); } #[inline] -pub fn new_int_alist<B:Copy>() -> alist<int, B> { +pub fn new_int_alist<B>() -> alist<int, B> { fn eq_int(a: int, b: int) -> bool { a == b } return alist {eq_fn: eq_int, data: @mut ~[]}; } #[inline] -pub fn new_int_alist_2<B:Copy>() -> alist<int, B> { +pub fn new_int_alist_2<B>() -> alist<int, B> { #[inline] fn eq_int(a: int, b: int) -> bool { a == b } return alist {eq_fn: eq_int, data: @mut ~[]}; diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 8afc0327755..75a4b6e2621 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -18,6 +18,6 @@ use std::hashmap::HashMap; pub type header_map = HashMap<~str, @mut ~[@~str]>; // the unused ty param is necessary so this gets monomorphized -pub fn request<T:Copy>(req: &header_map) { - let _x = copy *(copy **req.get(&~"METHOD"))[0u]; +pub fn request<T>(req: &header_map) { + let _x = (*((**req.get(&~"METHOD")).clone())[0u]).clone(); } diff --git a/src/test/auxiliary/issue2378a.rs b/src/test/auxiliary/issue2378a.rs index 1873aca5909..eed271c5499 100644 --- a/src/test/auxiliary/issue2378a.rs +++ b/src/test/auxiliary/issue2378a.rs @@ -13,10 +13,10 @@ enum maybe<T> { just(T), nothing } -impl <T:Copy> Index<uint,T> for maybe<T> { +impl <T:Clone> Index<uint,T> for maybe<T> { fn index(&self, idx: &uint) -> T { match self { - &just(ref t) => copy *t, + &just(ref t) => (*t).clone(), ¬hing => { fail!(); } } } diff --git a/src/test/auxiliary/issue2378b.rs b/src/test/auxiliary/issue2378b.rs index 20f07a5cb54..d2c42bacc63 100644 --- a/src/test/auxiliary/issue2378b.rs +++ b/src/test/auxiliary/issue2378b.rs @@ -17,7 +17,7 @@ use issue2378a::maybe; struct two_maybes<T> {a: maybe<T>, b: maybe<T>} -impl <T:Copy> Index<uint,(T,T)> for two_maybes<T> { +impl<T:Clone> Index<uint,(T,T)> for two_maybes<T> { fn index(&self, idx: &uint) -> (T, T) { (self.a[*idx], self.b[*idx]) } diff --git a/src/test/auxiliary/issue4516_ty_param_lib.rs b/src/test/auxiliary/issue4516_ty_param_lib.rs index 391e9b39610..cd90c9b06c4 100644 --- a/src/test/auxiliary/issue4516_ty_param_lib.rs +++ b/src/test/auxiliary/issue4516_ty_param_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub fn to_closure<A:'static + Copy>(x: A) -> @fn() -> A { - let result: @fn() -> A = || copy x; +pub fn to_closure<A:'static + Clone>(x: A) -> @fn() -> A { + let result: @fn() -> A = || x.clone(); result } diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs index c2caf1e77ee..9f504db8f2a 100644 --- a/src/test/auxiliary/issue_2242_a.rs +++ b/src/test/auxiliary/issue_2242_a.rs @@ -16,5 +16,5 @@ trait to_strz { } impl to_strz for ~str { - fn to_strz() -> ~str { copy self } + fn to_strz() -> ~str { self.clone() } } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index f0ffa3237b5..bbdfd3ecf79 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -198,7 +198,11 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { white => { let i = i as node_id; +<<<<<<< HEAD let neighbors = &graph[i]; +======= + let neighbors = graph[i].clone(); +>>>>>>> librustc: Remove all uses of "copy". let mut color = white; @@ -283,7 +287,7 @@ fn pbfs(graph: &arc::ARC<graph>, key: node_id) -> bfs_result { white => { let i = i as node_id; - let neighbors = copy graph[i]; + let neighbors = graph[i].clone(); let mut color = white; @@ -397,7 +401,7 @@ fn validate(edges: ~[(node_id, node_id)], info!(~"Verifying tree and graph edges..."); let status = do par::alli(tree) { - let edges = copy edges; + let edges = edges.clone(); let result: ~fn(x: uint, v: &i64) -> bool = |u, v| { let u = u as node_id; if *v == -1i64 || u == root { @@ -438,7 +442,7 @@ fn main() { edges.len(), stop - start)); let start = time::precise_time_s(); - let graph = make_graph(1 << scale, copy edges); + let graph = make_graph(1 << scale, edges.clone()); let stop = time::precise_time_s(); let mut total_edges = 0; @@ -451,7 +455,7 @@ fn main() { let mut total_seq = 0.0; let mut total_par = 0.0; - let graph_arc = arc::ARC(copy graph); + let graph_arc = arc::ARC(graph.clone()); do gen_search_keys(graph, num_keys).map() |root| { io::stdout().write_line(~""); @@ -459,7 +463,7 @@ fn main() { if do_sequential { let start = time::precise_time_s(); - let bfs_tree = bfs(copy graph, *root); + let bfs_tree = bfs(graph.clone(), *root); let stop = time::precise_time_s(); //total_seq += stop - start; @@ -470,7 +474,7 @@ fn main() { if do_validate { let start = time::precise_time_s(); - assert!((validate(copy edges, *root, bfs_tree))); + assert!((validate(edges.clone(), *root, bfs_tree))); let stop = time::precise_time_s(); io::stdout().write_line( @@ -479,7 +483,7 @@ fn main() { } let start = time::precise_time_s(); - let bfs_tree = bfs2(copy graph, *root); + let bfs_tree = bfs2(graph.clone(), *root); let stop = time::precise_time_s(); total_seq += stop - start; @@ -490,7 +494,7 @@ fn main() { if do_validate { let start = time::precise_time_s(); - assert!((validate(copy edges, *root, bfs_tree))); + assert!((validate(edges.clone(), *root, bfs_tree))); let stop = time::precise_time_s(); io::stdout().write_line( @@ -510,7 +514,7 @@ fn main() { if do_validate { let start = time::precise_time_s(); - assert!((validate(copy edges, *root, bfs_tree))); + assert!((validate(edges.clone(), *root, bfs_tree))); let stop = time::precise_time_s(); io::stdout().write_line(fmt!("Validation completed in %? seconds.", diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 91576bad73d..8aff30ec80a 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -43,7 +43,7 @@ fn server(requests: &Port<request>, responses: &comm::Chan<uint>) { let mut done = false; while !done { match requests.try_recv() { - Some(get_count) => { responses.send(copy count); } + Some(get_count) => { responses.send(count.clone()); } Some(bytes(b)) => { //error!("server: received %? bytes", b); count += b; @@ -107,7 +107,7 @@ fn main() { } else if args.len() <= 1u { ~[~"", ~"10000", ~"4"] } else { - copy args + args.clone() }; info!("%?", args); diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 12c0871566c..0046fb9dd12 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -34,11 +34,11 @@ enum request { } fn server(requests: &PortSet<request>, responses: &Chan<uint>) { - let mut count = 0; + let mut count: uint = 0; let mut done = false; while !done { match requests.try_recv() { - Some(get_count) => { responses.send(copy count); } + Some(get_count) => { responses.send(count.clone()); } Some(bytes(b)) => { //error!("server: received %? bytes", b); count += b; @@ -103,7 +103,7 @@ fn main() { } else if args.len() <= 1u { ~[~"", ~"10000", ~"4"] } else { - copy args + args.clone() }; info!("%?", args); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 0bf492ae55f..a60e0b9e340 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -77,7 +77,7 @@ fn main() { } else if args.len() <= 1u { ~[~"", ~"10", ~"100"] } else { - copy args + args.clone() }; let num_tasks = uint::from_str(args[1]).get(); diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index 0f6ca37a3fb..b4692c774aa 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -63,7 +63,7 @@ fn main() { } else if args.len() <= 1u { ~[~"", ~"100", ~"1000"] } else { - copy args + args.clone() }; let num_tasks = uint::from_str(args[1]).get(); diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index a5f96b35999..0c6b97c6b78 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -73,7 +73,7 @@ fn main() { } else if args.len() <= 1u { ~[~"", ~"10", ~"100"] } else { - copy args + args.clone() }; let num_tasks = uint::from_str(args[1]).get(); diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index da8d65a1dcb..f6e90d1b745 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -37,6 +37,7 @@ fn myrandom_next(r: @mut MyRandom, mx: u32) -> u32 { mx * r.last / 139968u32 } +#[deriving(Clone)] struct AminoAcids { ch: char, prob: u32 @@ -59,10 +60,14 @@ fn select_random(r: u32, genelist: ~[AminoAcids]) -> char { let mid: uint = lo + (hi - lo) / 2u; if target < v[mid].prob { return bisect(v, lo, mid, target); - } else { return bisect(v, mid, hi, target); } - } else { return v[hi].ch; } + } else { + return bisect(v, mid, hi, target); + } + } else { + return v[hi].ch; + } } - bisect(copy genelist, 0, genelist.len() - 1, r) + bisect(genelist.clone(), 0, genelist.len() - 1, r) } fn make_random_fasta(wr: @io::Writer, @@ -78,7 +83,7 @@ fn make_random_fasta(wr: @io::Writer, let mut op: ~str = ~""; for uint::range(0u, n as uint) |_i| { op.push_char(select_random(myrandom_next(rng, 100u32), - copy genelist)); + genelist.clone())); if op.len() >= LINE_LENGTH { wr.write_line(op); op = ~""; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 919c4daeb25..64cfa2561a4 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -34,22 +34,31 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { return (xx as float) * 100f / (yy as float); } - fn le_by_val<TT:Copy,UU:Copy + Ord>(kv0: &(TT,UU), - kv1: &(TT,UU)) -> bool { - let (_, v0) = copy *kv0; - let (_, v1) = copy *kv1; + fn le_by_val<TT:Copy + Clone, + UU:Copy + Clone + Ord>( + kv0: &(TT,UU), + kv1: &(TT,UU)) + -> bool { + let (_, v0) = (*kv0).clone(); + let (_, v1) = (*kv1).clone(); return v0 >= v1; } - fn le_by_key<TT:Copy + Ord,UU:Copy>(kv0: &(TT,UU), - kv1: &(TT,UU)) -> bool { - let (k0, _) = copy *kv0; - let (k1, _) = copy *kv1; + fn le_by_key<TT:Copy + Clone + Ord, + UU:Copy + Clone>( + kv0: &(TT,UU), + kv1: &(TT,UU)) + -> bool { + let (k0, _) = (*kv0).clone(); + let (k1, _) = (*kv1).clone(); return k0 <= k1; } // sort by key, then by value - fn sortKV<TT:Copy + Ord,UU:Copy + Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { + fn sortKV<TT:Copy + Clone + Ord, + UU:Copy + Clone + Ord>( + orig: ~[(TT,UU)]) + -> ~[(TT,UU)] { return sort::merge_sort(sort::merge_sort(orig, le_by_key), le_by_val); } @@ -65,7 +74,7 @@ fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str { let mut buffer = ~""; for pairs_sorted.iter().advance |kv| { - let (k,v) = copy *kv; + let (k,v) = (*kv).clone(); unsafe { let b = str::raw::from_bytes(k); // FIXME: #4318 Instead of to_ascii and to_str_ascii, could use diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 295211e03a1..cbc2d3f0ea8 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -105,7 +105,7 @@ fn main() { args }; - let opts = parse_opts(copy args); + let opts = parse_opts(args.clone()); if opts.stress { stress(2); diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index e5732b7d580..d3fd20a0293 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -48,7 +48,7 @@ fn main() { } else if args.len() <= 1 { ~[~"", ~"100"] } else { - copy args + args.clone() }; let (p,c) = comm::stream(); diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index 514b85c6ae0..e07e5334712 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -68,7 +68,7 @@ fn main() { } else if args.len() <= 1u { ~[~"", ~"100"] } else { - copy args + args.clone() }; let num_tasks = uint::from_str(args[1]).get(); diff --git a/src/test/compile-fail/borrowck-lend-flow-match.rs b/src/test/compile-fail/borrowck-lend-flow-match.rs index fcb31b7b7e0..d5c5597e57f 100644 --- a/src/test/compile-fail/borrowck-lend-flow-match.rs +++ b/src/test/compile-fail/borrowck-lend-flow-match.rs @@ -30,7 +30,7 @@ fn separate_arms() { x = Some(1); //~ ERROR cannot assign } } - copy x; // just to prevent liveness warnings + x.clone(); // just to prevent liveness warnings } fn guard() { diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index 0b9897f23fc..39a0e585ad2 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -1,5 +1,6 @@ // Test that we do not permit moves from &[] matched by a vec pattern. +#[deriving(Clone)] struct Foo { string: ~str } @@ -21,7 +22,7 @@ pub fn main() { ::std::util::unreachable(); } } - let z = copy tail[0]; + let z = tail[0].clone(); info!(fmt!("%?", z)); } _ => { diff --git a/src/test/compile-fail/borrowck-pat-reassign-binding.rs b/src/test/compile-fail/borrowck-pat-reassign-binding.rs index be2aee5d1b8..8d9718ca380 100644 --- a/src/test/compile-fail/borrowck-pat-reassign-binding.rs +++ b/src/test/compile-fail/borrowck-pat-reassign-binding.rs @@ -22,5 +22,5 @@ fn main() { x = Some(*i+1); //~ ERROR cannot assign to `x` } } - copy x; // just to prevent liveness warnings + x.clone(); // just to prevent liveness warnings } diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs index 8c0cf68c164..460e2ce23fc 100644 --- a/src/test/compile-fail/by-move-pattern-binding.rs +++ b/src/test/compile-fail/by-move-pattern-binding.rs @@ -13,7 +13,7 @@ fn main() { let s = S { x: Bar(~"hello") }; match &s.x { &Foo => {} - &Bar(identifier) => f(copy identifier) //~ ERROR cannot move + &Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move }; match &s.x { &Foo => {} diff --git a/src/test/compile-fail/copy-a-resource.rs b/src/test/compile-fail/copy-a-resource.rs index f709ddc0e0d..a90b04b79ad 100644 --- a/src/test/compile-fail/copy-a-resource.rs +++ b/src/test/compile-fail/copy-a-resource.rs @@ -24,7 +24,7 @@ fn foo(i:int) -> foo { fn main() { let x = foo(10); - let _y = copy x; - //~^ ERROR copying a value of non-copyable type `foo` + let _y = x.clone(); + //~^ ERROR does not implement any method in scope error!(x); } diff --git a/src/test/compile-fail/infinite-instantiation.rs b/src/test/compile-fail/infinite-instantiation.rs index 377b2016bcb..1a7cc5d3ad5 100644 --- a/src/test/compile-fail/infinite-instantiation.rs +++ b/src/test/compile-fail/infinite-instantiation.rs @@ -21,13 +21,13 @@ impl to_opt for uint { } } -impl<T:Copy> to_opt for Option<T> { +impl<T:Clone> to_opt for Option<T> { fn to_option(&self) -> Option<Option<T>> { - Some(copy *self) + Some((*self).clone()) } } -fn function<T:to_opt>(counter: uint, t: T) { +fn function<T:to_opt + Clone>(counter: uint, t: T) { if counter > 0u { function(counter - 1u, t.to_option()); } diff --git a/src/test/compile-fail/issue-2823.rs b/src/test/compile-fail/issue-2823.rs index 7d1f64b9dd2..95cb5c6475c 100644 --- a/src/test/compile-fail/issue-2823.rs +++ b/src/test/compile-fail/issue-2823.rs @@ -20,6 +20,6 @@ impl Drop for C { fn main() { let c = C{ x: 2}; - let d = copy c; //~ ERROR copying a value of non-copyable type `C` + let d = c.clone(); //~ ERROR does not implement any method in scope error!("%?", d.x); } diff --git a/src/test/compile-fail/issue-4542.rs b/src/test/compile-fail/issue-4542.rs index 6f41e516461..93f55d55e46 100644 --- a/src/test/compile-fail/issue-4542.rs +++ b/src/test/compile-fail/issue-4542.rs @@ -12,7 +12,7 @@ fn main() { for os::args().each |arg| { - match copy *arg { + match (*arg).clone() { s => { } } } diff --git a/src/test/compile-fail/kindck-owned.rs b/src/test/compile-fail/kindck-owned.rs index 848fd95a560..ed21df4a691 100644 --- a/src/test/compile-fail/kindck-owned.rs +++ b/src/test/compile-fail/kindck-owned.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn copy1<T:Copy>(t: T) -> @fn() -> T { - let result: @fn() -> T = || copy t; //~ ERROR does not fulfill `'static` +fn copy1<T:Clone>(t: T) -> @fn() -> T { + let result: @fn() -> T = || t.clone(); //~ ERROR does not fulfill `'static` result } -fn copy2<T:Copy + 'static>(t: T) -> @fn() -> T { - let result: @fn() -> T = || copy t; +fn copy2<T:Clone + 'static>(t: T) -> @fn() -> T { + let result: @fn() -> T = || t.clone(); result } @@ -24,6 +24,7 @@ fn main() { copy2(@3); copy2(@&x); //~ ERROR does not fulfill `'static` +<<<<<<< HEAD let boxed: @fn() = || {}; copy2(boxed); @@ -31,4 +32,6 @@ fn main() { copy2(owned); //~ ERROR does not fulfill `Copy` let borrowed: &fn:Copy() = || {}; copy2(borrowed); //~ ERROR does not fulfill `'static` +======= +>>>>>>> librustc: Remove all uses of "copy". } diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs index b74ca055e00..f8afc10c49b 100644 --- a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs +++ b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs @@ -13,7 +13,7 @@ fn test() { loop { v = 1; //~ ERROR re-assignment of immutable variable //~^ NOTE prior assignment occurs here - copy v; // just to prevent liveness warnings + v.clone(); // just to prevent liveness warnings } } diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs index dd134976164..43d7ca83753 100644 --- a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs +++ b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs @@ -12,7 +12,7 @@ fn test() { let v: int; v = 2; //~ NOTE prior assignment occurs here v += 1; //~ ERROR re-assignment of immutable variable - copy v; + v.clone(); } fn main() { diff --git a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs index c830c2d0175..8eb84525b83 100644 --- a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs +++ b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs @@ -10,9 +10,9 @@ fn test() { let v: int = 1; //~ NOTE prior assignment occurs here - copy v; + v.clone(); v = 2; //~ ERROR re-assignment of immutable variable - copy v; + v.clone(); } fn main() { diff --git a/src/test/compile-fail/liveness-dead.rs b/src/test/compile-fail/liveness-dead.rs index 2ab3cb4568a..df78b25187b 100644 --- a/src/test/compile-fail/liveness-dead.rs +++ b/src/test/compile-fail/liveness-dead.rs @@ -15,14 +15,14 @@ fn f1(x: &mut int) { } fn f2() { - let mut x = 3; //~ ERROR: value assigned to `x` is never read + let mut x: int = 3; //~ ERROR: value assigned to `x` is never read x = 4; - copy x; + x.clone(); } fn f3() { - let mut x = 3; - copy x; + let mut x: int = 3; + x.clone(); x = 4; //~ ERROR: value assigned to `x` is never read } diff --git a/src/test/compile-fail/liveness-init-in-fru.rs b/src/test/compile-fail/liveness-init-in-fru.rs index 1bd42c1cd32..96b3c2453c5 100644 --- a/src/test/compile-fail/liveness-init-in-fru.rs +++ b/src/test/compile-fail/liveness-init-in-fru.rs @@ -9,11 +9,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -struct point {x: int, y: int} +#[deriving(Clone)] +struct point { + x: int, + y: int, +} fn main() { let mut origin: point; origin = point {x: 10,.. origin}; //~ ERROR use of possibly uninitialized variable: `origin` - copy origin; + origin.clone(); } diff --git a/src/test/compile-fail/liveness-init-op-equal.rs b/src/test/compile-fail/liveness-init-op-equal.rs index aa62e95b565..cbe805551c2 100644 --- a/src/test/compile-fail/liveness-init-op-equal.rs +++ b/src/test/compile-fail/liveness-init-op-equal.rs @@ -11,7 +11,7 @@ fn test() { let v: int; v += 1; //~ ERROR use of possibly uninitialized variable: `v` - copy v; + v.clone(); } fn main() { diff --git a/src/test/compile-fail/liveness-init-plus-equal.rs b/src/test/compile-fail/liveness-init-plus-equal.rs index fd9f7e01a26..6e813809f03 100644 --- a/src/test/compile-fail/liveness-init-plus-equal.rs +++ b/src/test/compile-fail/liveness-init-plus-equal.rs @@ -11,7 +11,7 @@ fn test() { let mut v: int; v = v + 1; //~ ERROR use of possibly uninitialized variable: `v` - copy v; + v.clone(); } fn main() { diff --git a/src/test/compile-fail/liveness-move-in-loop.rs b/src/test/compile-fail/liveness-move-in-loop.rs index 605233d3da0..b6cecf0145c 100644 --- a/src/test/compile-fail/liveness-move-in-loop.rs +++ b/src/test/compile-fail/liveness-move-in-loop.rs @@ -17,7 +17,7 @@ fn main() { loop { loop { x = y; //~ ERROR use of moved value - copy x; + x.clone(); } } } diff --git a/src/test/compile-fail/liveness-move-in-while.rs b/src/test/compile-fail/liveness-move-in-while.rs index c501607aee6..eed7ba16da4 100644 --- a/src/test/compile-fail/liveness-move-in-while.rs +++ b/src/test/compile-fail/liveness-move-in-while.rs @@ -14,7 +14,7 @@ fn main() { let mut x: ~int; loop { info!(y); //~ ERROR use of moved value: `y` - while true { while true { while true { x = y; copy x; } } } + while true { while true { while true { x = y; x.clone(); } } } //~^ ERROR use of moved value: `y` } } diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs index 662514e133b..3423c780c4a 100644 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ b/src/test/compile-fail/liveness-use-after-move.rs @@ -12,5 +12,5 @@ fn main() { let x = ~5; let y = x; info!(*x); //~ ERROR use of moved value: `x` - copy y; + y.clone(); } diff --git a/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs b/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs index db52a2bbe1e..b70c9e11f34 100644 --- a/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs +++ b/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs @@ -18,25 +18,25 @@ fn f05() { fn f10() { let x = ~"hi"; - let _y = Foo { f:copy x }; + let _y = Foo { f:x.clone() }; touch(&x); } fn f20() { let x = ~"hi"; - let _y = Foo { f:copy (x) }; + let _y = Foo { f:(x).clone() }; touch(&x); } fn f30() { let x = ~"hi"; - let _y = Foo { f:copy ((x)) }; + let _y = Foo { f:((x)).clone() }; touch(&x); } fn f40() { let x = ~"hi"; - let _y = Foo { f:(((((copy ((x))))))) }; + let _y = Foo { f:(((((((x)).clone()))))) }; touch(&x); } diff --git a/src/test/compile-fail/non-copyable-void.rs b/src/test/compile-fail/non-copyable-void.rs index f979f8273a0..64d29a55756 100644 --- a/src/test/compile-fail/non-copyable-void.rs +++ b/src/test/compile-fail/non-copyable-void.rs @@ -14,7 +14,7 @@ fn main() { let x : *~[int] = &~[1,2,3]; let y : *libc::c_void = x as *libc::c_void; unsafe { - let _z = copy *y; - //~^ ERROR copying a value of non-copyable type + let _z = (*y).clone(); + //~^ ERROR does not implement any method in scope } } diff --git a/src/test/compile-fail/noncopyable-class.rs b/src/test/compile-fail/noncopyable-class.rs index aa7100f0aad..e64d5b67ab7 100644 --- a/src/test/compile-fail/noncopyable-class.rs +++ b/src/test/compile-fail/noncopyable-class.rs @@ -38,6 +38,6 @@ fn foo(i:int) -> foo { fn main() { let x = foo(10); - let _y = copy x; //~ ERROR copying a value of non-copyable type + let _y = x.clone(); //~ ERROR does not implement any method in scope error!(x); } diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs index b7fc2a64669..ccbe265000d 100644 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ b/src/test/compile-fail/pinned-deep-copy.rs @@ -27,13 +27,16 @@ fn r(i: @mut int) -> r { } } +struct A { + y: r, +} + fn main() { let i = @mut 0; { - struct A { y: r } // Can't do this copy let x = ~~~A {y: r(i)}; - let _z = copy x; //~ ERROR copying a value of non-copyable type + let _z = x.clone(); //~ ERROR failed to find an implementation info!(x); } error!(*i); diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs index dacfd466040..ace0f516eef 100644 --- a/src/test/compile-fail/unique-object-noncopyable.rs +++ b/src/test/compile-fail/unique-object-noncopyable.rs @@ -29,5 +29,5 @@ impl Foo for Bar { fn main() { let x = ~Bar { x: 10 }; let y: ~Foo = x as ~Foo; - let _z = copy y; //~ ERROR copying a value of non-copyable type + let _z = y.clone(); //~ ERROR does not implement any method in scope } diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index 30848a18af7..0218899bf2e 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -9,7 +9,7 @@ // except according to those terms. struct r { - b:bool, + b: bool, } impl Drop for r { @@ -18,6 +18,6 @@ impl Drop for r { fn main() { let i = ~r { b: true }; - let _j = copy i; //~ ERROR copying a value of non-copyable type + let _j = i.clone(); //~ ERROR failed to find an implementation info!(i); } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index cfb51793822..bee36ea8293 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -29,9 +29,8 @@ fn main() { let i2 = @mut 1; let r1 = ~[~r { i: i1 }]; let r2 = ~[~r { i: i2 }]; - f(copy r1, copy r2); - //~^ ERROR copying a value of non-copyable type - //~^^ ERROR copying a value of non-copyable type + f(r1.clone(), r2.clone()); + //~^ ERROR failed to find an implementation of info!((r2, *i1)); info!((r1, *i2)); } diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index 4ab74b485ab..38a72353a1e 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -17,7 +17,7 @@ fn failfn() { fn main() { let y = ~0; let x: @~fn() = @(|| { - error!(copy y); + error!(y.clone()); }); failfn(); error!(x); diff --git a/src/test/run-fail/unwind-box-fn.rs b/src/test/run-fail/unwind-box-fn.rs index c62e13e77d7..a94f904c492 100644 --- a/src/test/run-fail/unwind-box-fn.rs +++ b/src/test/run-fail/unwind-box-fn.rs @@ -17,7 +17,7 @@ fn failfn() { fn main() { let y = ~0; let x: @@fn() = @|| { - error!(copy y); + error!(y.clone()); }; failfn(); error!(x); diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 75c3638a99d..640be6635ee 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -15,11 +15,11 @@ fn main() { let carrots = @~"crunchy"; let result: @fn(@~str, &fn(~str)) = (|tasties, macerate| { - macerate(copy *tasties); + macerate((*tasties).clone()); }); result(carrots, |food| { let mush = food + cheese; - let cheese = copy cheese; + let cheese = cheese.clone(); let f: &fn() = || { let chew = mush + cheese; fail!("so yummy") diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs index e30054575d6..75af701cede 100644 --- a/src/test/run-fail/unwind-misc-1.rs +++ b/src/test/run-fail/unwind-misc-1.rs @@ -18,7 +18,7 @@ fn main() { let mut arr = ~[]; for uint::range(0u, 10u) |i| { arr += ~[@~"key stuff"]; - map.insert(copy arr, arr + ~[@~"value stuff"]); + map.insert(arr.clone(), arr + ~[@~"value stuff"]); if arr.len() == 5 { fail!(); } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index c48fbbca2b7..a821e4647c1 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -12,8 +12,8 @@ struct pair<A,B> { a: A, b: B } -fn f<A:Copy + 'static>(a: A, b: u16) -> @fn() -> (A, u16) { - let result: @fn() -> (A, u16) = || (copy a, b); +fn f<A:Clone + 'static>(a: A, b: u16) -> @fn() -> (A, u16) { + let result: @fn() -> (A, u16) = || (a.clone(), b); result } diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index f0f86222a25..1d910023a63 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -18,13 +18,13 @@ struct Rec<A> { rec: Option<@mut RecEnum<A>> } -fn make_cycle<A:Copy>(a: A) { +fn make_cycle<A>(a: A) { let g: @mut RecEnum<A> = @mut RecEnum(Rec {val: a, rec: None}); g.rec = Some(g); } -fn f<A:Send + Copy,B:Send + Copy>(a: A, b: B) -> @fn() -> (A, B) { - let result: @fn() -> (A, B) = || (copy a, copy b); +fn f<A:Send + Clone,B:Send + Clone>(a: A, b: B) -> @fn() -> (A, B) { + let result: @fn() -> (A, B) = || (a.clone(), b.clone()); result } diff --git a/src/test/run-pass/borrowed-ptr-pattern.rs b/src/test/run-pass/borrowed-ptr-pattern.rs index 86e8f600cd5..11751ed6ade 100644 --- a/src/test/run-pass/borrowed-ptr-pattern.rs +++ b/src/test/run-pass/borrowed-ptr-pattern.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo<T:Copy>(x: &T) -> T{ +fn foo<T:Clone>(x: &T) -> T{ match x { - &ref a => copy *a + &ref a => (*a).clone() } } diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs index 2c45ec83d00..2e92395d549 100644 --- a/src/test/run-pass/box-unbox.rs +++ b/src/test/run-pass/box-unbox.rs @@ -12,7 +12,7 @@ struct Box<T> {c: @T} -fn unbox<T:Copy>(b: Box<T>) -> T { return copy *b.c; } +fn unbox<T:Clone>(b: Box<T>) -> T { return (*b.c).clone(); } pub fn main() { let foo: int = 17; diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index 56c70e78092..97bcd7c5308 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -46,6 +46,7 @@ fn dog() -> dog { } } +#[deriving(Clone)] struct cat { priv meows : @mut uint, @@ -88,7 +89,7 @@ fn annoy_neighbors(critter: @noisy) { pub fn main() { let nyan : cat = cat(0u, 2, ~"nyan"); let whitefang : dog = dog(); - annoy_neighbors(@(copy nyan) as @noisy); + annoy_neighbors(@nyan.clone() as @noisy); annoy_neighbors(@whitefang as @noisy); assert_eq!(nyan.meow_count(), 10u); assert_eq!(*whitefang.volume, 1); diff --git a/src/test/run-pass/class-implement-traits.rs b/src/test/run-pass/class-implement-traits.rs index 8c7c62ce27e..59de9e9e76e 100644 --- a/src/test/run-pass/class-implement-traits.rs +++ b/src/test/run-pass/class-implement-traits.rs @@ -16,6 +16,7 @@ trait noisy { fn speak(&mut self); } +#[deriving(Clone)] struct cat { priv meows : uint, @@ -68,6 +69,6 @@ pub fn main() { nyan.eat(); assert!((!nyan.eat())); for uint::range(1u, 10u) |_i| { - make_speak(copy nyan); + make_speak(nyan.clone()); } } diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 1fa10222543..01c6442fa00 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -16,8 +16,8 @@ struct Pair<A,B> { a: A, b: B } -fn f<A:Copy + 'static>(a: A, b: u16) -> @fn() -> (A, u16) { - let result: @fn() -> (A, u16) = || (copy a, b); +fn f<A:Clone + 'static>(a: A, b: u16) -> @fn() -> (A, u16) { + let result: @fn() -> (A, u16) = || (a.clone(), b); result } diff --git a/src/test/run-pass/closure-bounds-copyable-squiggle-closure.rs b/src/test/run-pass/closure-bounds-copyable-squiggle-closure.rs deleted file mode 100644 index 8c2ae22e8ed..00000000000 --- a/src/test/run-pass/closure-bounds-copyable-squiggle-closure.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 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. - -// Tests correct copying of heap closures' environments. - -fn foo(x: ~fn:Copy()) -> (~fn:(), ~fn:()) { - (copy x, x) -} -fn main() { - let v = ~[~[1,2,3],~[4,5,6]]; // shouldn't get double-freed - let (f1,f2) = do foo { - assert!(v.len() == 2); - }; - f1(); - f2(); -} diff --git a/src/test/run-pass/closure-bounds-squiggle-closure-as-copyable-typaram.rs b/src/test/run-pass/closure-bounds-squiggle-closure-as-copyable-typaram.rs deleted file mode 100644 index 88d474a51e1..00000000000 --- a/src/test/run-pass/closure-bounds-squiggle-closure-as-copyable-typaram.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 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. - -// Tests correct copying of heap closures' environments. - -fn bar<T: Copy>(x: T) -> (T, T) { - (copy x, x) -} -fn foo(x: ~fn:Copy()) -> (~fn:(), ~fn:()) { - bar(x) -} -fn main() { - let v = ~[~[1,2,3],~[4,5,6]]; // shouldn't get double-freed - let (f1,f2) = do foo { - assert!(v.len() == 2); - }; - f1(); - f2(); -} diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 9a4519786e9..295f175fca4 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -41,12 +41,15 @@ fn select_based_on_unit_circle<'r, T>( shape.select(threshold, a, b) } - +#[deriving(Clone)] struct thing { x: A } -struct A { a: @int } +#[deriving(Clone)] +struct A { + a: @int +} fn thing(x: A) -> thing { thing { @@ -72,7 +75,7 @@ pub fn main() { assert_eq!(x.quux(), 10); let y = ~thing(A {a: @10}); - assert_eq!((copy y).bar(), 10); + assert_eq!(y.clone().bar(), 10); assert_eq!(y.quux(), 10); let z = thing(A {a: @11}); diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 9cf047d425c..7d849bbff01 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -13,8 +13,8 @@ type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, eq: compare<T>) { - let actual: T = { copy expected }; +fn test_generic<T:Clone>(expected: T, eq: compare<T>) { + let actual: T = { expected.clone() }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 25bf553ff35..389a42ae7af 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -13,8 +13,8 @@ type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, eq: compare<T>) { - let actual: T = { copy expected }; +fn test_generic<T:Clone>(expected: T, eq: compare<T>) { + let actual: T = { expected.clone() }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index afb1a4c76bb..7091fceb771 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -15,8 +15,8 @@ // Tests for standalone blocks as expressions with dynamic type sizes type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, eq: compare<T>) { - let actual: T = { copy expected }; +fn test_generic<T:Clone>(expected: T, eq: compare<T>) { + let actual: T = { expected.clone() }; assert!((eq(expected, actual))); } @@ -25,7 +25,11 @@ fn test_bool() { test_generic::<bool>(true, compare_bool); } -struct Pair {a: int, b: int} +#[deriving(Clone)] +struct Pair { + a: int, + b: int, +} fn test_rec() { fn compare_rec(t1: Pair, t2: Pair) -> bool { diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index 186d15c3490..a2d28a2be04 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -13,8 +13,8 @@ type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, not_expected: T, eq: compare<T>) { - let actual: T = if true { copy expected } else { not_expected }; +fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) { + let actual: T = if true { expected.clone() } else { not_expected }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 2e6db3bba07..f5b2a1a7986 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -14,8 +14,8 @@ // Tests for if as expressions with dynamic type sizes type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, not_expected: T, eq: compare<T>) { - let actual: T = if true { copy expected } else { not_expected }; +fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) { + let actual: T = if true { expected.clone() } else { not_expected }; assert!((eq(expected, actual))); } @@ -24,7 +24,11 @@ fn test_bool() { test_generic::<bool>(true, false, compare_bool); } -struct Pair {a: int, b: int} +#[deriving(Clone)] +struct Pair { + a: int, + b: int, +} fn test_rec() { fn compare_rec(t1: Pair, t2: Pair) -> bool { diff --git a/src/test/run-pass/expr-match-generic-box2.rs b/src/test/run-pass/expr-match-generic-box2.rs index 64aa4ce3609..a2ccf5c0fb9 100644 --- a/src/test/run-pass/expr-match-generic-box2.rs +++ b/src/test/run-pass/expr-match-generic-box2.rs @@ -13,8 +13,8 @@ type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, eq: compare<T>) { - let actual: T = match true { true => { copy expected }, _ => fail!("wat") }; +fn test_generic<T:Clone>(expected: T, eq: compare<T>) { + let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-match-generic.rs b/src/test/run-pass/expr-match-generic.rs index bd87e7207d1..59f1ff14f59 100644 --- a/src/test/run-pass/expr-match-generic.rs +++ b/src/test/run-pass/expr-match-generic.rs @@ -13,8 +13,8 @@ type compare<T> = @fn(T, T) -> bool; -fn test_generic<T:Copy>(expected: T, eq: compare<T>) { - let actual: T = match true { true => { copy expected }, _ => fail!("wat") }; +fn test_generic<T:Clone>(expected: T, eq: compare<T>) { + let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; assert!((eq(expected, actual))); } @@ -23,7 +23,11 @@ fn test_bool() { test_generic::<bool>(true, compare_bool); } -struct Pair { a: int, b: int } +#[deriving(Clone)] +struct Pair { + a: int, + b: int, +} fn test_rec() { fn compare_rec(t1: Pair, t2: Pair) -> bool { diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 8d31c3d2481..3c30a6b53af 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -10,12 +10,16 @@ -fn g<X:Copy>(x: X) -> X { return x; } +fn g<X>(x: X) -> X { return x; } -struct Pair<T> {a: T, b: T} +#[deriving(Clone)] +struct Pair<T> { + a: T, + b: T +} -fn f<T:Copy>(t: T) -> Pair<T> { - let x: Pair<T> = Pair {a: copy t, b: t}; +fn f<T:Clone>(t: T) -> Pair<T> { + let x: Pair<T> = Pair {a: t.clone(), b: t}; return g::<Pair<T>>(x); } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index 3be685c6389..161f37eb444 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -21,7 +21,7 @@ pub fn main() { match getopts(args, opts) { Ok(ref m) => assert!(!opt_present(m, "b")), - Err(ref f) => fail!(fail_str(copy *f)) + Err(ref f) => fail!(fail_str((*f).clone())) }; } diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index 59ab5018c1d..aa9be2203c6 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -23,19 +23,15 @@ enum object { fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str { - match table.find(&key) - { - option::Some(&extra::json::String(ref s)) => - { - copy *s + match table.find(&key) { + option::Some(&extra::json::String(ref s)) => { + (*s).clone() } - option::Some(value) => - { + option::Some(value) => { error!("%s was expected to be a string but is a %?", key, value); default } - option::None => - { + option::None => { default } } @@ -43,17 +39,14 @@ fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str fn add_interface(store: int, managed_ip: ~str, data: extra::json::Json) -> (~str, object) { - match &data - { - &extra::json::Object(ref interface) => - { - let name = lookup(copy *interface, ~"ifDescr", ~""); + match &data { + &extra::json::Object(ref interface) => { + let name = lookup((*interface).clone(), ~"ifDescr", ~""); let label = fmt!("%s-%s", managed_ip, name); (label, bool_value(false)) } - _ => - { + _ => { error!("Expected dict for %s interfaces but found %?", managed_ip, data); (~"gnos:missing-interface", bool_value(true)) } @@ -67,7 +60,7 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, extra::jso &extra::json::List(ref interfaces) => { do interfaces.map |interface| { - add_interface(store, copy managed_ip, copy *interface) + add_interface(store, managed_ip.clone(), (*interface).clone()) } } _ => diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index 5b668d710dd..387b0a68d21 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -103,7 +103,7 @@ priv fn cmd_to_str(cmd: ~[~str]) -> ~str { res.push_str("\r\n"); for cmd.iter().advance |s| { res.push_str([~"$", s.len().to_str(), ~"\r\n", - copy *s, ~"\r\n"].concat() ); + (*s).clone(), ~"\r\n"].concat() ); } res } diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 590be377691..61c63245d70 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn double<T:Copy>(a: T) -> ~[T] { return ~[copy a] + ~[a]; } +fn double<T:Copy + Clone>(a: T) -> ~[T] { return ~[a.clone()] + ~[a]; } fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index e733400527b..1370aea6df5 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -10,11 +10,13 @@ trait repeat<A> { fn get(&self) -> A; } -impl<A:Copy> repeat<A> for @A { - fn get(&self) -> A { copy **self } +impl<A:Clone> repeat<A> for @A { + fn get(&self) -> A { + (**self).clone() + } } -fn repeater<A:Copy>(v: @A) -> @repeat:<A> { +fn repeater<A:Clone>(v: @A) -> @repeat:<A> { // Note: owned kind is not necessary as A appears in the trait type @v as @repeat:<A> // No } diff --git a/src/test/run-pass/move-1-unique.rs b/src/test/run-pass/move-1-unique.rs index 9194fc830e0..ac6dfa00f48 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -8,7 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Triple { x: int, y: int, z: int } +#[deriving(Clone)] +struct Triple { + x: int, + y: int, + z: int, +} fn test(x: bool, foo: ~Triple) -> int { let bar = foo; @@ -19,8 +24,8 @@ fn test(x: bool, foo: ~Triple) -> int { pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; - assert_eq!(test(true, copy x), 2); - assert_eq!(test(true, copy x), 2); - assert_eq!(test(true, copy x), 2); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(true, x.clone()), 2); assert_eq!(test(false, x), 5); } diff --git a/src/test/run-pass/move-3-unique.rs b/src/test/run-pass/move-3-unique.rs index 1df2e3a382d..377fae52f49 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -12,7 +12,12 @@ extern mod extra; use std::uint; -struct Triple { x: int, y: int, z: int } +#[deriving(Clone)] +struct Triple { + x: int, + y: int, + z: int, +} fn test(x: bool, foo: ~Triple) -> int { let bar = foo; @@ -24,7 +29,7 @@ fn test(x: bool, foo: ~Triple) -> int { pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; for uint::range(0u, 10000u) |_i| { - assert_eq!(test(true, copy x), 2); + assert_eq!(test(true, x.clone()), 2); } assert_eq!(test(false, x), 5); } diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index f88c71bdf39..694773f4c7c 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -8,15 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[deriving(Clone)] struct myvec<X>(~[X]); -fn myvec_deref<X:Copy>(mv: myvec<X>) -> ~[X] { return copy *mv; } +fn myvec_deref<X:Clone>(mv: myvec<X>) -> ~[X] { return (*mv).clone(); } -fn myvec_elt<X:Copy>(mv: myvec<X>) -> X { return mv[0]; } +fn myvec_elt<X>(mv: myvec<X>) -> X { return mv[0]; } pub fn main() { let mv = myvec(~[1, 2, 3]); - assert_eq!(myvec_deref(copy mv)[1], 2); - assert_eq!(myvec_elt(copy mv), 1); + assert_eq!(myvec_deref(mv.clone())[1], 2); + assert_eq!(myvec_elt(mv.clone()), 1); assert_eq!(mv[2], 3); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index e557fae7ac9..62bd54e4395 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -1,3 +1,7 @@ +// xfail-test + +// xfail'd due to a bug in move detection for macros. + // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -36,11 +40,12 @@ impl<T> E<T> { macro_rules! check_option { ($e:expr: $T:ty) => {{ - check_option!(copy $e: $T, |ptr| assert!(*ptr == $e)); + check_option!($e: $T, |ptr| assert!(*ptr == $e)); }}; ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{ assert!(option::None::<$T>.is_none()); - let s_ = option::Some::<$T>($e); + let e = $e; + let s_ = option::Some::<$T>(e); let $v = s_.get_ref(); $chk }} @@ -48,11 +53,12 @@ macro_rules! check_option { macro_rules! check_fancy { ($e:expr: $T:ty) => {{ - check_fancy!(copy $e: $T, |ptr| assert!(*ptr == $e)); + check_fancy!($e: $T, |ptr| assert!(*ptr == $e)); }}; ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{ assert!(Nothing::<$T>((), ((), ()), [23i8, ..0]).is_none()); - let t_ = Thing::<$T>(23, $e); + let e = $e; + let t_ = Thing::<$T>(23, e); match t_.get_ref() { (23, $v) => { $chk } _ => fail!("Thing::<%s>(23, %s).get_ref() != (23, _)", @@ -74,7 +80,6 @@ pub fn main() { check_type!(@19: @int); check_type!(~"foo": ~str); check_type!(@"bar": @str); - check_type!(~[]: ~[int]); check_type!(~[20, 22]: ~[int]); check_type!(@[]: @[int]); check_type!(@[24, 26]: @[int]); diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index b995e9c9ed2..824cacc620d 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -17,6 +17,7 @@ struct AssociationList<K,V> { pairs: ~[AssociationPair<K,V>] } +#[deriving(Clone)] struct AssociationPair<K,V> { key: K, value: V @@ -28,11 +29,11 @@ impl<K,V> AssociationList<K,V> { } } -impl<K:Eq,V:Copy> Index<K,V> for AssociationList<K,V> { +impl<K:Eq,V:Clone> Index<K,V> for AssociationList<K,V> { fn index(&self, index: &K) -> V { for self.pairs.iter().advance |pair| { if pair.key == *index { - return copy pair.value; + return pair.value.clone(); } } fail!("No value found for key: %?", index); @@ -44,8 +45,8 @@ pub fn main() { let bar = ~"bar"; let mut list = AssociationList {pairs: ~[]}; - list.push(copy foo, 22); - list.push(copy bar, 44); + list.push(foo.clone(), 22); + list.push(bar.clone(), 44); assert!(list[foo] == 22) assert!(list[bar] == 44) diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index b7ef4e3ff25..faae814821d 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -499,9 +499,9 @@ struct Stuff { } impl my_visitor { - pub fn get<T:Copy>(&self, f: &fn(T)) { + pub fn get<T:Clone>(&self, f: &fn(T)) { unsafe { - f(copy *(self.ptr1 as *T)); + f((*(self.ptr1 as *T)).clone()); } } diff --git a/src/test/run-pass/resource-generic.rs b/src/test/run-pass/resource-generic.rs deleted file mode 100644 index 75d978b0d05..00000000000 --- a/src/test/run-pass/resource-generic.rs +++ /dev/null @@ -1,40 +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. - -// xfail-fast - -struct Arg<T> {val: T, fin: extern fn(T)} - -struct finish<T> { - arg: Arg<T> -} - -#[unsafe_destructor] -impl<T:Copy> Drop for finish<T> { - fn drop(&self) { - unsafe { - (self.arg.fin)(copy self.arg.val); - } - } -} - -fn finish<T:Copy>(arg: Arg<T>) -> finish<T> { - finish { - arg: arg - } -} - -pub fn main() { - let box = @mut 10; - fn dec_box(i: @mut int) { *i -= 1; } - - { let _i = finish(Arg{val: box, fin: dec_box}); } - assert_eq!(*box, 9); -} diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index b74e81bb612..e192a38dfa3 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -14,25 +14,29 @@ use std::task; pub fn main() { test05(); } -struct Pair<A,B> { a: A, b: B } +#[deriving(Clone)] +struct Pair<A,B> { + a: A, + b: B, +} -fn make_generic_record<A:Copy,B:Copy>(a: A, b: B) -> Pair<A,B> { +fn make_generic_record<A,B>(a: A, b: B) -> Pair<A,B> { return Pair {a: a, b: b}; } fn test05_start(f: &~fn(v: float, v: ~str) -> Pair<float, ~str>) { let p = (*f)(22.22f, ~"Hi"); - info!(copy p); + info!(p.clone()); assert!(p.a == 22.22f); assert!(p.b == ~"Hi"); let q = (*f)(44.44f, ~"Ho"); - info!(copy q); + info!(q.clone()); assert!(q.a == 44.44f); assert!(q.b == ~"Ho"); } -fn spawn<A:Copy,B:Copy>(f: extern fn(&~fn(A,B)->Pair<A,B>)) { +fn spawn<A,B>(f: extern fn(&~fn(A,B)->Pair<A,B>)) { let arg: ~fn(A, B) -> Pair<A,B> = |a, b| make_generic_record(a, b); task::spawn(|| f(&arg)); } diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index 34afc12f02e..11489c33eea 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -13,20 +13,43 @@ // interior record which is then itself interior to // something else, shape calculations were off. +#[deriving(Clone)] enum opt_span { - //hack (as opposed to option), to make `span` compile os_none, os_some(@Span), } -struct Span {lo: uint, hi: uint, expanded_from: opt_span} -struct Spanned<T> { data: T, span: Span } + +#[deriving(Clone)] +struct Span { + lo: uint, + hi: uint, + expanded_from: opt_span, +} + +#[deriving(Clone)] +struct Spanned<T> { + data: T, + span: Span, +} + type ty_ = uint; -struct Path_ { global: bool, idents: ~[~str], types: ~[@ty] } + +#[deriving(Clone)] +struct Path_ { + global: bool, + idents: ~[~str], + types: ~[@ty], +} + type path = Spanned<Path_>; type ty = Spanned<ty_>; -struct X { sp: Span, path: path } +#[deriving(Clone)] +struct X { + sp: Span, + path: path, +} pub fn main() { let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none}; @@ -34,6 +57,6 @@ pub fn main() { let p_: Path_ = Path_ { global: true, idents: ~[~"hi"], types: ~[t] }; let p: path = Spanned { data: p_, span: sp }; let x = X { sp: sp, path: p }; - error!(copy x.path); - error!(copy x); + error!(x.path.clone()); + error!(x.clone()); } diff --git a/src/test/run-pass/unique-copy-box.rs b/src/test/run-pass/unique-copy-box.rs index 7634641a56e..3b3074b4a7d 100644 --- a/src/test/run-pass/unique-copy-box.rs +++ b/src/test/run-pass/unique-copy-box.rs @@ -15,7 +15,7 @@ pub fn main() { let i = ~@1; let j = ~@2; let rc1 = sys::refcount(*i); - let j = copy i; + let j = i.clone(); let rc2 = sys::refcount(*i); error!("rc1: %u rc2: %u", rc1, rc2); assert_eq!(rc1 + 1u, rc2); |
