diff options
| author | Simon BD <simon@server> | 2012-10-22 18:33:41 -0500 |
|---|---|---|
| committer | Simon BD <simon@server> | 2012-10-22 18:33:41 -0500 |
| commit | cc0f2c6bb26ba38d3487a396fa8625e938af6820 (patch) | |
| tree | 6c2063df35144c5477b0adc9e49933d71224dc2a /src/test | |
| parent | 9aec7a3e85c5b07923eab05d3ebe9d031bf258f3 (diff) | |
| parent | 9ee5fff4f16cfc3390bd69abbb46b0a68521667c (diff) | |
| download | rust-cc0f2c6bb26ba38d3487a396fa8625e938af6820.tar.gz rust-cc0f2c6bb26ba38d3487a396fa8625e938af6820.zip | |
Merge remote-tracking branch 'original/incoming' into incoming
Diffstat (limited to 'src/test')
172 files changed, 1069 insertions, 835 deletions
diff --git a/src/test/auxiliary/anon_trait_static_method_lib.rs b/src/test/auxiliary/anon_trait_static_method_lib.rs new file mode 100644 index 00000000000..ec9398dea15 --- /dev/null +++ b/src/test/auxiliary/anon_trait_static_method_lib.rs @@ -0,0 +1,10 @@ +pub struct Foo { + x: int +} + +pub impl Foo { + static fn new() -> Foo { + Foo { x: 3 } + } +} + diff --git a/src/test/auxiliary/cci_class_6.rs b/src/test/auxiliary/cci_class_6.rs index 6cf86aff055..da1a8b5f0ed 100644 --- a/src/test/auxiliary/cci_class_6.rs +++ b/src/test/auxiliary/cci_class_6.rs @@ -21,7 +21,7 @@ fn cat<U>(in_x : uint, in_y : int, -in_info: ~[U]) -> cat<U> { cat { meows: in_x, how_hungry: in_y, - info: in_info + info: move in_info } } diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 288fe66dd20..ca2af387587 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -13,7 +13,7 @@ struct cat { } impl cat : ToStr { - fn to_str() -> ~str { self.name } + pure fn to_str() -> ~str { self.name } } priv impl cat { diff --git a/src/test/auxiliary/issue_3136_a.rc b/src/test/auxiliary/issue_3136_a.rc new file mode 100644 index 00000000000..532c669bd1d --- /dev/null +++ b/src/test/auxiliary/issue_3136_a.rc @@ -0,0 +1,3 @@ +#[crate_type = "lib"]; + +pub mod issue_3136_a; diff --git a/src/test/auxiliary/issue_3136_a.rs b/src/test/auxiliary/issue_3136_a.rs new file mode 100644 index 00000000000..b3af6880323 --- /dev/null +++ b/src/test/auxiliary/issue_3136_a.rs @@ -0,0 +1,15 @@ +trait x { + fn use_x<T>(); +} +enum y = (); +impl y:x { + fn use_x<T>() { + struct foo { //~ ERROR quux + i: () + } + fn new_foo<T>(i: ()) -> foo { + foo { i: i } + } + } +} + diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index 77f107fda09..18960d0ad8a 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -7,7 +7,6 @@ use libc::size_t; -export port::{}; export port; export recv; @@ -65,13 +64,13 @@ fn recv<T: Send>(p: port<T>) -> T { recv_((**p).po) } /// Receive on a raw port pointer fn recv_<T: Send>(p: *rust_port) -> T { - let yield = 0u; + let yield = 0; let yieldp = ptr::addr_of(&yield); let mut res; res = rusti::init::<T>(); rustrt::port_recv(ptr::addr_of(&res) as *uint, p, yieldp); - if yield != 0u { + if yield != 0 { // Data isn't available yet, so res has not been initialized. task::yield(); } else { @@ -79,7 +78,7 @@ fn recv_<T: Send>(p: *rust_port) -> T { // this is a good place to yield task::yield(); } - return res; + move res } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 5acde71c6fd..c877d1d3657 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -119,7 +119,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result { Q.add_back(key); marks[key] = key; - while Q.size() > 0u { + while Q.size() > 0 { let t = Q.pop_front(); do graph[t].each() |k| { @@ -131,7 +131,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result { }; } - vec::from_mut(marks) + vec::from_mut(move marks) } /** @@ -167,11 +167,11 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { } } - let mut i = 0u; + let mut i = 0; while vec::any(colors, is_gray) { // Do the BFS. log(info, fmt!("PBFS iteration %?", i)); - i += 1u; + i += 1; colors = do colors.mapi() |i, c| { let c : color = *c; match c { @@ -245,13 +245,13 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result { i += 1; let old_len = colors.len(); - let color = arc::ARC(colors); + let color = arc::ARC(move colors); let color_vec = arc::get(&color); // FIXME #3387 requires this temp colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(+i: uint, +c: color) -> color { + fn~(move graph, move colors, +i: uint, +c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); @@ -388,7 +388,7 @@ fn main() { let args = os::args(); let args = if os::getenv(~"RUST_BENCH").is_some() { ~[~"", ~"15", ~"48"] - } else if args.len() <= 1u { + } else if args.len() <= 1 { ~[~"", ~"10", ~"16"] } else { args @@ -400,21 +400,21 @@ fn main() { let do_sequential = true; let start = time::precise_time_s(); - let edges = make_edges(scale, 16u); + let edges = make_edges(scale, 16); let stop = time::precise_time_s(); io::stdout().write_line(fmt!("Generated %? edges in %? seconds.", vec::len(edges), stop - start)); let start = time::precise_time_s(); - let graph = make_graph(1u << scale, edges); + let graph = make_graph(1 << scale, edges); let stop = time::precise_time_s(); - let mut total_edges = 0u; + let mut total_edges = 0; vec::each(graph, |edges| { total_edges += edges.len(); true }); io::stdout().write_line(fmt!("Generated graph with %? edges in %? seconds.", - total_edges / 2u, + total_edges / 2, stop - start)); let mut total_seq = 0.0; diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index d60937af13c..88ca0d3e0c2 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -19,7 +19,7 @@ use io::WriterUtil; use pipes::{Port, Chan, SharedChan}; macro_rules! move_out ( - { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } } + { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } } ) enum request { @@ -50,26 +50,26 @@ fn run(args: &[~str]) { let (to_parent, from_child) = pipes::stream(); let (to_child, from_parent) = pipes::stream(); - let to_child = SharedChan(to_child); + let to_child = SharedChan(move to_child); let size = uint::from_str(args[1]).get(); let workers = uint::from_str(args[2]).get(); let num_bytes = 100; let start = std::time::precise_time_s(); let mut worker_results = ~[]; - for uint::range(0u, workers) |i| { + for uint::range(0, workers) |_i| { let to_child = to_child.clone(); do task::task().future_result(|+r| { - worker_results.push(r); - }).spawn { - for uint::range(0u, size / workers) |_i| { + worker_results.push(move r); + }).spawn |move to_child| { + for uint::range(0, size / workers) |_i| { //error!("worker %?: sending %? bytes", i, num_bytes); to_child.send(bytes(num_bytes)); } //error!("worker %? exiting", i); }; } - do task::spawn { + do task::spawn |move from_parent, move to_parent| { server(from_parent, to_parent); } diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index e2d115600ef..ce3fd5134ac 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -15,7 +15,7 @@ use io::WriterUtil; use pipes::{Port, PortSet, Chan}; macro_rules! move_out ( - { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } } + { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } } ) enum request { @@ -46,27 +46,27 @@ fn run(args: &[~str]) { let (to_parent, from_child) = pipes::stream(); let (to_child, from_parent_) = pipes::stream(); let from_parent = PortSet(); - from_parent.add(from_parent_); + from_parent.add(move from_parent_); let size = uint::from_str(args[1]).get(); let workers = uint::from_str(args[2]).get(); let num_bytes = 100; let start = std::time::precise_time_s(); let mut worker_results = ~[]; - for uint::range(0u, workers) |i| { + for uint::range(0, workers) |_i| { let (to_child, from_parent_) = pipes::stream(); - from_parent.add(from_parent_); + from_parent.add(move from_parent_); do task::task().future_result(|+r| { - worker_results.push(r); - }).spawn { - for uint::range(0u, size / workers) |_i| { + worker_results.push(move r); + }).spawn |move to_child| { + for uint::range(0, size / workers) |_i| { //error!("worker %?: sending %? bytes", i, num_bytes); to_child.send(bytes(num_bytes)); } //error!("worker %? exiting", i); }; } - do task::spawn { + do task::spawn |move from_parent, move to_parent| { server(from_parent, to_parent); } diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index f657884eeef..3ec89567d20 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -33,7 +33,7 @@ fn recv(p: &pipe) -> uint { fn init() -> (pipe,pipe) { let m = arc::MutexARC(~[]); - ((&m).clone(), m) + ((&m).clone(), move m) } @@ -41,18 +41,18 @@ fn thread_ring(i: uint, count: uint, +num_chan: pipe, +num_port: pipe) { - let mut num_chan <- Some(num_chan); - let mut num_port <- Some(num_port); + let mut num_chan <- Some(move num_chan); + let mut num_port <- Some(move num_port); // Send/Receive lots of messages. for uint::range(0u, count) |j| { //error!("task %?, iter %?", i, j); let mut num_chan2 = option::swap_unwrap(&mut num_chan); let mut num_port2 = option::swap_unwrap(&mut num_port); send(&num_chan2, i * j); - num_chan = Some(num_chan2); + num_chan = Some(move num_chan2); let _n = recv(&num_port2); //log(error, _n); - num_port = Some(num_port2); + num_port = Some(move num_port2); }; } @@ -70,7 +70,7 @@ fn main() { let msg_per_task = uint::from_str(args[2]).get(); let (num_chan, num_port) = init(); - let mut num_chan = Some(num_chan); + let mut num_chan = Some(move num_chan); let start = time::precise_time_s(); @@ -82,22 +82,22 @@ fn main() { let (new_chan, num_port) = init(); let num_chan2 = ~mut None; *num_chan2 <-> num_chan; - let num_port = ~mut Some(num_port); + let num_port = ~mut Some(move num_port); let new_future = future::spawn(|move num_chan2, move num_port| { let mut num_chan = None; num_chan <-> *num_chan2; let mut num_port1 = None; num_port1 <-> *num_port; thread_ring(i, msg_per_task, - option::unwrap(num_chan), - option::unwrap(num_port1)) + option::unwrap(move num_chan), + option::unwrap(move num_port1)) }); - futures.push(new_future); - num_chan = Some(new_chan); + futures.push(move new_future); + num_chan = Some(move new_chan); }; // do our iteration - thread_ring(0u, msg_per_task, option::unwrap(num_chan), num_port); + thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port); // synchronize for futures.each |f| { future::get(f) }; diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index 73942d4ddf8..68429ee01bb 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -24,7 +24,7 @@ proto! ring ( fn macros() { #macro[ [#move_out[x], - unsafe { let y <- *ptr::addr_of(&x); y }] + unsafe { let y <- *ptr::addr_of(&x); move y }] ]; } @@ -32,18 +32,18 @@ fn thread_ring(i: uint, count: uint, +num_chan: ring::client::num, +num_port: ring::server::num) { - let mut num_chan <- Some(num_chan); - let mut num_port <- Some(num_port); + let mut num_chan <- Some(move num_chan); + let mut num_port <- Some(move num_port); // Send/Receive lots of messages. - for uint::range(0u, count) |j| { + 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; - num_chan = Some(ring::client::num(option::unwrap(num_chan2), i * j)); - let port = option::unwrap(num_port2); - match recv(port) { + num_chan = Some(ring::client::num(option::unwrap(move num_chan2), i * j)); + let port = option::unwrap(move num_port2); + match recv(move port) { ring::num(_n, p) => { //log(error, _n); num_port = Some(move_out!(p)); @@ -66,7 +66,7 @@ fn main() { let msg_per_task = uint::from_str(args[2]).get(); let (num_chan, num_port) = ring::init(); - let mut num_chan = Some(num_chan); + let mut num_chan = Some(move num_chan); let start = time::precise_time_s(); @@ -78,7 +78,7 @@ fn main() { let (new_chan, num_port) = ring::init(); let num_chan2 = ~mut None; *num_chan2 <-> num_chan; - let num_port = ~mut Some(num_port); + let num_port = ~mut Some(move num_port); let new_future = do future::spawn |move num_chan2, move num_port| { let mut num_chan = None; @@ -86,15 +86,15 @@ fn main() { let mut num_port1 = None; num_port1 <-> *num_port; thread_ring(i, msg_per_task, - option::unwrap(num_chan), - option::unwrap(num_port1)) + option::unwrap(move num_chan), + option::unwrap(move num_port1)) }; - futures.push(new_future); - num_chan = Some(new_chan); + futures.push(move new_future); + num_chan = Some(move new_chan); }; // do our iteration - thread_ring(0u, msg_per_task, option::unwrap(num_chan), num_port); + thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port); // synchronize for futures.each |f| { future::get(f) }; diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index 386496f459d..5e3d2f7d3e0 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -33,7 +33,7 @@ fn recv(p: &pipe) -> uint { fn init() -> (pipe,pipe) { let x = arc::RWARC(~[]); - ((&x).clone(), x) + ((&x).clone(), move x) } @@ -41,18 +41,18 @@ fn thread_ring(i: uint, count: uint, +num_chan: pipe, +num_port: pipe) { - let mut num_chan <- Some(num_chan); - let mut num_port <- Some(num_port); + let mut num_chan <- Some(move num_chan); + let mut num_port <- Some(move num_port); // Send/Receive lots of messages. for uint::range(0u, count) |j| { //error!("task %?, iter %?", i, j); let mut num_chan2 = option::swap_unwrap(&mut num_chan); let mut num_port2 = option::swap_unwrap(&mut num_port); send(&num_chan2, i * j); - num_chan = Some(num_chan2); + num_chan = Some(move num_chan2); let _n = recv(&num_port2); //log(error, _n); - num_port = Some(num_port2); + num_port = Some(move num_port2); }; } @@ -70,7 +70,7 @@ fn main() { let msg_per_task = uint::from_str(args[2]).get(); let (num_chan, num_port) = init(); - let mut num_chan = Some(num_chan); + let mut num_chan = Some(move num_chan); let start = time::precise_time_s(); @@ -82,7 +82,7 @@ fn main() { let (new_chan, num_port) = init(); let num_chan2 = ~mut None; *num_chan2 <-> num_chan; - let num_port = ~mut Some(num_port); + let num_port = ~mut Some(move num_port); let new_future = do future::spawn |move num_chan2, move num_port| { let mut num_chan = None; @@ -90,15 +90,15 @@ fn main() { let mut num_port1 = None; num_port1 <-> *num_port; thread_ring(i, msg_per_task, - option::unwrap(num_chan), - option::unwrap(num_port1)) + option::unwrap(move num_chan), + option::unwrap(move num_port1)) }; - futures.push(new_future); - num_chan = Some(new_chan); + futures.push(move new_future); + num_chan = Some(move new_chan); }; // do our iteration - thread_ring(0u, msg_per_task, option::unwrap(num_chan), num_port); + thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port); // synchronize for futures.each |f| { future::get(f) }; diff --git a/src/test/bench/msgsend-ring.rs b/src/test/bench/msgsend-ring.rs index 1dfcd241b83..5cb278b0dd2 100644 --- a/src/test/bench/msgsend-ring.rs +++ b/src/test/bench/msgsend-ring.rs @@ -52,7 +52,7 @@ fn main() { get_chan_chan.send(Chan(&p)); thread_ring(i, msg_per_task, num_chan, p) }; - futures.push(new_future); + futures.push(move new_future); num_chan = get_chan.recv(); }; diff --git a/src/test/bench/msgsend.rs b/src/test/bench/msgsend.rs index 8564adaab72..6ab22779c55 100644 --- a/src/test/bench/msgsend.rs +++ b/src/test/bench/msgsend.rs @@ -35,12 +35,12 @@ fn run(args: ~[~str]) { let workers = uint::from_str(args[2]).get(); let start = std::time::precise_time_s(); let mut worker_results = ~[]; - for uint::range(0u, workers) |_i| { + for uint::range(0, workers) |_i| { do task::task().future_result(|+r| { - worker_results.push(r); + worker_results.push(move r); }).spawn { - for uint::range(0u, size / workers) |_i| { - comm::send(to_child, bytes(100u)); + for uint::range(0, size / workers) |_i| { + comm::send(to_child, bytes(100)); } }; } diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 70f98934e1b..e7f9312ce38 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -33,7 +33,7 @@ proto! pingpong_unbounded ( // This stuff should go in libcore::pipes macro_rules! move_it ( - { $x:expr } => { let t <- *ptr::addr_of(&($x)); t } + { $x:expr } => { let t <- *ptr::addr_of(&($x)); move t } ) macro_rules! follow ( @@ -41,11 +41,9 @@ macro_rules! follow ( $($message:path($($x: ident),+) -> $next:ident $e:expr)+ } => ( |m| match move m { - $(Some($message($($x,)* next)) => { - // FIXME (#2329) use regular move here once move out of - // enums is supported. - let $next = unsafe { move_it!(next) }; - $e })+ + $(Some($message($($x,)* move next)) => { + let $next = move next; + move $e })+ _ => { fail } } ); @@ -54,11 +52,9 @@ macro_rules! follow ( $($message:path -> $next:ident $e:expr)+ } => ( |m| match move m { - $(Some($message(next)) => { - // FIXME (#2329) use regular move here once move out of - // enums is supported. - let $next = unsafe { move_it!(next) }; - $e })+ + $(Some($message(move next)) => { + let $next = move next; + move $e })+ _ => { fail } } ) @@ -66,7 +62,7 @@ macro_rules! follow ( fn switch<T: Send, Tb: Send, U>(+endp: pipes::RecvPacketBuffered<T, Tb>, f: fn(+v: Option<T>) -> U) -> U { - f(pipes::try_recv(endp)) + f(pipes::try_recv(move endp)) } // Here's the benchmark @@ -76,10 +72,10 @@ fn bounded(count: uint) { let mut ch = do spawn_service(init) |ch| { let mut count = count; - let mut ch = ch; + let mut ch = move ch; while count > 0 { - ch = switch(ch, follow! ( - ping -> next { server::pong(next) } + ch = switch(move ch, follow! ( + ping -> next { server::pong(move next) } )); count -= 1; @@ -88,10 +84,10 @@ fn bounded(count: uint) { let mut count = count; while count > 0 { - let ch_ = client::ping(ch); + let ch_ = client::ping(move ch); - ch = switch(ch_, follow! ( - pong -> next { next } + ch = switch(move ch_, follow! ( + pong -> next { move next } )); count -= 1; @@ -103,10 +99,10 @@ fn unbounded(count: uint) { let mut ch = do spawn_service(init) |ch| { let mut count = count; - let mut ch = ch; + let mut ch = move ch; while count > 0 { - ch = switch(ch, follow! ( - ping -> next { server::pong(next) } + ch = switch(move ch, follow! ( + ping -> next { server::pong(move next) } )); count -= 1; @@ -115,10 +111,10 @@ fn unbounded(count: uint) { let mut count = count; while count > 0 { - let ch_ = client::ping(ch); + let ch_ = client::ping(move ch); - ch = switch(ch_, follow! ( - pong -> next { next } + ch = switch(move ch_, follow! ( + pong -> next { move next } )); count -= 1; diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index a68b345cbc5..3a3c609853b 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -124,7 +124,7 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::Port<~[u8]>, }; //comm::send(to_parent, fmt!("yay{%u}", sz)); - to_parent.send(buffer); + to_parent.send(move buffer); } // given a FASTA file on stdin, process sequence THREE @@ -143,25 +143,25 @@ fn main() { // initialize each sequence sorter - let sizes = ~[1u,2u,3u,4u,6u,12u,18u]; + let sizes = ~[1,2,3,4,6,12,18]; let streams = vec::map(sizes, |_sz| Some(stream())); - let streams = vec::to_mut(streams); + let streams = vec::to_mut(move streams); let mut from_child = ~[]; let to_child = vec::mapi(sizes, |ii, sz| { let sz = *sz; let mut stream = None; stream <-> streams[ii]; - let (to_parent_, from_child_) = option::unwrap(stream); + let (to_parent_, from_child_) = option::unwrap(move stream); - from_child.push(from_child_); + from_child.push(move from_child_); let (to_child, from_parent) = pipes::stream(); - do task::spawn_with(from_parent) |from_parent| { + do task::spawn_with(move from_parent) |move to_parent_, from_parent| { make_sequence_processor(sz, from_parent, to_parent_); }; - to_child + move to_child }); diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index fa97e796bd1..a776c1322d3 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -34,15 +34,15 @@ fn fib(n: int) -> int { } else { let p = pipes::PortSet(); let ch = p.chan(); - task::spawn(|| pfib(ch, n - 1) ); + task::spawn(|move ch| pfib(ch, n - 1) ); let ch = p.chan(); - task::spawn(|| pfib(ch, n - 2) ); + task::spawn(|move ch| pfib(ch, n - 2) ); c.send(p.recv() + p.recv()); } } let (ch, p) = pipes::stream(); - let t = task::spawn(|| pfib(ch, n) ); + let _t = task::spawn(|move ch| pfib(ch, n) ); p.recv() } @@ -73,7 +73,7 @@ fn stress(num_tasks: int) { let mut results = ~[]; for range(0, num_tasks) |i| { do task::task().future_result(|+r| { - results.push(r); + results.push(move r); }).spawn { stress_task(i); } @@ -104,7 +104,7 @@ fn main() { let out = io::stdout(); for range(1, max + 1) |n| { - for range(0, num_trials) |i| { + for range(0, num_trials) |_i| { let start = time::precise_time_ns(); let fibn = fib(n); let stop = time::precise_time_ns(); diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 2e8ef0bac58..921aa8f0657 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -130,7 +130,7 @@ fn main() { let args = os::args(); let grid = if vec::len(args) == 1u { // FIXME create sudoku inline since nested vec consts dont work yet - // (#571) + // (#3733) let g = vec::from_fn(10u, |_i| { vec::to_mut(vec::from_elem(10u, 0 as u8)) }); diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index f5b2bb1c1c3..55d75ff7c82 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -78,7 +78,8 @@ fn recurse_or_fail(depth: int, st: Option<st>) { box: @Cons((), st.box), unique: ~Cons((), @*st.unique), fn_box: fn@() -> @nillist { @Cons((), fn_box()) }, - fn_unique: fn~() -> ~nillist { ~Cons((), @*fn_unique()) }, + fn_unique: fn~(move fn_unique) -> ~nillist + { ~Cons((), @*fn_unique()) }, tuple: (@Cons((), st.tuple.first()), ~Cons((), @*st.tuple.second())), vec: st.vec + ~[@Cons((), st.vec.last())], @@ -87,6 +88,6 @@ fn recurse_or_fail(depth: int, st: Option<st>) { } }; - recurse_or_fail(depth, Some(st)); + recurse_or_fail(depth, Some(move st)); } } diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 2055993d441..09e6f23004a 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -9,14 +9,14 @@ fn child_generation(gens_left: uint, -c: pipes::Chan<()>) { // This used to be O(n^2) in the number of generations that ever existed. // With this code, only as many generations are alive at a time as tasks // alive at a time, - let c = ~mut Some(c); - do task::spawn_supervised { + let c = ~mut Some(move c); + do task::spawn_supervised |move c| { let c = option::swap_unwrap(c); if gens_left & 1 == 1 { task::yield(); // shake things up a bit } if gens_left > 0 { - child_generation(gens_left - 1, c); // recurse + child_generation(gens_left - 1, move c); // recurse } else { c.send(()) } @@ -27,14 +27,14 @@ fn main() { let args = os::args(); let args = if os::getenv(~"RUST_BENCH").is_some() { ~[~"", ~"100000"] - } else if args.len() <= 1u { + } else if args.len() <= 1 { ~[~"", ~"100"] } else { copy args }; let (c,p) = pipes::stream(); - child_generation(uint::from_str(args[1]).get(), c); + child_generation(uint::from_str(args[1]).get(), move c); if p.try_recv().is_none() { fail ~"it happened when we slumbered"; } diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index a692b2f3011..f148d595f9d 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -19,21 +19,21 @@ fn grandchild_group(num_tasks: uint) { comm::recv(comm::Port::<()>()); // block forever } } - #error["Grandchild group getting started"]; + error!("Grandchild group getting started"); for num_tasks.times { // Make sure all above children are fully spawned; i.e., enlisted in // their ancestor groups. comm::recv(po); } - #error["Grandchild group ready to go."]; + error!("Grandchild group ready to go."); // Master grandchild task exits early. } fn spawn_supervised_blocking(myname: &str, +f: fn~()) { let mut res = None; - task::task().future_result(|+r| res = Some(r)).supervised().spawn(f); - #error["%s group waiting", myname]; - let x = future::get(&option::unwrap(res)); + task::task().future_result(|+r| res = Some(move r)).supervised().spawn(move f); + error!("%s group waiting", myname); + let x = future::get(&option::unwrap(move res)); assert x == task::Success; } @@ -58,10 +58,10 @@ fn main() { grandchild_group(num_tasks); } // When grandchild group is ready to go, make the middle group exit. - #error["Middle group wakes up and exits"]; + error!("Middle group wakes up and exits"); } // Grandparent group waits for middle group to be gone, then fails - #error["Grandparent group wakes up and fails"]; + error!("Grandparent group wakes up and fails"); fail; }; assert x.is_err(); diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 30add8c730c..3fe192ed363 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -30,7 +30,7 @@ use cmp::Eq; use to_bytes::IterBytes; macro_rules! move_out ( - { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } } + { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } } ) trait word_reader { @@ -90,19 +90,19 @@ impl<T> box<T> { fn swap(f: fn(+v: T) -> T) { let mut tmp = None; self.contents <-> tmp; - self.contents = Some(f(option::unwrap(tmp))); + self.contents = Some(f(option::unwrap(move tmp))); } fn unwrap() -> T { let mut tmp = None; self.contents <-> tmp; - option::unwrap(tmp) + option::unwrap(move tmp) } } fn box<T>(+x: T) -> box<T> { box { - contents: Some(x) + contents: Some(move x) } } @@ -151,13 +151,13 @@ mod map_reduce { let mut tasks = ~[]; for inputs.each |i| { let (ctrl, ctrl_server) = ctrl_proto::init(); - let ctrl = box(ctrl); + let ctrl = box(move ctrl); let i = copy *i; let m = copy *map; - tasks.push(spawn_joinable(|move i| map_task(m, &ctrl, i))); - ctrls.push(ctrl_server); + tasks.push(spawn_joinable(|move ctrl, move i| map_task(m, &ctrl, i))); + ctrls.push(move ctrl_server); } - return tasks; + move tasks } fn map_task<K1: Copy Send, K2: Hash IterBytes Eq Const Copy Send, V: Copy Send>( @@ -177,8 +177,8 @@ mod map_reduce { Some(_c) => { c = Some(_c); } None => { do ctrl.swap |ctrl| { - let ctrl = ctrl_proto::client::find_reducer(ctrl, *key); - match pipes::recv(ctrl) { + let ctrl = ctrl_proto::client::find_reducer(move ctrl, *key); + match pipes::recv(move ctrl) { ctrl_proto::reducer(c_, ctrl) => { c = Some(c_); move_out!(ctrl) @@ -250,12 +250,12 @@ mod map_reduce { let mut num_mappers = vec::len(inputs) as int; while num_mappers > 0 { - let (_ready, message, ctrls) = pipes::select(ctrl); - match option::unwrap(message) { + let (_ready, message, ctrls) = pipes::select(move ctrl); + match option::unwrap(move message) { ctrl_proto::mapper_done => { // error!("received mapper terminated."); num_mappers -= 1; - ctrl = ctrls; + ctrl = move ctrls; } ctrl_proto::find_reducer(k, cc) => { let c; @@ -271,13 +271,13 @@ mod map_reduce { let p = Port(); let ch = Chan(&p); let r = reduce, kk = k; - tasks.push(spawn_joinable(|| reduce_task(~r, kk, ch) )); + tasks.push(spawn_joinable(|move r| reduce_task(~r, kk, ch) )); c = recv(p); reducers.insert(k, c); } } ctrl = vec::append_one( - ctrls, + move ctrls, ctrl_proto::server::reducer(move_out!(cc), c)); } } diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs index f539045108e..6cd22b7f535 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs @@ -1,6 +1,6 @@ struct defer { x: &[&str], - drop { #error["%?", self.x]; } + drop { error!("%?", self.x); } } fn defer(x: &r/[&r/str]) -> defer/&r { diff --git a/src/test/compile-fail/borrowck-imm-field-imm-base.rs b/src/test/compile-fail/borrowck-imm-field-imm-base.rs new file mode 100644 index 00000000000..69ff3b10378 --- /dev/null +++ b/src/test/compile-fail/borrowck-imm-field-imm-base.rs @@ -0,0 +1,17 @@ +struct Foo { + x: uint +} + +struct Bar { + foo: Foo +} + +fn main() { + let mut b = Bar { foo: Foo { x: 3 } }; + let p = &b; //~ NOTE prior loan as immutable granted here + let q = &mut b.foo.x; //~ ERROR loan of mutable local variable as mutable conflicts with prior loan + let r = &p.foo.x; + io::println(fmt!("*r = %u", *r)); + *q += 1; + io::println(fmt!("*r = %u", *r)); +} \ No newline at end of file diff --git a/src/test/compile-fail/borrowck-imm-field-mut-base.rs b/src/test/compile-fail/borrowck-imm-field-mut-base.rs new file mode 100644 index 00000000000..6b9d93462d9 --- /dev/null +++ b/src/test/compile-fail/borrowck-imm-field-mut-base.rs @@ -0,0 +1,19 @@ +struct Foo { + mut x: uint +} + +struct Bar { + foo: Foo +} + +fn main() { + let mut b = Bar { foo: Foo { x: 3 } }; + let p = &b.foo.x; + let q = &mut b.foo; //~ ERROR loan of mutable field as mutable conflicts with prior loan + //~^ ERROR loan of mutable local variable as mutable conflicts with prior loan + let r = &mut b; //~ ERROR loan of mutable local variable as mutable conflicts with prior loan + io::println(fmt!("*p = %u", *p)); + q.x += 1; + r.foo.x += 1; + io::println(fmt!("*p = %u", *p)); +} \ No newline at end of file diff --git a/src/test/compile-fail/borrowck-loan-blocks-move.rs b/src/test/compile-fail/borrowck-loan-blocks-move.rs index 5cecbf9284f..e48756bbbeb 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move.rs @@ -4,7 +4,7 @@ fn take(-_v: ~int) { fn box_imm() { let v = ~3; let _w = &v; //~ NOTE loan of immutable local variable granted here - take(v); //~ ERROR moving out of immutable local variable prohibited due to outstanding loan + take(move v); //~ ERROR moving out of immutable local variable prohibited due to outstanding loan } fn main() { diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs new file mode 100644 index 00000000000..54048ed2fd8 --- /dev/null +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -0,0 +1,25 @@ +use core::either::{Either, Left, Right}; + + fn f(x: &mut Either<int,float>, y: &Either<int,float>) -> int { + match *y { + Left(ref z) => { + *x = Right(1.0); + *z + } + _ => fail + } + } + + fn g() { + let mut x: Either<int,float> = Left(3); + io::println(f(&mut x, &x).to_str()); //~ ERROR conflicts with prior loan + } + + fn h() { + let mut x: Either<int,float> = Left(3); + let y: &Either<int, float> = &x; + let z: &mut Either<int, float> = &mut x; //~ ERROR conflicts with prior loan + *z = *y; + } + + fn main() {} diff --git a/src/test/compile-fail/borrowck-mut-field-imm-base.rs b/src/test/compile-fail/borrowck-mut-field-imm-base.rs new file mode 100644 index 00000000000..f13637ab86a --- /dev/null +++ b/src/test/compile-fail/borrowck-mut-field-imm-base.rs @@ -0,0 +1,20 @@ +struct Foo { + mut x: uint +} + +struct Bar { + foo: Foo +} + +fn main() { + let mut b = Bar { foo: Foo { x: 3 } }; + let p = &b; + let q = &mut b.foo.x; + let r = &p.foo.x; //~ ERROR illegal borrow unless pure + let s = &b.foo.x; //~ ERROR loan of mutable field as immutable conflicts with prior loan + io::println(fmt!("*r = %u", *r)); + io::println(fmt!("*r = %u", *s)); + *q += 1; + io::println(fmt!("*r = %u", *r)); + io::println(fmt!("*r = %u", *s)); +} \ No newline at end of file diff --git a/src/test/compile-fail/borrowck-unary-move-2.rs b/src/test/compile-fail/borrowck-unary-move-2.rs index 303415e4663..1d1595383ee 100644 --- a/src/test/compile-fail/borrowck-unary-move-2.rs +++ b/src/test/compile-fail/borrowck-unary-move-2.rs @@ -1,5 +1,5 @@ struct noncopyable { - i: (), drop { #error["dropped"]; } + i: (), drop { error!("dropped"); } } fn noncopyable() -> noncopyable { @@ -13,4 +13,4 @@ enum wrapper = noncopyable; fn main() { let x1 = wrapper(noncopyable()); let _x2 = move *x1; //~ ERROR moving out of enum content -} \ No newline at end of file +} diff --git a/src/test/compile-fail/cap-clause-use-after-move.rs b/src/test/compile-fail/cap-clause-use-after-move.rs index 7fb06ba5a23..a19dfc9e9f4 100644 --- a/src/test/compile-fail/cap-clause-use-after-move.rs +++ b/src/test/compile-fail/cap-clause-use-after-move.rs @@ -1,7 +1,5 @@ -// error-pattern:Unsatisfied precondition constraint - fn main() { let x = 5; - let _y = fn~(move x) { }; - let _z = x; //< error: Unsatisfied precondition constraint + let _y = fn~(move x) { }; //~ WARNING captured variable `x` not used in closure + let _z = x; //~ ERROR use of moved variable: `x` } diff --git a/src/test/compile-fail/copy-into-closure.rs b/src/test/compile-fail/copy-into-closure.rs index 8ee2a4fd3ae..51e0934bfe0 100644 --- a/src/test/compile-fail/copy-into-closure.rs +++ b/src/test/compile-fail/copy-into-closure.rs @@ -4,7 +4,7 @@ fn closure1(+x: ~str) -> (~str, fn@() -> ~str) { //~^ WARNING implicitly copying a non-implicitly-copyable value //~^^ NOTE to copy values into a @fn closure, use a capture clause }; - (x,f) + (move x,f) } fn closure2(+x: util::NonCopyable) -> (util::NonCopyable, @@ -15,7 +15,7 @@ fn closure2(+x: util::NonCopyable) -> (util::NonCopyable, //~^^ NOTE non-copyable value cannot be copied into a @fn closure //~^^^ ERROR copying a noncopyable value }; - (x,f) + (move x,f) } fn closure3(+x: util::NonCopyable) { do task::spawn { diff --git a/src/test/compile-fail/duplicate-visibility.rs b/src/test/compile-fail/duplicate-visibility.rs new file mode 100644 index 00000000000..32997fcce31 --- /dev/null +++ b/src/test/compile-fail/duplicate-visibility.rs @@ -0,0 +1,4 @@ +// error-pattern:unmatched visibility `pub` +extern { + pub pub fn foo(); +} diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs index 7e3e29f2b8f..626e7eff3f7 100644 --- a/src/test/compile-fail/estr-subtyping.rs +++ b/src/test/compile-fail/estr-subtyping.rs @@ -1,29 +1,23 @@ fn wants_box(x: @str) { } fn wants_uniq(x: ~str) { } -fn wants_three(x: str/3) { } +fn wants_slice(x: &str) { } fn has_box(x: @str) { wants_box(x); wants_uniq(x); //~ ERROR str storage differs: expected ~ but found @ - wants_three(x); //~ ERROR str storage differs: expected 3 but found @ + wants_slice(x); } fn has_uniq(x: ~str) { wants_box(x); //~ ERROR str storage differs: expected @ but found ~ wants_uniq(x); - wants_three(x); //~ ERROR str storage differs: expected 3 but found ~ + wants_slice(x); } -fn has_three(x: str/3) { - wants_box(x); //~ ERROR str storage differs: expected @ but found 3 - wants_uniq(x); //~ ERROR str storage differs: expected ~ but found 3 - wants_three(x); -} - -fn has_four(x: str/4) { - wants_box(x); //~ ERROR str storage differs: expected @ but found 4 - wants_uniq(x); //~ ERROR str storage differs: expected ~ but found 4 - wants_three(x); //~ ERROR str storage differs: expected 3 but found 4 +fn has_slice(x: &str) { + wants_box(x); //~ ERROR str storage differs: expected @ but found & + wants_uniq(x); //~ ERROR str storage differs: expected ~ but found & + wants_slice(x); } fn main() { diff --git a/src/test/compile-fail/evec-subtyping.rs b/src/test/compile-fail/evec-subtyping.rs index 2eabfa0c48c..e5e9aa0c257 100644 --- a/src/test/compile-fail/evec-subtyping.rs +++ b/src/test/compile-fail/evec-subtyping.rs @@ -1,6 +1,6 @@ fn wants_box(x: @[uint]) { } fn wants_uniq(x: ~[uint]) { } -fn wants_three(x: [uint]/3) { } +fn wants_three(x: [uint * 3]) { } fn has_box(x: @[uint]) { wants_box(x); @@ -14,13 +14,13 @@ fn has_uniq(x: ~[uint]) { wants_three(x); //~ ERROR [] storage differs: expected 3 but found ~ } -fn has_three(x: [uint]/3) { +fn has_three(x: [uint * 3]) { wants_box(x); //~ ERROR [] storage differs: expected @ but found 3 wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3 wants_three(x); } -fn has_four(x: [uint]/4) { +fn has_four(x: [uint * 4]) { wants_box(x); //~ ERROR [] storage differs: expected @ but found 4 wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 4 wants_three(x); //~ ERROR [] storage differs: expected 3 but found 4 diff --git a/src/test/compile-fail/extenv-no-args.rs b/src/test/compile-fail/extenv-no-args.rs index e169db23bf2..1db0e0a39ee 100644 --- a/src/test/compile-fail/extenv-no-args.rs +++ b/src/test/compile-fail/extenv-no-args.rs @@ -1,3 +1,3 @@ -// error-pattern:#env takes between 1 and 1 arguments +// error-pattern: env! takes between 1 and 1 arguments fn main() { env!(); } diff --git a/src/test/compile-fail/extenv-too-many-args.rs b/src/test/compile-fail/extenv-too-many-args.rs index ee5b1b4af74..4f0df2a090f 100644 --- a/src/test/compile-fail/extenv-too-many-args.rs +++ b/src/test/compile-fail/extenv-too-many-args.rs @@ -1,3 +1,3 @@ -// error-pattern:#env takes between 1 and 1 arguments +// error-pattern: env! takes between 1 and 1 arguments fn main() { env!("one", "two"); } diff --git a/src/test/compile-fail/extfmt-no-args.rs b/src/test/compile-fail/extfmt-no-args.rs index b291fbae225..1cca7e5b315 100644 --- a/src/test/compile-fail/extfmt-no-args.rs +++ b/src/test/compile-fail/extfmt-no-args.rs @@ -1,3 +1,3 @@ -// error-pattern:#fmt needs at least 1 arguments +// error-pattern:fmt! needs at least 1 arguments fn main() { fmt!(); } diff --git a/src/test/compile-fail/extfmt-non-literal.rs b/src/test/compile-fail/extfmt-non-literal.rs index 0e2109fac4f..7255bd84631 100644 --- a/src/test/compile-fail/extfmt-non-literal.rs +++ b/src/test/compile-fail/extfmt-non-literal.rs @@ -1,7 +1,7 @@ // error-pattern: literal fn main() { - // #fmt's first argument must be a literal. Hopefully this + // fmt!'s first argument must be a literal. Hopefully this // restriction can be eased eventually to just require a // compile-time constant. let x = fmt!("a" + "b"); diff --git a/src/test/compile-fail/extfmt-non-literal2.rs b/src/test/compile-fail/extfmt-non-literal2.rs index cc10845fd9f..0196c37c68e 100644 --- a/src/test/compile-fail/extfmt-non-literal2.rs +++ b/src/test/compile-fail/extfmt-non-literal2.rs @@ -1,7 +1,7 @@ // error-pattern: literal fn main() { - // #fmt's first argument must be a literal. Hopefully this + // fmt!'s first argument must be a literal. Hopefully this // restriction can be eased eventually to just require a // compile-time constant. let x = fmt!(20); diff --git a/src/test/compile-fail/extfmt-unsigned-plus.rs b/src/test/compile-fail/extfmt-unsigned-plus.rs index d8a9f4fa98d..1dd3ed390d5 100644 --- a/src/test/compile-fail/extfmt-unsigned-plus.rs +++ b/src/test/compile-fail/extfmt-unsigned-plus.rs @@ -1,4 +1,4 @@ -// error-pattern:only valid in signed #fmt conversion +// error-pattern:only valid in signed fmt! conversion fn main() { // Can't use a sign on unsigned conversions diff --git a/src/test/compile-fail/extfmt-unsigned-space.rs b/src/test/compile-fail/extfmt-unsigned-space.rs index 001adb521cc..a2ac54bea7d 100644 --- a/src/test/compile-fail/extfmt-unsigned-space.rs +++ b/src/test/compile-fail/extfmt-unsigned-space.rs @@ -1,4 +1,4 @@ -// error-pattern:only valid in signed #fmt conversion +// error-pattern:only valid in signed fmt! conversion fn main() { // Can't use a space on unsigned conversions diff --git a/src/test/compile-fail/functional-struct-update.rs b/src/test/compile-fail/functional-struct-update.rs new file mode 100644 index 00000000000..8d7913a62fa --- /dev/null +++ b/src/test/compile-fail/functional-struct-update.rs @@ -0,0 +1,16 @@ +struct Bar { + x: int, + drop { io::println("Goodbye, cruel world"); } +} + +struct Foo { + x: int, + y: Bar +} + +fn main() { + let a = Foo { x: 1, y: Bar { x: 5 } }; + let c = Foo { x: 4, .. a}; //~ ERROR copying a noncopyable value + io::println(fmt!("%?", c)); +} + diff --git a/src/test/compile-fail/issue-1965.rs b/src/test/compile-fail/issue-1965.rs index 9742acba1e3..ee318d7b02c 100644 --- a/src/test/compile-fail/issue-1965.rs +++ b/src/test/compile-fail/issue-1965.rs @@ -2,6 +2,6 @@ fn test(-x: uint) {} fn main() { - let i = 3u; - for uint::range(0u, 10u) |_x| {test(i)} + let i = 3; + for uint::range(0, 10) |_x| {test(move i)} } diff --git a/src/test/compile-fail/issue-2074.rs b/src/test/compile-fail/issue-2074.rs new file mode 100644 index 00000000000..d911b7db3dd --- /dev/null +++ b/src/test/compile-fail/issue-2074.rs @@ -0,0 +1,12 @@ +// xfail-test +fn main() { + let one = fn@() -> uint { + enum r { a }; + return a as uint; + }; + let two = fn@() -> uint { + enum r { a }; + return a as uint; + }; + one(); two(); +} diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index 61cfabc40d2..0d491fc8834 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -21,7 +21,7 @@ fn main() { let mut res = foo(x); let mut v = ~[mut]; - v <- ~[mut res] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`) + v <- ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`) assert (v.len() == 2); } diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs index f4ccd901fb3..0f4a4804c75 100644 --- a/src/test/compile-fail/issue-2590.rs +++ b/src/test/compile-fail/issue-2590.rs @@ -10,7 +10,7 @@ trait parse { impl parser: parse { fn parse() -> ~[int] { - dvec::unwrap(move self.tokens) //~ ERROR illegal move from self + dvec::unwrap(move self.tokens) //~ ERROR moving out of immutable field } } diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs index 75e524e27ac..590ea5e0b7c 100644 --- a/src/test/compile-fail/issue-2766-a.rs +++ b/src/test/compile-fail/issue-2766-a.rs @@ -1,13 +1,13 @@ mod stream { #[legacy_exports]; - enum stream<T: Send> { send(T, server::stream<T>), } + enum Stream<T: Send> { send(T, server::Stream<T>), } mod server { #[legacy_exports]; - impl<T: Send> stream<T> { - fn recv() -> extern fn(+v: stream<T>) -> stream::stream<T> { + impl<T: Send> Stream<T> { + fn recv() -> extern fn(+v: Stream<T>) -> stream::Stream<T> { // resolve really should report just one error here. // Change the test case when it changes. - fn recv(+pipe: stream<T>) -> stream::stream<T> { //~ ERROR attempt to use a type argument out of scope + fn recv(+pipe: Stream<T>) -> stream::Stream<T> { //~ ERROR attempt to use a type argument out of scope //~^ ERROR use of undeclared type name //~^^ ERROR attempt to use a type argument out of scope //~^^^ ERROR use of undeclared type name @@ -16,7 +16,7 @@ mod stream { recv } } - type stream<T: Send> = pipes::RecvPacket<stream::stream<T>>; + type Stream<T: Send> = pipes::RecvPacket<stream::Stream<T>>; } } diff --git a/src/test/compile-fail/issue-2823.rs b/src/test/compile-fail/issue-2823.rs new file mode 100644 index 00000000000..fd2c1758458 --- /dev/null +++ b/src/test/compile-fail/issue-2823.rs @@ -0,0 +1,12 @@ +struct C { + x: int, + drop { + #error("dropping: %?", self.x); + } +} + +fn main() { + let c = C{ x: 2}; + let d = copy c; //~ ERROR copying a noncopyable value + #error("%?", d.x); +} \ No newline at end of file diff --git a/src/test/compile-fail/issue-3099-a.rs b/src/test/compile-fail/issue-3099-a.rs index 2721186585b..fee676ed5e2 100644 --- a/src/test/compile-fail/issue-3099-a.rs +++ b/src/test/compile-fail/issue-3099-a.rs @@ -1,5 +1,5 @@ enum a { b, c } -enum a { d, e } //~ ERROR Duplicate definition of type a +enum a { d, e } //~ ERROR duplicate definition of type a fn main() {} diff --git a/src/test/compile-fail/issue-3099-b.rs b/src/test/compile-fail/issue-3099-b.rs index 997bb9e2557..dc393eb7520 100644 --- a/src/test/compile-fail/issue-3099-b.rs +++ b/src/test/compile-fail/issue-3099-b.rs @@ -2,6 +2,6 @@ mod a {} #[legacy_exports] -mod a {} //~ ERROR Duplicate definition of module a +mod a {} //~ ERROR duplicate definition of type a fn main() {} diff --git a/src/test/compile-fail/issue-3099.rs b/src/test/compile-fail/issue-3099.rs index 4f3bd89e7ef..79212686130 100644 --- a/src/test/compile-fail/issue-3099.rs +++ b/src/test/compile-fail/issue-3099.rs @@ -1,11 +1,11 @@ fn a(x: ~str) -> ~str { - #fmt("First function with %s", x) + fmt!("First function with %s", x) } -fn a(x: ~str, y: ~str) -> ~str { //~ ERROR Duplicate definition of value a - #fmt("Second function with %s and %s", x, y) +fn a(x: ~str, y: ~str) -> ~str { //~ ERROR duplicate definition of value a + fmt!("Second function with %s and %s", x, y) } fn main() { - #info("Result: "); + info!("Result: "); } diff --git a/src/test/compile-fail/issue-3214.rs b/src/test/compile-fail/issue-3214.rs new file mode 100644 index 00000000000..7008f8c4ce2 --- /dev/null +++ b/src/test/compile-fail/issue-3214.rs @@ -0,0 +1,8 @@ +fn foo<T>() { + struct foo { + mut x: T, //~ ERROR attempt to use a type argument out of scope + //~^ ERROR use of undeclared type name + drop { } + } +} +fn main() { } diff --git a/src/test/compile-fail/issue-3521-2.rs b/src/test/compile-fail/issue-3521-2.rs new file mode 100644 index 00000000000..5af0417af04 --- /dev/null +++ b/src/test/compile-fail/issue-3521-2.rs @@ -0,0 +1,7 @@ +fn main() { + let foo = 100; + + const y: int = foo + 1; //~ ERROR: attempt to use a non-constant value in a constant + + log(error, y); +} diff --git a/src/test/compile-fail/issue-3521.rs b/src/test/compile-fail/issue-3521.rs new file mode 100644 index 00000000000..9ad483367fe --- /dev/null +++ b/src/test/compile-fail/issue-3521.rs @@ -0,0 +1,9 @@ +fn main() { + let foo = 100; + + enum Stuff { + Bar = foo //~ ERROR attempt to use a non-constant value in a constant + } + + log(error, Bar); +} diff --git a/src/test/compile-fail/issue-3668-2.rs b/src/test/compile-fail/issue-3668-2.rs new file mode 100644 index 00000000000..89c9e2b2e91 --- /dev/null +++ b/src/test/compile-fail/issue-3668-2.rs @@ -0,0 +1,5 @@ +fn f(x:int) { + const child: int = x + 1; //~ ERROR attempt to use a non-constant value in a constant +} + +fn main() {} diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs new file mode 100644 index 00000000000..6cbd64c6aa9 --- /dev/null +++ b/src/test/compile-fail/issue-3668.rs @@ -0,0 +1,13 @@ +struct P { child: Option<@mut P> } +trait PTrait { + fn getChildOption() -> Option<@P>; +} + +impl P: PTrait { + fn getChildOption() -> Option<@P> { + const childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant + fail; + } +} + +fn main() {} diff --git a/src/test/compile-fail/liveness-move-from-args.rs b/src/test/compile-fail/liveness-move-from-args.rs index 27e9d3b60dc..48f72dd0d3e 100644 --- a/src/test/compile-fail/liveness-move-from-args.rs +++ b/src/test/compile-fail/liveness-move-from-args.rs @@ -1,19 +1,19 @@ fn take(-_x: int) { } fn from_by_value_arg(++x: int) { - take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode + take(move x); //~ ERROR illegal move from argument `x`, which is not copy or move mode } fn from_by_ref_arg(&&x: int) { - take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode + take(move x); //~ ERROR illegal move from argument `x`, which is not copy or move mode } fn from_copy_arg(+x: int) { - take(x); + take(move x); } fn from_move_arg(-x: int) { - take(x); + take(move x); } fn main() { diff --git a/src/test/compile-fail/liveness-move-from-mode.rs b/src/test/compile-fail/liveness-move-from-mode.rs index a837d337f98..959bda4e583 100644 --- a/src/test/compile-fail/liveness-move-from-mode.rs +++ b/src/test/compile-fail/liveness-move-from-mode.rs @@ -4,7 +4,7 @@ fn main() { let x: int = 25; loop { - take(x); //~ ERROR use of moved variable: `x` + take(move x); //~ ERROR use of moved variable: `x` //~^ NOTE move of variable occurred here } } diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 8b2fef7cd35..473a133730a 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -54,5 +54,5 @@ struct r { } fn main() { let x = r { x: () }; - fn@() { copy x; }; //~ ERROR copying a noncopyable value + fn@(move x) { copy x; }; //~ ERROR copying a noncopyable value } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 5447c88e567..13952dbe3c1 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -9,7 +9,7 @@ enum _chan<T> = int; // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it fn test00_start(ch: _chan<int>, message: int, _count: int) { - send(ch, message); //~ NOTE move of variable occurred here + send(ch, move message); //~ NOTE move of variable occurred here log(debug, message); //~ ERROR use of moved variable: `message` } diff --git a/src/test/compile-fail/obsolete-syntax.rs b/src/test/compile-fail/obsolete-syntax.rs index 9f57e08cdb2..c8a8bd85961 100644 --- a/src/test/compile-fail/obsolete-syntax.rs +++ b/src/test/compile-fail/obsolete-syntax.rs @@ -56,4 +56,15 @@ fn obsolete_with() { //~^ ERROR obsolete syntax: with } +fn obsolete_fixed_length_vec() { + let foo: [int]/1; + //~^ ERROR obsolete syntax: fixed-length vector + foo = [1]/_; + //~^ ERROR obsolete syntax: fixed-length vector + let foo: [int]/1; + //~^ ERROR obsolete syntax: fixed-length vector + foo = [1]/1; + //~^ ERROR obsolete syntax: fixed-length vector +} + fn main() { } diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index dc2a43cc7db..b163006c50a 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -3,7 +3,7 @@ fn wants_static_fn(_x: &static/fn()) {} fn main() { let i = 3; do wants_static_fn { - #debug("i=%d", i); + debug!("i=%d", i); //~^ ERROR captured variable does not outlive the enclosing closure } } diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index 223665381da..e4913f7056e 100644 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ b/src/test/compile-fail/regions-glb-free-free.rs @@ -19,7 +19,7 @@ mod argparse { fn set_desc(self, s: &str) -> Flag { Flag { //~ ERROR cannot infer an appropriate lifetime name: self.name, - desc: s, + desc: s, //~ ERROR cannot infer an appropriate lifetime max_count: self.max_count, value: self.value } diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index 80a36945097..f5bd208f00f 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -5,7 +5,7 @@ extern mod core; -fn last<T: Copy>(v: ~[const T]) -> core::Option<T> { +fn last<T>(v: ~[const &T]) -> core::Option<T> { fail; } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index eea832c91a4..b31583724d2 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -3,5 +3,5 @@ fn f<T: Send>(_i: T) { fn main() { let i = ~@100; - f(i); //~ ERROR missing `send` + f(move i); //~ ERROR missing `send` } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index a47a8b76e56..a84c1397319 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -17,5 +17,5 @@ fn main() { let cat = ~"kitty"; let po = comm::Port(); //~ ERROR missing `send` let ch = comm::Chan(&po); //~ ERROR missing `send` - comm::send(ch, foo(42, @cat)); //~ ERROR missing `send` + comm::send(ch, foo(42, @(move cat))); //~ ERROR missing `send` } diff --git a/src/test/pretty/blank-lines.rs b/src/test/pretty/blank-lines.rs index 3ef46a721ae..d677577e442 100644 --- a/src/test/pretty/blank-lines.rs +++ b/src/test/pretty/blank-lines.rs @@ -1,5 +1,5 @@ // pp-exact -fn f() -> [int]/3 { +fn f() -> [int * 3] { let picard = 0; let data = 1; @@ -7,7 +7,7 @@ fn f() -> [int]/3 { let worf = 2; - let enterprise = [picard, data, worf]/_; + let enterprise = [picard, data, worf]; diff --git a/src/test/run-fail/doublefail.rs b/src/test/run-fail/doublefail.rs new file mode 100644 index 00000000000..37beb7b895e --- /dev/null +++ b/src/test/run-fail/doublefail.rs @@ -0,0 +1,5 @@ +//error-pattern:One +fn main() { + fail ~"One"; + fail ~"Two"; +} \ No newline at end of file diff --git a/src/test/run-fail/port-type.rs b/src/test/run-fail/port-type.rs index 30714413c53..9f2974d2cc2 100644 --- a/src/test/run-fail/port-type.rs +++ b/src/test/run-fail/port-type.rs @@ -12,7 +12,7 @@ fn echo<T: Send>(c: Chan<T>, oc: Chan<Chan<T>>) { send(oc, Chan(&p)); let x = recv(p); - send(c, x); + send(c, move x); } fn main() { fail ~"meep"; } diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index 0bea0f934f4..ca85aa97017 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -20,7 +20,7 @@ fn r(v: *int) -> r { fn main() unsafe { let i1 = ~0; let i1p = cast::reinterpret_cast(&i1); - cast::forget(i1); + cast::forget(move i1); let x = @r(i1p); failfn(); log(error, x); diff --git a/src/test/run-fail/unwind-move.rs b/src/test/run-fail/unwind-move.rs index 311cb52b134..995edbcc05b 100644 --- a/src/test/run-fail/unwind-move.rs +++ b/src/test/run-fail/unwind-move.rs @@ -1,9 +1,9 @@ // error-pattern:fail -fn f(-a: @int) { +fn f(-_a: @int) { fail; } fn main() { let a = @0; - f(a); + f(move a); } \ No newline at end of file diff --git a/src/test/run-pass/anon-trait-static-method.rs b/src/test/run-pass/anon-trait-static-method.rs new file mode 100644 index 00000000000..6c4e9abc5ff --- /dev/null +++ b/src/test/run-pass/anon-trait-static-method.rs @@ -0,0 +1,15 @@ +struct Foo { + x: int +} + +impl Foo { + static fn new() -> Foo { + Foo { x: 3 } + } +} + +fn main() { + let x = Foo::new(); + io::println(x.x.to_str()); +} + diff --git a/src/test/run-pass/anon_trait_static_method_exe.rs b/src/test/run-pass/anon_trait_static_method_exe.rs new file mode 100644 index 00000000000..052f95ed3b5 --- /dev/null +++ b/src/test/run-pass/anon_trait_static_method_exe.rs @@ -0,0 +1,13 @@ +// xfail-fast - check-fast doesn't understand aux-build +// aux-build:anon_trait_static_method_lib.rs + +extern mod anon_trait_static_method_lib; +use anon_trait_static_method_lib::Foo; + +fn main() { + let x = Foo::new(); + io::println(x.x.to_str()); +} + + + diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index e8aaf88374f..dc861829c11 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -12,7 +12,7 @@ fn f2(a: int, f: fn(int)) -> int { f(1); return a; } fn main() { let mut a = {mut x: 1}, b = 2, c = 3; - assert (f1(a, &mut b, c) == 6); + assert (f1(a, &mut b, move c) == 6); assert (a.x == 0); assert (b == 10); assert (f2(a.x, |x| a.x = 50 ) == 0); diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 4652212ce5f..16e7473fb78 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -39,7 +39,7 @@ fn main() { assert length::<int, &[int]>(x) == vec::len(x); // Now try it with a type that *needs* to be borrowed - let z = [0,1,2,3]/_; + let z = [0,1,2,3]; // Call a method for z.iterate() |y| { assert z[*y] == *y; } // Call a parameterized function diff --git a/src/test/run-pass/auto-ref-sliceable.rs b/src/test/run-pass/auto-ref-sliceable.rs index 48d83da74ad..a8e6832d33c 100644 --- a/src/test/run-pass/auto-ref-sliceable.rs +++ b/src/test/run-pass/auto-ref-sliceable.rs @@ -4,7 +4,7 @@ trait Pushable<T> { impl<T> ~[T]: Pushable<T> { fn push_val(&mut self, +t: T) { - self.push(t); + self.push(move t); } } diff --git a/src/test/run-pass/auto_serialize.rs b/src/test/run-pass/auto_serialize.rs index 3a07faa75c5..b63d1dcab7e 100644 --- a/src/test/run-pass/auto_serialize.rs +++ b/src/test/run-pass/auto_serialize.rs @@ -1,6 +1,3 @@ -// xfail-fast -#[legacy_modes]; - extern mod std; // These tests used to be separate files, but I wanted to refactor all @@ -9,200 +6,178 @@ extern mod std; use cmp::Eq; use std::ebml; use io::Writer; -use std::serialization::{serialize_uint, deserialize_uint}; - -fn test_ser_and_deser<A:Eq>(a1: A, - expected: ~str, - ebml_ser_fn: fn(ebml::Writer, A), - ebml_deser_fn: fn(ebml::EbmlDeserializer) -> A, - io_ser_fn: fn(io::Writer, A)) { - - // check the pretty printer: - io_ser_fn(io::stdout(), a1); - let s = io::with_str_writer(|w| io_ser_fn(w, a1) ); +use std::serialization::{Serializable, Deserializable, deserialize}; +use std::prettyprint; + +fn test_prettyprint<A: Serializable<prettyprint::Serializer>>( + a: &A, + expected: &~str +) { + let s = do io::with_str_writer |w| { + a.serialize(&prettyprint::Serializer(w)) + }; debug!("s == %?", s); - assert s == expected; + assert s == *expected; +} - // check the EBML serializer: +fn test_ebml<A: + Eq + Serializable<ebml::Serializer> + Deserializable<ebml::Deserializer> +>(a1: &A) { let bytes = do io::with_bytes_writer |wr| { - let w = ebml::Writer(wr); - ebml_ser_fn(w, a1); + let ebml_w = &ebml::Serializer(wr); + a1.serialize(ebml_w) }; let d = ebml::Doc(@bytes); - let a2 = ebml_deser_fn(ebml::ebml_deserializer(d)); - io::print(~"\na1 = "); - io_ser_fn(io::stdout(), a1); - io::print(~"\na2 = "); - io_ser_fn(io::stdout(), a2); - io::print(~"\n"); - assert a1 == a2; - + let a2: A = deserialize(&ebml::Deserializer(d)); + assert *a1 == a2; } #[auto_serialize] -enum expr { - val(uint), - plus(@expr, @expr), - minus(@expr, @expr) +#[auto_deserialize] +enum Expr { + Val(uint), + Plus(@Expr, @Expr), + Minus(@Expr, @Expr) } -impl an_enum : cmp::Eq { - pure fn eq(other: &an_enum) -> bool { - self.v == (*other).v - } - pure fn ne(other: &an_enum) -> bool { !self.eq(other) } -} - -impl point : cmp::Eq { - pure fn eq(other: &point) -> bool { - self.x == (*other).x && self.y == (*other).y - } - pure fn ne(other: &point) -> bool { !self.eq(other) } -} - -impl<T:cmp::Eq> quark<T> : cmp::Eq { - pure fn eq(other: &quark<T>) -> bool { +impl Expr : cmp::Eq { + pure fn eq(other: &Expr) -> bool { match self { - top(ref q) => match (*other) { - top(ref r) => q == r, - bottom(_) => false - }, - bottom(ref q) => match (*other) { - top(_) => false, - bottom(ref r) => q == r - } + Val(e0a) => { + match *other { + Val(e0b) => e0a == e0b, + _ => false + } + } + Plus(e0a, e1a) => { + match *other { + Plus(e0b, e1b) => e0a == e0b && e1a == e1b, + _ => false + } + } + Minus(e0a, e1a) => { + match *other { + Minus(e0b, e1b) => e0a == e0b && e1a == e1b, + _ => false + } + } } } - pure fn ne(other: &quark<T>) -> bool { !self.eq(other) } + pure fn ne(other: &Expr) -> bool { !self.eq(other) } } +impl AnEnum : cmp::Eq { + pure fn eq(other: &AnEnum) -> bool { + self.v == other.v + } + pure fn ne(other: &AnEnum) -> bool { !self.eq(other) } +} -impl c_like : cmp::Eq { - pure fn eq(other: &c_like) -> bool { - self as int == (*other) as int +impl Point : cmp::Eq { + pure fn eq(other: &Point) -> bool { + self.x == other.x && self.y == other.y } - pure fn ne(other: &c_like) -> bool { !self.eq(other) } + pure fn ne(other: &Point) -> bool { !self.eq(other) } } -impl expr : cmp::Eq { - pure fn eq(other: &expr) -> bool { +impl<T:cmp::Eq> Quark<T> : cmp::Eq { + pure fn eq(other: &Quark<T>) -> bool { match self { - val(e0a) => { - match (*other) { - val(e0b) => e0a == e0b, - _ => false + Top(ref q) => { + match *other { + Top(ref r) => q == r, + Bottom(_) => false } - } - plus(e0a, e1a) => { - match (*other) { - plus(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - minus(e0a, e1a) => { - match (*other) { - minus(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false + }, + Bottom(ref q) => { + match *other { + Top(_) => false, + Bottom(ref r) => q == r } - } + }, } } - pure fn ne(other: &expr) -> bool { !self.eq(other) } + pure fn ne(other: &Quark<T>) -> bool { !self.eq(other) } } -#[auto_serialize] -type spanned<T> = {lo: uint, hi: uint, node: T}; - -impl<T:cmp::Eq> spanned<T> : cmp::Eq { - pure fn eq(other: &spanned<T>) -> bool { - self.lo == (*other).lo && self.hi == (*other).hi && - self.node.eq(&(*other).node) +impl CLike : cmp::Eq { + pure fn eq(other: &CLike) -> bool { + self as int == *other as int } - pure fn ne(other: &spanned<T>) -> bool { !self.eq(other) } + pure fn ne(other: &CLike) -> bool { !self.eq(other) } } #[auto_serialize] -type spanned_uint = spanned<uint>; +#[auto_deserialize] +type Spanned<T> = {lo: uint, hi: uint, node: T}; -#[auto_serialize] -type some_rec = {v: uint_vec}; +impl<T:cmp::Eq> Spanned<T> : cmp::Eq { + pure fn eq(other: &Spanned<T>) -> bool { + self.lo == other.lo && self.hi == other.hi && self.node == other.node + } + pure fn ne(other: &Spanned<T>) -> bool { !self.eq(other) } +} #[auto_serialize] -enum an_enum = some_rec; +#[auto_deserialize] +type SomeRec = {v: ~[uint]}; #[auto_serialize] -type uint_vec = ~[uint]; +#[auto_deserialize] +enum AnEnum = SomeRec; #[auto_serialize] -type point = {x: uint, y: uint}; +#[auto_deserialize] +struct Point {x: uint, y: uint} #[auto_serialize] -enum quark<T> { - top(T), - bottom(T) +#[auto_deserialize] +enum Quark<T> { + Top(T), + Bottom(T) } #[auto_serialize] -type uint_quark = quark<uint>; - -#[auto_serialize] -enum c_like { a, b, c } +#[auto_deserialize] +enum CLike { A, B, C } fn main() { - - test_ser_and_deser(plus(@minus(@val(3u), @val(10u)), - @plus(@val(22u), @val(5u))), - ~"plus(@minus(@val(3u), @val(10u)), \ - @plus(@val(22u), @val(5u)))", - serialize_expr, - deserialize_expr, - serialize_expr); - - test_ser_and_deser({lo: 0u, hi: 5u, node: 22u}, - ~"{lo: 0u, hi: 5u, node: 22u}", - serialize_spanned_uint, - deserialize_spanned_uint, - serialize_spanned_uint); - - test_ser_and_deser(an_enum({v: ~[1u, 2u, 3u]}), - ~"an_enum({v: [1u, 2u, 3u]})", - serialize_an_enum, - deserialize_an_enum, - serialize_an_enum); - - test_ser_and_deser({x: 3u, y: 5u}, - ~"{x: 3u, y: 5u}", - serialize_point, - deserialize_point, - serialize_point); - - test_ser_and_deser(~[1u, 2u, 3u], - ~"[1u, 2u, 3u]", - serialize_uint_vec, - deserialize_uint_vec, - serialize_uint_vec); - - test_ser_and_deser(top(22u), - ~"top(22u)", - serialize_uint_quark, - deserialize_uint_quark, - serialize_uint_quark); - - test_ser_and_deser(bottom(222u), - ~"bottom(222u)", - serialize_uint_quark, - deserialize_uint_quark, - serialize_uint_quark); - - test_ser_and_deser(a, - ~"a", - serialize_c_like, - deserialize_c_like, - serialize_c_like); - - test_ser_and_deser(b, - ~"b", - serialize_c_like, - deserialize_c_like, - serialize_c_like); + let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u))); + test_prettyprint(a, &~"Plus(@Minus(@Val(3u), @Val(10u)), \ + @Plus(@Val(22u), @Val(5u)))"); + test_ebml(a); + + let a = &{lo: 0u, hi: 5u, node: 22u}; + test_prettyprint(a, &~"{lo: 0u, hi: 5u, node: 22u}"); + test_ebml(a); + + let a = &AnEnum({v: ~[1u, 2u, 3u]}); + test_prettyprint(a, &~"AnEnum({v: ~[1u, 2u, 3u]})"); + test_ebml(a); + + let a = &Point {x: 3u, y: 5u}; + test_prettyprint(a, &~"Point {x: 3u, y: 5u}"); + test_ebml(a); + + let a = &@[1u, 2u, 3u]; + test_prettyprint(a, &~"@[1u, 2u, 3u]"); + test_ebml(a); + + let a = &Top(22u); + test_prettyprint(a, &~"Top(22u)"); + test_ebml(a); + + let a = &Bottom(222u); + test_prettyprint(a, &~"Bottom(222u)"); + test_ebml(a); + + let a = &A; + test_prettyprint(a, &~"A"); + test_ebml(a); + + let a = &B; + test_prettyprint(a, &~"B"); + test_ebml(a); } diff --git a/src/test/run-pass/auto_serialize2.rs b/src/test/run-pass/auto_serialize2.rs deleted file mode 100644 index 4503ea6c7e0..00000000000 --- a/src/test/run-pass/auto_serialize2.rs +++ /dev/null @@ -1,163 +0,0 @@ -extern mod std; - -// These tests used to be separate files, but I wanted to refactor all -// the common code. - -use cmp::Eq; -use std::ebml2; -use io::Writer; -use std::serialization2::{Serializable, Deserializable, deserialize}; -use std::prettyprint2; - -fn test_ser_and_deser<A:Eq Serializable Deserializable>( - a1: &A, - +expected: ~str -) { - // check the pretty printer: - let s = do io::with_str_writer |w| { - a1.serialize(&prettyprint2::Serializer(w)) - }; - debug!("s == %?", s); - assert s == expected; - - // check the EBML serializer: - let bytes = do io::with_bytes_writer |wr| { - let ebml_w = &ebml2::Serializer(wr); - a1.serialize(ebml_w) - }; - let d = ebml2::Doc(@bytes); - let a2: A = deserialize(&ebml2::Deserializer(d)); - assert *a1 == a2; -} - -#[auto_serialize2] -#[auto_deserialize2] -enum Expr { - Val(uint), - Plus(@Expr, @Expr), - Minus(@Expr, @Expr) -} - -impl Expr : cmp::Eq { - pure fn eq(other: &Expr) -> bool { - match self { - Val(e0a) => { - match *other { - Val(e0b) => e0a == e0b, - _ => false - } - } - Plus(e0a, e1a) => { - match *other { - Plus(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - Minus(e0a, e1a) => { - match *other { - Minus(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - } - } - pure fn ne(other: &Expr) -> bool { !self.eq(other) } -} - -impl AnEnum : cmp::Eq { - pure fn eq(other: &AnEnum) -> bool { - self.v == other.v - } - pure fn ne(other: &AnEnum) -> bool { !self.eq(other) } -} - -impl Point : cmp::Eq { - pure fn eq(other: &Point) -> bool { - self.x == other.x && self.y == other.y - } - pure fn ne(other: &Point) -> bool { !self.eq(other) } -} - -impl<T:cmp::Eq> Quark<T> : cmp::Eq { - pure fn eq(other: &Quark<T>) -> bool { - match self { - Top(ref q) => { - match *other { - Top(ref r) => q == r, - Bottom(_) => false - } - }, - Bottom(ref q) => { - match *other { - Top(_) => false, - Bottom(ref r) => q == r - } - }, - } - } - pure fn ne(other: &Quark<T>) -> bool { !self.eq(other) } -} - -impl CLike : cmp::Eq { - pure fn eq(other: &CLike) -> bool { - self as int == *other as int - } - pure fn ne(other: &CLike) -> bool { !self.eq(other) } -} - -#[auto_serialize2] -#[auto_deserialize2] -type Spanned<T> = {lo: uint, hi: uint, node: T}; - -impl<T:cmp::Eq> Spanned<T> : cmp::Eq { - pure fn eq(other: &Spanned<T>) -> bool { - self.lo == other.lo && self.hi == other.hi && self.node == other.node - } - pure fn ne(other: &Spanned<T>) -> bool { !self.eq(other) } -} - -#[auto_serialize2] -#[auto_deserialize2] -type SomeRec = {v: ~[uint]}; - -#[auto_serialize2] -#[auto_deserialize2] -enum AnEnum = SomeRec; - -#[auto_serialize2] -#[auto_deserialize2] -struct Point {x: uint, y: uint} - -#[auto_serialize2] -#[auto_deserialize2] -enum Quark<T> { - Top(T), - Bottom(T) -} - -#[auto_serialize2] -#[auto_deserialize2] -enum CLike { A, B, C } - -fn main() { - test_ser_and_deser(&Plus(@Minus(@Val(3u), @Val(10u)), - @Plus(@Val(22u), @Val(5u))), - ~"Plus(@Minus(@Val(3u), @Val(10u)), \ - @Plus(@Val(22u), @Val(5u)))"); - - test_ser_and_deser(&{lo: 0u, hi: 5u, node: 22u}, - ~"{lo: 0u, hi: 5u, node: 22u}"); - - test_ser_and_deser(&AnEnum({v: ~[1u, 2u, 3u]}), - ~"AnEnum({v: ~[1u, 2u, 3u]})"); - - test_ser_and_deser(&Point {x: 3u, y: 5u}, ~"Point {x: 3u, y: 5u}"); - - test_ser_and_deser(&@[1u, 2u, 3u], ~"@[1u, 2u, 3u]"); - - test_ser_and_deser(&Top(22u), ~"Top(22u)"); - test_ser_and_deser(&Bottom(222u), ~"Bottom(222u)"); - - test_ser_and_deser(&A, ~"A"); - test_ser_and_deser(&B, ~"B"); -} diff --git a/src/test/run-pass/borrowck-fixed-length-vecs.rs b/src/test/run-pass/borrowck-fixed-length-vecs.rs index 9d79e28b219..22862d7e58f 100644 --- a/src/test/run-pass/borrowck-fixed-length-vecs.rs +++ b/src/test/run-pass/borrowck-fixed-length-vecs.rs @@ -1,5 +1,5 @@ fn main() { - let x = [22]/1; + let x = [22]; let y = &x[0]; assert *y == 22; -} \ No newline at end of file +} diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index c7517ab1b3d..8a51eb33857 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -45,7 +45,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } impl cat: ToStr { - fn to_str() -> ~str { self.name } + pure fn to_str() -> ~str { self.name } } fn print_out<T: ToStr>(thing: T, expected: ~str) { diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index 387ca032f6a..a5bcfc93c79 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -1,4 +1,4 @@ -const x : [int]/4 = [1,2,3,4]; +const x : [int * 4] = [1,2,3,4]; const p : int = x[2]; const y : &[int] = &[1,2,3,4]; const q : int = y[2]; @@ -17,4 +17,4 @@ fn main() { assert p == 3; assert q == 3; assert t == 20; -} \ No newline at end of file +} diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index 9cfee2d5dff..36327172fab 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -1,4 +1,4 @@ -const x : [int]/4 = [1,2,3,4]; +const x : [int * 4] = [1,2,3,4]; const y : &[int] = &[1,2,3,4]; fn main() { @@ -7,4 +7,4 @@ fn main() { assert x[1] == 2; assert x[3] == 4; assert x[3] == y[3]; -} \ No newline at end of file +} diff --git a/src/test/run-pass/default-method-simple.rs b/src/test/run-pass/default-method-simple.rs new file mode 100644 index 00000000000..6a05d958913 --- /dev/null +++ b/src/test/run-pass/default-method-simple.rs @@ -0,0 +1,23 @@ +trait Foo { + fn f() { + io::println("Hello!"); + self.g(); + } + fn g(); +} + +struct A { + x: int +} + +impl A : Foo { + fn g() { + io::println("Goodbye!"); + } +} + +fn main() { + let a = A { x: 1 }; + a.f(); +} + diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 2bbbbf7ef17..002d8b27ca7 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -10,7 +10,7 @@ fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() } fn main() { for iter::eachi(&(Some({a: 0}))) |i, a| { - #debug["%u %d", i, a.a]; + debug!("%u %d", i, a.a); } let _x: Option<float> = foo_func(0); diff --git a/src/test/run-pass/evec-internal-boxes.rs b/src/test/run-pass/evec-internal-boxes.rs index ce0fe172cf8..5ad12510b38 100644 --- a/src/test/run-pass/evec-internal-boxes.rs +++ b/src/test/run-pass/evec-internal-boxes.rs @@ -1,7 +1,7 @@ fn main() { - let x : [@int]/5 = [@1,@2,@3,@4,@5]/5; - let _y : [@int]/5 = [@1,@2,@3,@4,@5]/_; - let mut z = [@1,@2,@3,@4,@5]/_; + let x : [@int * 5] = [@1,@2,@3,@4,@5]; + let _y : [@int * 5] = [@1,@2,@3,@4,@5]; + let mut z = [@1,@2,@3,@4,@5]; z = x; assert *z[0] == 1; assert *z[4] == 5; diff --git a/src/test/run-pass/evec-internal.rs b/src/test/run-pass/evec-internal.rs index 789660c11f0..7ee72272e0b 100644 --- a/src/test/run-pass/evec-internal.rs +++ b/src/test/run-pass/evec-internal.rs @@ -4,16 +4,16 @@ // Doesn't work; needs a design decision. fn main() { - let x : [int]/5 = [1,2,3,4,5]/5; - let _y : [int]/5 = [1,2,3,4,5]/_; - let mut z = [1,2,3,4,5]/_; + let x : [int * 5] = [1,2,3,4,5]; + let _y : [int * 5] = [1,2,3,4,5]; + let mut z = [1,2,3,4,5]; z = x; assert z[0] == 1; assert z[4] == 5; - let a : [int]/5 = [1,1,1,1,1]/_; - let b : [int]/5 = [2,2,2,2,2]/_; - let c : [int]/5 = [2,2,2,2,3]/_; + let a : [int * 5] = [1,1,1,1,1]; + let b : [int * 5] = [2,2,2,2,2]; + let c : [int * 5] = [2,2,2,2,3]; log(debug, a); diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index 5bf6eb9a44d..ca42fc35f2b 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -3,7 +3,7 @@ // are implicitly copyable #[deny(implicit_copies)] fn main() { - let arr = [1,2,3]/3; + let arr = [1,2,3]; let arr2 = arr; assert(arr[1] == 2); assert(arr2[2] == 3); diff --git a/src/test/run-pass/fixed_length_vec_glue.rs b/src/test/run-pass/fixed_length_vec_glue.rs index 8be0b1b0c43..d9488c5abd8 100644 --- a/src/test/run-pass/fixed_length_vec_glue.rs +++ b/src/test/run-pass/fixed_length_vec_glue.rs @@ -1,5 +1,5 @@ fn main() { - let arr = [1,2,3]/3; + let arr = [1,2,3]; let struc = {a: 13u8, b: arr, c: 42}; let s = sys::log_str(&struc); assert(s == ~"{ a: 13, b: [ 1, 2, 3 ], c: 42 }"); diff --git a/src/test/run-pass/fn-bare-spawn.rs b/src/test/run-pass/fn-bare-spawn.rs index 2655b0260fd..f50d74a2df2 100644 --- a/src/test/run-pass/fn-bare-spawn.rs +++ b/src/test/run-pass/fn-bare-spawn.rs @@ -1,7 +1,7 @@ // This is what the signature to spawn should look like with bare functions fn spawn<T: Send>(val: T, f: extern fn(T)) { - f(val); + f(move val); } fn f(+i: int) { diff --git a/src/test/run-pass/functional-struct-update.rs b/src/test/run-pass/functional-struct-update.rs index ce6198c8d24..e95027a4246 100644 --- a/src/test/run-pass/functional-struct-update.rs +++ b/src/test/run-pass/functional-struct-update.rs @@ -5,7 +5,7 @@ struct Foo { fn main() { let a = Foo { x: 1, y: 2 }; - let c = Foo { x: 4, .. a }; + let c = Foo { x: 4, .. a}; io::println(fmt!("%?", c)); } diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index 683321aac3d..e32656894a8 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -8,6 +8,6 @@ extern mod rusti { fn main() { let mut x = @1; let mut y = @2; - rusti::move_val(&mut y, x); + rusti::move_val(&mut y, move x); assert *y == 1; } \ No newline at end of file diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 3b3b63308cd..cda85fb166a 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -28,7 +28,7 @@ fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { do self.iter |a| { b <- blk(b, a); } - return b; + move b } fn range(lo: uint, hi: uint, it: fn(uint)) { diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs new file mode 100644 index 00000000000..11815db1763 --- /dev/null +++ b/src/test/run-pass/issue-2216.rs @@ -0,0 +1,22 @@ +fn main() { + let mut x = 0; + + loop foo: { + loop bar: { + loop quux: { + if 1 == 2 { + break foo; + } + else { + break bar; + } + } + loop foo; + } + x = 42; + break; + } + + error!("%?", x); + assert(x == 42); +} \ No newline at end of file diff --git a/src/test/run-pass/issue-2284.rs b/src/test/run-pass/issue-2284.rs new file mode 100644 index 00000000000..c2c4c03fb8f --- /dev/null +++ b/src/test/run-pass/issue-2284.rs @@ -0,0 +1,10 @@ +trait Send { + fn f(); +} + +fn f<T: Send>(t: T) { + t.f(); +} + +fn main() { +} \ No newline at end of file diff --git a/src/test/run-pass/issue-2428.rs b/src/test/run-pass/issue-2428.rs new file mode 100644 index 00000000000..76fc674e734 --- /dev/null +++ b/src/test/run-pass/issue-2428.rs @@ -0,0 +1,10 @@ +fn main() { + let foo = 100; + const quux: int = 5; + + enum Stuff { + Bar = quux + } + + assert (Bar as int == quux); +} diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index b887b86cf2f..e91194b009a 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -1,3 +1,5 @@ +// tjc: I don't know why +// xfail-pretty mod pipes { #[legacy_exports]; use cast::{forget, transmute}; @@ -42,18 +44,18 @@ mod pipes { // We should consider moving this to core::unsafe, although I // suspect graydon would want us to use void pointers instead. unsafe fn uniquify<T>(+x: *T) -> ~T { - unsafe { cast::transmute(x) } + unsafe { cast::transmute(move x) } } fn swap_state_acq(+dst: &mut state, src: state) -> state { unsafe { - transmute(rusti::atomic_xchg_acq(transmute(dst), src as int)) + transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int)) } } fn swap_state_rel(+dst: &mut state, src: state) -> state { unsafe { - transmute(rusti::atomic_xchg_rel(transmute(dst), src as int)) + transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int)) } } @@ -61,20 +63,20 @@ mod pipes { let p = p.unwrap(); let p = unsafe { uniquify(p) }; assert (*p).payload.is_none(); - (*p).payload <- Some(payload); + (*p).payload <- Some(move payload); let old_state = swap_state_rel(&mut (*p).state, full); match old_state { empty => { // Yay, fastpath. // The receiver will eventually clean this up. - unsafe { forget(p); } + unsafe { forget(move p); } } full => { fail ~"duplicate send" } blocked => { // The receiver will eventually clean this up. - unsafe { forget(p); } + unsafe { forget(move p); } } terminated => { // The receiver will never receive this. Rely on drop_glue @@ -94,7 +96,7 @@ mod pipes { full => { let mut payload = None; payload <-> (*p).payload; - return Some(option::unwrap(payload)) + return Some(option::unwrap(move payload)) } terminated => { assert old_state == terminated; @@ -109,7 +111,7 @@ mod pipes { match swap_state_rel(&mut (*p).state, terminated) { empty | blocked => { // The receiver will eventually clean up. - unsafe { forget(p) } + unsafe { forget(move p) } } full => { // This is impossible @@ -126,7 +128,7 @@ mod pipes { match swap_state_rel(&mut (*p).state, terminated) { empty => { // the sender will clean up - unsafe { forget(p) } + unsafe { forget(move p) } } blocked => { // this shouldn't happen. @@ -144,7 +146,7 @@ mod pipes { if self.p != None { let mut p = None; p <-> self.p; - sender_terminate(option::unwrap(p)) + sender_terminate(option::unwrap(move p)) } } } @@ -153,7 +155,7 @@ mod pipes { fn unwrap() -> *packet<T> { let mut p = None; p <-> self.p; - option::unwrap(p) + option::unwrap(move p) } } @@ -169,7 +171,7 @@ mod pipes { if self.p != None { let mut p = None; p <-> self.p; - receiver_terminate(option::unwrap(p)) + receiver_terminate(option::unwrap(move p)) } } } @@ -178,7 +180,7 @@ mod pipes { fn unwrap() -> *packet<T> { let mut p = None; p <-> self.p; - option::unwrap(p) + option::unwrap(move p) } } @@ -204,8 +206,8 @@ mod pingpong { ping(x) => { cast::transmute(ptr::addr_of(&x)) } }; let liberated_value <- *addr; - cast::forget(p); - liberated_value + cast::forget(move p); + move liberated_value } fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe { @@ -213,8 +215,8 @@ mod pingpong { pong(x) => { cast::transmute(ptr::addr_of(&x)) } }; let liberated_value <- *addr; - cast::forget(p); - liberated_value + cast::forget(move p); + move liberated_value } fn init() -> (client::ping, server::ping) { @@ -229,16 +231,16 @@ mod pingpong { fn do_ping(-c: ping) -> pong { let (sp, rp) = pipes::entangle(); - pipes::send(c, ping(sp)); - rp + pipes::send(move c, ping(move sp)); + move rp } fn do_pong(-c: pong) -> (ping, ()) { - let packet = pipes::recv(c); + let packet = pipes::recv(move c); if packet.is_none() { fail ~"sender closed the connection" } - (liberate_pong(option::unwrap(packet)), ()) + (liberate_pong(option::unwrap(move packet)), ()) } } @@ -248,32 +250,32 @@ mod pingpong { type pong = pipes::send_packet<pingpong::pong>; fn do_ping(-c: ping) -> (pong, ()) { - let packet = pipes::recv(c); + let packet = pipes::recv(move c); if packet.is_none() { fail ~"sender closed the connection" } - (liberate_ping(option::unwrap(packet)), ()) + (liberate_ping(option::unwrap(move packet)), ()) } fn do_pong(-c: pong) -> ping { let (sp, rp) = pipes::entangle(); - pipes::send(c, pong(sp)); - rp + pipes::send(move c, pong(move sp)); + move rp } } } fn client(-chan: pingpong::client::ping) { - let chan = pingpong::client::do_ping(chan); + let chan = pingpong::client::do_ping(move chan); log(error, ~"Sent ping"); - let (chan, _data) = pingpong::client::do_pong(chan); + let (_chan, _data) = pingpong::client::do_pong(move chan); log(error, ~"Received pong"); } fn server(-chan: pingpong::server::ping) { - let (chan, _data) = pingpong::server::do_ping(chan); + let (chan, _data) = pingpong::server::do_ping(move chan); log(error, ~"Received ping"); - let chan = pingpong::server::do_pong(chan); + let _chan = pingpong::server::do_pong(move chan); log(error, ~"Sent pong"); } diff --git a/src/test/run-pass/issue-2834.rs b/src/test/run-pass/issue-2834.rs index b61169ee5f6..096ee2eed48 100644 --- a/src/test/run-pass/issue-2834.rs +++ b/src/test/run-pass/issue-2834.rs @@ -9,7 +9,7 @@ proto! streamp ( fn rendezvous() { let (c, s) = streamp::init(); - let streams: ~[streamp::client::open<int>] = ~[c]; + let streams: ~[streamp::client::open<int>] = ~[move c]; error!("%?", streams[0]); } diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs new file mode 100644 index 00000000000..1765e8638a6 --- /dev/null +++ b/src/test/run-pass/issue-2895.rs @@ -0,0 +1,23 @@ +use sys::size_of; +extern mod std; + +struct Cat { + x: int +} + +struct Kitty { + x: int, + drop {} +} + +#[cfg(target_arch = "x86_64")] +fn main() { + assert (size_of::<Cat>() == 8 as uint); + assert (size_of::<Kitty>() == 16 as uint); +} + +#[cfg(target_arch = "x86")] +fn main() { + assert (size_of::<Cat>() == 4 as uint); + assert (size_of::<Kitty>() == 8 as uint); +} diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 6d771dc7386..5cc39f4d683 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -16,7 +16,7 @@ enum square { } impl square: to_str::ToStr { - fn to_str() -> ~str { + pure fn to_str() -> ~str { match self { bot => { ~"R" } wall => { ~"#" } @@ -41,14 +41,14 @@ fn square_from_char(c: char) -> square { '.' => { earth } ' ' => { empty } _ => { - #error("invalid square: %?", c); + error!("invalid square: %?", c); fail } } } fn read_board_grid<rdr: Owned io::Reader>(+in: rdr) -> ~[~[square]] { - let in = in as io::Reader; + let in = (move in) as io::Reader; let mut grid = ~[]; for in.each_line |line| { let mut row = ~[]; diff --git a/src/test/run-pass/issue-2930.rs b/src/test/run-pass/issue-2930.rs index 98cfaded04a..bccaeeaf18d 100644 --- a/src/test/run-pass/issue-2930.rs +++ b/src/test/run-pass/issue-2930.rs @@ -1,11 +1,11 @@ proto! stream ( - stream:send<T:Send> { - send(T) -> stream<T> + Stream:send<T:Send> { + send(T) -> Stream<T> } ) fn main() { let (bc, _bp) = stream::init(); - stream::client::send(bc, ~"abc"); + stream::client::send(move bc, ~"abc"); } diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 855f5caf9a0..86ba11560b2 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -19,6 +19,6 @@ fn main() { // x.f(); // y.f(); // (*z).f(); - #error["ok so far..."]; + error!("ok so far..."); z.f(); //segfault } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index 0dd383e4039..0cabe1adb28 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -26,8 +26,8 @@ fn main() { let bools2 = to_bools({storage: ~[0b01100100]}); for uint::range(0, 8) |i| { - io::println(#fmt("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint)); + io::println(fmt!("%u => %u vs %u", i, bools[i] as uint, bools2[i] as uint)); } assert bools == bools2; -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs index 0da0ade0892..44a96a276ea 100644 --- a/src/test/run-pass/issue-3168.rs +++ b/src/test/run-pass/issue-3168.rs @@ -2,20 +2,20 @@ fn main() { let (c,p) = pipes::stream(); - do task::try { + do task::try |move c| { let (c2,p2) = pipes::stream(); - do task::spawn { + do task::spawn |move p2| { p2.recv(); - #error["brother fails"]; + error!("sibling fails"); fail; } let (c3,p3) = pipes::stream(); - c.send(c3); + c.send(move c3); c2.send(()); - #error["child blocks"]; + error!("child blocks"); p3.recv(); }; - #error["parent tries"]; + error!("parent tries"); assert !p.recv().try_send(()); - #error("all done!"); + error!("all done!"); } diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs index 002c7d4c518..17e6c03c954 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -4,22 +4,22 @@ use pipes::{Select2, Selectable}; fn main() { let (c,p) = pipes::stream(); - do task::try { + do task::try |move c| { let (c2,p2) = pipes::stream(); - do task::spawn { + do task::spawn |move p2| { p2.recv(); - #error["brother fails"]; + error!("sibling fails"); fail; } let (c3,p3) = pipes::stream(); - c.send(c3); + c.send(move c3); c2.send(()); - #error["child blocks"]; + error!("child blocks"); let (c, p) = pipes::stream(); - (p, p3).select(); + (move p, move p3).select(); c.send(()); }; - #error["parent tries"]; + error!("parent tries"); assert !p.recv().try_send(()); - #error("all done!"); + error!("all done!"); } diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs new file mode 100644 index 00000000000..7302163a312 --- /dev/null +++ b/src/test/run-pass/issue-3447.rs @@ -0,0 +1,24 @@ +struct list<T> { + element: &self/T, + mut next: Option<@list<T>> +} + +impl<T> list<T>{ + fn addEnd(&self, element: &self/T) { + let newList = list { + element: element, + next: option::None + }; + + self.next = Some(@(move newList)); + } +} + +fn main() { + let s = @"str"; + let ls = list { + element: &s, + next: option::None + }; + io::println(*ls.element); +} diff --git a/src/test/run-pass/issue-3656.rs b/src/test/run-pass/issue-3656.rs new file mode 100644 index 00000000000..5e9835b4f6f --- /dev/null +++ b/src/test/run-pass/issue-3656.rs @@ -0,0 +1,21 @@ +// xfail-fast Can't redeclare malloc with wrong signature because bugs +// Issue #3656 +// Incorrect struct size computation in the FFI, because of not taking +// the alignment of elements into account. + +use libc::*; + +struct KEYGEN { + hash_algorithm: [c_uint * 2], + count: uint32_t, + salt: *c_void, + salt_size: uint32_t, +} + +extern { + // Bogus signature, just need to test if it compiles. + pub fn malloc(++data: KEYGEN); +} + +fn main() { +} diff --git a/src/test/run-pass/issue_3136_b.rs b/src/test/run-pass/issue_3136_b.rs new file mode 100644 index 00000000000..ef8e1af56d7 --- /dev/null +++ b/src/test/run-pass/issue_3136_b.rs @@ -0,0 +1,6 @@ +// xfail-fast - check-fast doesn't understand aux-build +// aux-build:issue_3136_a.rc + +extern mod issue_3136_a; +fn main() {} + diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index a3451da6f9a..225ba63e6a5 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -75,7 +75,6 @@ mod test_stmt_single_attr_outer { #[attr = "val"] fn f() { } - /* FIXME: Issue #493 #[attr = "val"] mod mod1 { #[legacy_exports]; @@ -86,7 +85,6 @@ mod test_stmt_single_attr_outer { extern mod rustrt { #[legacy_exports]; } - */ } } diff --git a/src/test/run-pass/iter-all.rs b/src/test/run-pass/iter-all.rs index 75334db86cc..b5c10fd2c81 100644 --- a/src/test/run-pass/iter-all.rs +++ b/src/test/run-pass/iter-all.rs @@ -1,9 +1,9 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } fn main() { - assert ![1u, 2u]/_.all(is_even); - assert [2u, 4u]/_.all(is_even); - assert []/_.all(is_even); + assert ![1u, 2u].all(is_even); + assert [2u, 4u].all(is_even); + assert [].all(is_even); assert !Some(1u).all(is_even); assert Some(2u).all(is_even); diff --git a/src/test/run-pass/iter-any.rs b/src/test/run-pass/iter-any.rs index 22057b74a41..f964eda54a5 100644 --- a/src/test/run-pass/iter-any.rs +++ b/src/test/run-pass/iter-any.rs @@ -1,9 +1,9 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } fn main() { - assert ![1u, 3u]/_.any(is_even); - assert [1u, 2u]/_.any(is_even); - assert ![]/_.any(is_even); + assert ![1u, 3u].any(is_even); + assert [1u, 2u].any(is_even); + assert ![].any(is_even); assert !Some(1).any(is_even); assert Some(2).any(is_even); diff --git a/src/test/run-pass/iter-contains.rs b/src/test/run-pass/iter-contains.rs index 6036b5b2d24..31fa52175aa 100644 --- a/src/test/run-pass/iter-contains.rs +++ b/src/test/run-pass/iter-contains.rs @@ -1,9 +1,9 @@ fn main() { - assert []/_.contains(&22u) == false; - assert [1u, 3u]/_.contains(&22u) == false; - assert [22u, 1u, 3u]/_.contains(&22u) == true; - assert [1u, 22u, 3u]/_.contains(&22u) == true; - assert [1u, 3u, 22u]/_.contains(&22u) == true; + assert [].contains(&22u) == false; + assert [1u, 3u].contains(&22u) == false; + assert [22u, 1u, 3u].contains(&22u) == true; + assert [1u, 22u, 3u].contains(&22u) == true; + assert [1u, 3u, 22u].contains(&22u) == true; assert None.contains(&22u) == false; assert Some(1u).contains(&22u) == false; assert Some(22u).contains(&22u) == true; diff --git a/src/test/run-pass/iter-count.rs b/src/test/run-pass/iter-count.rs index 0b6f94367be..26aa26b4c8d 100644 --- a/src/test/run-pass/iter-count.rs +++ b/src/test/run-pass/iter-count.rs @@ -1,8 +1,8 @@ fn main() { - assert []/_.count(&22u) == 0u; - assert [1u, 3u]/_.count(&22u) == 0u; - assert [22u, 1u, 3u]/_.count(&22u) == 1u; - assert [22u, 1u, 22u]/_.count(&22u) == 2u; + assert [].count(&22u) == 0u; + assert [1u, 3u].count(&22u) == 0u; + assert [22u, 1u, 3u].count(&22u) == 1u; + assert [22u, 1u, 22u].count(&22u) == 2u; assert None.count(&22u) == 0u; assert Some(1u).count(&22u) == 0u; assert Some(22u).count(&22u) == 1u; diff --git a/src/test/run-pass/iter-eachi.rs b/src/test/run-pass/iter-eachi.rs index 9ae3cc43913..4c85e6ca3af 100644 --- a/src/test/run-pass/iter-eachi.rs +++ b/src/test/run-pass/iter-eachi.rs @@ -1,6 +1,6 @@ fn main() { let mut c = 0u; - for [1u, 2u, 3u, 4u, 5u]/_.eachi |i, v| { + for [1u, 2u, 3u, 4u, 5u].eachi |i, v| { assert (i + 1u) == *v; c += 1u; } diff --git a/src/test/run-pass/iter-filter-to-vec.rs b/src/test/run-pass/iter-filter-to-vec.rs index f96b18f140a..000e7c491be 100644 --- a/src/test/run-pass/iter-filter-to-vec.rs +++ b/src/test/run-pass/iter-filter-to-vec.rs @@ -1,8 +1,8 @@ fn is_even(+x: uint) -> bool { (x % 2) == 0 } fn main() { - assert [1, 3]/_.filter_to_vec(is_even) == ~[]; - assert [1, 2, 3]/_.filter_to_vec(is_even) == ~[2]; + assert [1, 3].filter_to_vec(is_even) == ~[]; + assert [1, 2, 3].filter_to_vec(is_even) == ~[2]; assert None.filter_to_vec(is_even) == ~[]; assert Some(1).filter_to_vec(is_even) == ~[]; assert Some(2).filter_to_vec(is_even) == ~[2]; diff --git a/src/test/run-pass/iter-foldl.rs b/src/test/run-pass/iter-foldl.rs index bbc1673f686..65b517acf1c 100644 --- a/src/test/run-pass/iter-foldl.rs +++ b/src/test/run-pass/iter-foldl.rs @@ -1,8 +1,8 @@ fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) } fn main() { - assert [1u, 3u]/_.foldl(20f, add) == 24f; - assert []/_.foldl(20f, add) == 20f; + assert [1u, 3u].foldl(20f, add) == 24f; + assert [].foldl(20f, add) == 20f; assert None.foldl(20f, add) == 20f; assert Some(1u).foldl(20f, add) == 21f; assert Some(2u).foldl(20f, add) == 22f; diff --git a/src/test/run-pass/iter-map-to-vec.rs b/src/test/run-pass/iter-map-to-vec.rs index 2f5359f197f..208fc5d127e 100644 --- a/src/test/run-pass/iter-map-to-vec.rs +++ b/src/test/run-pass/iter-map-to-vec.rs @@ -1,8 +1,8 @@ fn inc(+x: uint) -> uint { x + 1 } fn main() { - assert [1, 3]/_.map_to_vec(inc) == ~[2, 4]; - assert [1, 2, 3]/_.map_to_vec(inc) == ~[2, 3, 4]; + assert [1, 3].map_to_vec(inc) == ~[2, 4]; + assert [1, 2, 3].map_to_vec(inc) == ~[2, 3, 4]; assert None.map_to_vec(inc) == ~[]; assert Some(1).map_to_vec(inc) == ~[2]; assert Some(2).map_to_vec(inc) == ~[3]; diff --git a/src/test/run-pass/iter-min-max.rs b/src/test/run-pass/iter-min-max.rs index 23bd7fb05af..60001c8f7e5 100644 --- a/src/test/run-pass/iter-min-max.rs +++ b/src/test/run-pass/iter-min-max.rs @@ -1,11 +1,11 @@ fn is_even(&&x: uint) -> bool { (x % 2u) == 0u } fn main() { - assert [1u, 3u]/_.min() == 1u; - assert [3u, 1u]/_.min() == 1u; + assert [1u, 3u].min() == 1u; + assert [3u, 1u].min() == 1u; assert Some(1u).min() == 1u; - assert [1u, 3u]/_.max() == 3u; - assert [3u, 1u]/_.max() == 3u; + assert [1u, 3u].max() == 3u; + assert [3u, 1u].max() == 3u; assert Some(3u).max() == 3u; } diff --git a/src/test/run-pass/iter-to-vec.rs b/src/test/run-pass/iter-to-vec.rs index c2f1330b721..358f484464d 100644 --- a/src/test/run-pass/iter-to-vec.rs +++ b/src/test/run-pass/iter-to-vec.rs @@ -1,5 +1,5 @@ fn main() { - assert [1u, 3u]/_.to_vec() == ~[1u, 3u]; + assert [1u, 3u].to_vec() == ~[1u, 3u]; let e: ~[uint] = ~[]; assert e.to_vec() == ~[]; assert None::<uint>.to_vec() == ~[]; diff --git a/src/test/run-pass/last-use-corner-cases.rs b/src/test/run-pass/last-use-corner-cases.rs index a3088a2c125..510fc8ddeaa 100644 --- a/src/test/run-pass/last-use-corner-cases.rs +++ b/src/test/run-pass/last-use-corner-cases.rs @@ -5,7 +5,7 @@ fn main() { // Make sure closing over can be a last use let q = ~10; let addr = ptr::addr_of(&(*q)); - let f = fn@() -> *int { ptr::addr_of(&(*q)) }; + let f = fn@(move q) -> *int { ptr::addr_of(&(*q)) }; assert addr == f(); // But only when it really is the last use diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index c1dc0b76a10..56c6659743d 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -3,14 +3,14 @@ fn lp<T>(s: ~str, f: fn(~str) -> T) -> T { while false { let r = f(s); - return r; + return (move r); } fail; } fn apply<T>(s: ~str, f: fn(~str) -> T) -> T { fn g<T>(s: ~str, f: fn(~str) -> T) -> T {f(s)} - g(s, |v| { let r = f(v); r }) + g(s, |v| { let r = f(v); move r }) } fn main() {} diff --git a/src/test/run-pass/liveness-move-in-loop.rs b/src/test/run-pass/liveness-move-in-loop.rs index e0a05c9b297..d52395b4c7c 100644 --- a/src/test/run-pass/liveness-move-in-loop.rs +++ b/src/test/run-pass/liveness-move-in-loop.rs @@ -5,7 +5,7 @@ fn the_loop() { loop { let x = 5; if x > 3 { - list += ~[take(x)]; + list += ~[take(move x)]; } else { break; } diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index bb042f2359b..bb9a4278467 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -9,7 +9,7 @@ type smallintmap<T> = @{mut v: ~[mut option<T>]}; fn mk<T>() -> smallintmap<T> { let v: ~[mut option<T>] = ~[mut]; - return @{mut v: v}; + return @{mut v: move v}; } fn f<T,U>() { diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index c771249c9ed..eed871ce4b8 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -15,7 +15,7 @@ struct F<A> { a: A } impl<A: Copy Serializable> F<A>: Serializable { fn serialize<S: Serializer>(s: S) { - self.a.serialize(s); + self.a.serialize(move s); } } diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index e312d2afb4b..fded13293f3 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -3,7 +3,7 @@ fn test(-foo: ~~[int]) { assert (foo[0] == 10); } fn main() { let x = ~~[10]; // Test forgetting a local by move-in - test(x); + test(move x); // Test forgetting a temporary by move-in. test(~~[10]); diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index 01e287c0db0..1f2f3b9ad3b 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -3,7 +3,7 @@ fn test(-foo: @~[int]) { assert (foo[0] == 10); } fn main() { let x = @~[10]; // Test forgetting a local by move-in - test(x); + test(move x); // Test forgetting a temporary by move-in. test(@~[10]); diff --git a/src/test/run-pass/move-arg.rs b/src/test/run-pass/move-arg.rs index 286b7c6cb6d..1db4d9cef74 100644 --- a/src/test/run-pass/move-arg.rs +++ b/src/test/run-pass/move-arg.rs @@ -1,3 +1,3 @@ fn test(-foo: int) { assert (foo == 10); } -fn main() { let x = 10; test(x); } +fn main() { let x = 10; test(move x); } diff --git a/src/test/run-pass/move-nullary-fn.rs b/src/test/run-pass/move-nullary-fn.rs index e5331a11556..0c02affb1c5 100644 --- a/src/test/run-pass/move-nullary-fn.rs +++ b/src/test/run-pass/move-nullary-fn.rs @@ -2,7 +2,7 @@ fn f2(-thing: fn@()) { } fn f(-thing: fn@()) { - f2(thing); + f2(move thing); } fn main() { diff --git a/src/test/run-pass/non-legacy-modes.rs b/src/test/run-pass/non-legacy-modes.rs index 8fb843d8564..d6ece2c19c3 100644 --- a/src/test/run-pass/non-legacy-modes.rs +++ b/src/test/run-pass/non-legacy-modes.rs @@ -3,7 +3,7 @@ struct X { } fn apply<T>(x: T, f: fn(T)) { - f(x); + f(move x); } fn check_int(x: int) { diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 06b87794e59..7481b06d873 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -9,7 +9,7 @@ struct dtor { fn unwrap<T>(+o: Option<T>) -> T { match move o { - Some(move v) => v, + Some(move v) => move v, None => fail } } @@ -19,7 +19,7 @@ fn main() { { let b = Some(dtor { x:x }); - let c = unwrap(b); + let c = unwrap(move b); } assert *x == 0; diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index 899b74b2866..e59634ad089 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -33,15 +33,15 @@ proto! bank ( ) macro_rules! move_it ( - { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); y } } + { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } } ) fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>, f: fn(+v: Option<T>) -> U) -> U { - f(pipes::try_recv(endp)) + f(pipes::try_recv(move endp)) } -fn move_it<T>(-x: T) -> T { x } +fn move_it<T>(-x: T) -> T { move x } macro_rules! follow ( { @@ -59,15 +59,15 @@ macro_rules! follow ( fn client_follow(+bank: bank::client::login) { use bank::*; - let bank = client::login(bank, ~"theincredibleholk", ~"1234"); - let bank = switch(bank, follow! ( - ok -> connected { connected } + let bank = client::login(move bank, ~"theincredibleholk", ~"1234"); + let bank = switch(move bank, follow! ( + ok -> connected { move connected } invalid -> _next { fail ~"bank closed the connected" } )); - let bank = client::deposit(bank, 100.00); - let bank = client::withdrawal(bank, 50.00); - switch(bank, follow! ( + let bank = client::deposit(move bank, 100.00); + let bank = client::withdrawal(move bank, 50.00); + switch(move bank, follow! ( money(m) -> _next { io::println(~"Yay! I got money!"); } @@ -80,8 +80,8 @@ fn client_follow(+bank: bank::client::login) { fn bank_client(+bank: bank::client::login) { use bank::*; - let bank = client::login(bank, ~"theincredibleholk", ~"1234"); - let bank = match try_recv(bank) { + let bank = client::login(move bank, ~"theincredibleholk", ~"1234"); + let bank = match try_recv(move bank) { Some(ok(connected)) => { move_it!(connected) } @@ -89,10 +89,10 @@ fn bank_client(+bank: bank::client::login) { None => { fail ~"bank closed the connection" } }; - let bank = client::deposit(bank, 100.00); - let bank = client::withdrawal(bank, 50.00); - match try_recv(bank) { - Some(money(m, _)) => { + let bank = client::deposit(move bank, 100.00); + let bank = client::withdrawal(move bank, 50.00); + match try_recv(move bank) { + Some(money(*)) => { io::println(~"Yay! I got money!"); } Some(insufficient_funds(_)) => { diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs index 93c12449f2e..524541780c0 100644 --- a/src/test/run-pass/pipe-detect-term.rs +++ b/src/test/run-pass/pipe-detect-term.rs @@ -19,7 +19,7 @@ fn main() { let iotask = uv::global_loop::get(); pipes::spawn_service(oneshot::init, |p| { - match try_recv(p) { + match try_recv(move p) { Some(*) => { fail } None => { } } @@ -34,11 +34,11 @@ fn main() { fn failtest() { let (c, p) = oneshot::init(); - do task::spawn_with(c) |_c| { + do task::spawn_with(move c) |_c| { fail; } - error!("%?", recv(p)); + error!("%?", recv(move p)); // make sure we get killed if we missed it in the receive. loop { task::yield() } } diff --git a/src/test/run-pass/pipe-peek.rs b/src/test/run-pass/pipe-peek.rs index e8b2aa1a791..e3a2d29747b 100644 --- a/src/test/run-pass/pipe-peek.rs +++ b/src/test/run-pass/pipe-peek.rs @@ -15,7 +15,7 @@ fn main() { assert !pipes::peek(&p); - oneshot::client::signal(c); + oneshot::client::signal(move c); assert pipes::peek(&p); } diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index 9bfbbe338e7..0db7d6cf123 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -25,7 +25,7 @@ mod pingpong { pong: mk_packet::<pong>() } }; - do pipes::entangle_buffer(buffer) |buffer, data| { + do pipes::entangle_buffer(move buffer) |buffer, data| { data.ping.set_buffer_(buffer); data.pong.set_buffer_(buffer); ptr::addr_of(&(data.ping)) @@ -40,9 +40,9 @@ mod pingpong { let b = pipe.reuse_buffer(); let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong))); let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong))); - let message = pingpong::ping(s); - pipes::send(pipe, message); - c + let message = pingpong::ping(move s); + pipes::send(move pipe, move message); + move c } } type ping = pipes::SendPacketBuffered<pingpong::ping, @@ -59,9 +59,9 @@ mod pingpong { let b = pipe.reuse_buffer(); let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping))); let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping))); - let message = pingpong::pong(s); - pipes::send(pipe, message); - c + let message = pingpong::pong(move s); + pipes::send(move pipe, move message); + move c } } type pong = pipes::SendPacketBuffered<pingpong::pong, @@ -77,34 +77,34 @@ mod test { fn client(-chan: pingpong::client::ping) { use pingpong::client; - let chan = client::ping(chan); return; + let chan = client::ping(move chan); return; log(error, "Sent ping"); - let pong(_chan) = recv(chan); + let pong(_chan) = recv(move chan); log(error, "Received pong"); } fn server(-chan: pingpong::server::ping) { use pingpong::server; - let ping(chan) = recv(chan); return; + let ping(chan) = recv(move chan); return; log(error, "Received ping"); - let _chan = server::pong(chan); + let _chan = server::pong(move chan); log(error, "Sent pong"); } } fn main() { let (client_, server_) = pingpong::init(); - let client_ = ~mut Some(client_); - let server_ = ~mut Some(server_); + let client_ = ~mut Some(move client_); + let server_ = ~mut Some(move server_); do task::spawn |move client_| { let mut client__ = None; *client_ <-> client__; - test::client(option::unwrap(client__)); + test::client(option::unwrap(move client__)); }; do task::spawn |move server_| { let mut server_ËŠ = None; *server_ <-> server_ËŠ; - test::server(option::unwrap(server_ËŠ)); + test::server(option::unwrap(move server_ËŠ)); }; } diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index 7af00e8dbf2..c1c74aefa9c 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -20,35 +20,35 @@ mod test { fn client(-chan: pingpong::client::ping) { use pingpong::client; - let chan = client::ping(chan); + let chan = client::ping(move chan); log(error, ~"Sent ping"); - let pong(_chan) = recv(chan); + let pong(_chan) = recv(move chan); log(error, ~"Received pong"); } fn server(-chan: pingpong::server::ping) { use pingpong::server; - let ping(chan) = recv(chan); + let ping(chan) = recv(move chan); log(error, ~"Received ping"); - let _chan = server::pong(chan); + let _chan = server::pong(move chan); log(error, ~"Sent pong"); } } fn main() { let (client_, server_) = pingpong::init(); - let client_ = ~mut Some(client_); - let server_ = ~mut Some(server_); + let client_ = ~mut Some(move client_); + let server_ = ~mut Some(move server_); do task::spawn |move client_| { let mut client__ = None; *client_ <-> client__; - test::client(option::unwrap(client__)); + test::client(option::unwrap(move client__)); }; do task::spawn |move server_| { let mut server_ËŠ = None; *server_ <-> server_ËŠ; - test::server(option::unwrap(server_ËŠ)); + test::server(option::unwrap(move server_ËŠ)); }; } diff --git a/src/test/run-pass/pipe-presentation-examples.rs b/src/test/run-pass/pipe-presentation-examples.rs index f485148d79e..853aba53eda 100644 --- a/src/test/run-pass/pipe-presentation-examples.rs +++ b/src/test/run-pass/pipe-presentation-examples.rs @@ -22,10 +22,10 @@ macro_rules! select_if ( ], )* } => { if $index == $count { - match move pipes::try_recv($port) { + match move pipes::try_recv(move $port) { $(Some($message($($(move $x,)+)* move next)) => { - let $next = next; - $e + let $next = move next; + move $e })+ _ => fail } @@ -56,7 +56,7 @@ macro_rules! select ( -> $next:ident $e:expr),+ } )+ } => { - let index = pipes::selecti([$(($port).header()),+]/_); + let index = pipes::selecti([$(($port).header()),+]); select_if!(index, 0, $( $port => [ $($message$(($($x),+))dont_type_this* -> $next $e),+ ], )+) @@ -90,33 +90,33 @@ fn render(_buffer: &Buffer) { } fn draw_frame(+channel: double_buffer::client::acquire) { - let channel = request(channel); + let channel = request(move channel); select! ( channel => { give_buffer(buffer) -> channel { render(&buffer); - release(channel, move buffer) + release(move channel, move buffer) } } ); } fn draw_two_frames(+channel: double_buffer::client::acquire) { - let channel = request(channel); + let channel = request(move channel); let channel = select! ( channel => { give_buffer(buffer) -> channel { render(&buffer); - release(channel, move buffer) + release(move channel, move buffer) } } ); - let channel = request(channel); + let channel = request(move channel); select! ( channel => { give_buffer(buffer) -> channel { render(&buffer); - release(channel, move buffer) + release(move channel, move buffer) } } ); diff --git a/src/test/run-pass/pipe-select-macro.rs b/src/test/run-pass/pipe-select-macro.rs index 8554659a2ee..e3842c86c4c 100644 --- a/src/test/run-pass/pipe-select-macro.rs +++ b/src/test/run-pass/pipe-select-macro.rs @@ -1,3 +1,5 @@ +// tjc: un-xfail after snapshot +// xfail-test // xfail-pretty // Protocols @@ -42,7 +44,7 @@ fn test(+foo: foo::client::foo, +bar: bar::client::bar) { }, do_baz(b) -> _next { - if *b { debug!("true") } else { debug!("false") } + if b { debug!("true") } else { debug!("false") } } } ) diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 4d70eb62e94..23588de2eca 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -14,8 +14,8 @@ proto! oneshot ( ) proto! stream ( - stream:send<T:Send> { - send(T) -> stream<T> + Stream:send<T:Send> { + send(T) -> Stream<T> } ) @@ -27,24 +27,24 @@ fn main() { let c = pipes::spawn_service(stream::init, |p| { error!("waiting for pipes"); - let stream::send(x, p) = recv(p); + let stream::send(x, p) = recv(move p); error!("got pipes"); let (left, right) : (oneshot::server::waiting, oneshot::server::waiting) - = x; + = move x; error!("selecting"); - let (i, _, _) = select(~[left, right]); + let (i, _, _) = select(~[move left, move right]); error!("selected"); assert i == 0; error!("waiting for pipes"); - let stream::send(x, _) = recv(p); + let stream::send(x, _) = recv(move p); error!("got pipes"); let (left, right) : (oneshot::server::waiting, oneshot::server::waiting) - = x; + = move x; error!("selecting"); - let (i, m, _) = select(~[left, right]); + let (i, m, _) = select(~[move left, move right]); error!("selected %?", i); if m.is_some() { assert i == 1; @@ -54,20 +54,20 @@ fn main() { let (c1, p1) = oneshot::init(); let (_c2, p2) = oneshot::init(); - let c = send(c, (p1, p2)); + let c = send(move c, (move p1, move p2)); sleep(iotask, 100); - signal(c1); + signal(move c1); let (_c1, p1) = oneshot::init(); let (c2, p2) = oneshot::init(); - send(c, (p1, p2)); + send(move c, (move p1, move p2)); sleep(iotask, 100); - signal(c2); + signal(move c2); test_select2(); } @@ -76,26 +76,26 @@ fn test_select2() { let (ac, ap) = stream::init(); let (bc, bp) = stream::init(); - stream::client::send(ac, 42); + stream::client::send(move ac, 42); - match pipes::select2(ap, bp) { + match pipes::select2(move ap, move bp) { either::Left(*) => { } either::Right(*) => { fail } } - stream::client::send(bc, ~"abc"); + stream::client::send(move bc, ~"abc"); error!("done with first select2"); let (ac, ap) = stream::init(); let (bc, bp) = stream::init(); - stream::client::send(bc, ~"abc"); + stream::client::send(move bc, ~"abc"); - match pipes::select2(ap, bp) { + match pipes::select2(move ap, move bp) { either::Left(*) => { fail } either::Right(*) => { } } - stream::client::send(ac, 42); + stream::client::send(move ac, 42); } diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs index 4e901c69d29..c9975bec946 100644 --- a/src/test/run-pass/pipe-sleep.rs +++ b/src/test/run-pass/pipe-sleep.rs @@ -14,10 +14,10 @@ proto! oneshot ( fn main() { use oneshot::client::*; - let c = pipes::spawn_service(oneshot::init, |p| { recv(p); }); + let c = pipes::spawn_service(oneshot::init, |p| { recv(move p); }); let iotask = uv::global_loop::get(); sleep(iotask, 500); - signal(c); + signal(move c); } \ No newline at end of file diff --git a/src/test/run-pass/pure-fmt.rs b/src/test/run-pass/pure-fmt.rs index 1671c3369ff..d757d0311b4 100644 --- a/src/test/run-pass/pure-fmt.rs +++ b/src/test/run-pass/pure-fmt.rs @@ -1,4 +1,4 @@ -// Testing that calling #fmt (via #debug) doesn't complain about impure borrows +// Testing that calling fmt! (via debug!) doesn't complain about impure borrows pure fn foo() { let a = { @@ -18,4 +18,4 @@ pure fn foo() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index e27aaa618ac..24ae16f25e1 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -3,13 +3,7 @@ use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; use libc::c_void; - -// FIXME: this is a near-duplicate of code in core::vec. -type unboxed_vec_repr = { - mut fill: uint, - mut alloc: uint, - data: u8 -}; +use vec::UnboxedVecRepr; #[doc = "High-level interfaces to `intrinsic::visit_ty` reflection system."] @@ -238,8 +232,8 @@ impl<V: TyVisitor movable_ptr> ptr_visit_adaptor<V>: TyVisitor { } fn visit_unboxed_vec(mtbl: uint, inner: *TyDesc) -> bool { - self.align_to::<unboxed_vec_repr>(); - // FIXME: Inner really has to move its own pointers on this one. + self.align_to::<UnboxedVecRepr>(); + // FIXME (#3732): Inner really has to move its own pointers on this one. // or else possibly we could have some weird interface wherein we // read-off a word from inner's pointers, but the read-word has to // always be the same in all sub-pointers? Dubious. @@ -570,7 +564,7 @@ impl my_visitor: TyVisitor { fn visit_enter_enum(_n_variants: uint, _sz: uint, _align: uint) -> bool { - // FIXME: this needs to rewind between enum variants, or something. + // FIXME (#3732): this needs to rewind between enum variants, or something. true } fn visit_enter_enum_variant(_variant: uint, diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index f7eb2c01315..4d2d2a7170e 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -1,37 +1,35 @@ -// FIXME: un-xfail after snapshot // xfail-test - -use intrinsic::{tydesc, get_tydesc, visit_tydesc, ty_visitor}; +use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; enum my_visitor = @{ mut types: ~[str] }; -impl of ty_visitor for my_visitor { +impl my_visitor: TyVisitor { fn visit_bot() -> bool { - self.types += ["bot"]; + self.types += ~["bot"]; error!("visited bot type"); true } fn visit_nil() -> bool { - self.types += ["nil"]; + self.types += ~["nil"]; error!("visited nil type"); true } fn visit_bool() -> bool { - self.types += ["bool"]; + self.types += ~["bool"]; error!("visited bool type"); true } fn visit_int() -> bool { - self.types += ["int"]; + self.types += ~["int"]; error!("visited int type"); true } fn visit_i8() -> bool { - self.types += ["i8"]; + self.types += ~["i8"]; error!("visited i8 type"); true } fn visit_i16() -> bool { - self.types += ["i16"]; + self.types += ~["i16"]; error!("visited i16 type"); true } @@ -57,41 +55,41 @@ impl of ty_visitor for my_visitor { fn visit_estr_fixed(_sz: uint, _sz: uint, _align: uint) -> bool { true } - fn visit_box(_mtbl: uint, _inner: *tydesc) -> bool { true } - fn visit_uniq(_mtbl: uint, _inner: *tydesc) -> bool { true } - fn visit_ptr(_mtbl: uint, _inner: *tydesc) -> bool { true } - fn visit_rptr(_mtbl: uint, _inner: *tydesc) -> bool { true } + fn visit_box(_mtbl: uint, _inner: *TyDesc) -> bool { true } + fn visit_uniq(_mtbl: uint, _inner: *TyDesc) -> bool { true } + fn visit_ptr(_mtbl: uint, _inner: *TyDesc) -> bool { true } + fn visit_rptr(_mtbl: uint, _inner: *TyDesc) -> bool { true } - fn visit_vec(_mtbl: uint, inner: *tydesc) -> bool { - self.types += ["["]; - visit_tydesc(inner, my_visitor(*self) as ty_visitor); - self.types += ["]"]; + fn visit_vec(_mtbl: uint, inner: *TyDesc) -> bool { + self.types += ~["["]; + visit_tydesc(inner, my_visitor(*self) as TyVisitor); + self.types += ~["]"]; true } - fn visit_unboxed_vec(_mtbl: uint, _inner: *tydesc) -> bool { true } - fn visit_evec_box(_mtbl: uint, _inner: *tydesc) -> bool { true } - fn visit_evec_uniq(_mtbl: uint, _inner: *tydesc) -> bool { true } - fn visit_evec_slice(_mtbl: uint, _inner: *tydesc) -> bool { true } + fn visit_unboxed_vec(_mtbl: uint, _inner: *TyDesc) -> bool { true } + fn visit_evec_box(_mtbl: uint, _inner: *TyDesc) -> bool { true } + fn visit_evec_uniq(_mtbl: uint, _inner: *TyDesc) -> bool { true } + fn visit_evec_slice(_mtbl: uint, _inner: *TyDesc) -> bool { true } fn visit_evec_fixed(_n: uint, _sz: uint, _align: uint, - _mtbl: uint, _inner: *tydesc) -> bool { true } + _mtbl: uint, _inner: *TyDesc) -> bool { true } fn visit_enter_rec(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } fn visit_rec_field(_i: uint, _name: &str, - _mtbl: uint, _inner: *tydesc) -> bool { true } + _mtbl: uint, _inner: *TyDesc) -> bool { true } fn visit_leave_rec(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } fn visit_enter_class(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } fn visit_class_field(_i: uint, _name: &str, - _mtbl: uint, _inner: *tydesc) -> bool { true } + _mtbl: uint, _inner: *TyDesc) -> bool { true } fn visit_leave_class(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } fn visit_enter_tup(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } - fn visit_tup_field(_i: uint, _inner: *tydesc) -> bool { true } + fn visit_tup_field(_i: uint, _inner: *TyDesc) -> bool { true } fn visit_leave_tup(_n_fields: uint, _sz: uint, _align: uint) -> bool { true } @@ -101,7 +99,7 @@ impl of ty_visitor for my_visitor { _disr_val: int, _n_fields: uint, _name: &str) -> bool { true } - fn visit_enum_variant_field(_i: uint, _inner: *tydesc) -> bool { true } + fn visit_enum_variant_field(_i: uint, _inner: *TyDesc) -> bool { true } fn visit_leave_enum_variant(_variant: uint, _disr_val: int, _n_fields: uint, @@ -111,8 +109,8 @@ impl of ty_visitor for my_visitor { fn visit_enter_fn(_purity: uint, _proto: uint, _n_inputs: uint, _retstyle: uint) -> bool { true } - fn visit_fn_input(_i: uint, _mode: uint, _inner: *tydesc) -> bool { true } - fn visit_fn_output(_retstyle: uint, _inner: *tydesc) -> bool { true } + fn visit_fn_input(_i: uint, _mode: uint, _inner: *TyDesc) -> bool { true } + fn visit_fn_output(_retstyle: uint, _inner: *TyDesc) -> bool { true } fn visit_leave_fn(_purity: uint, _proto: uint, _n_inputs: uint, _retstyle: uint) -> bool { true } @@ -124,17 +122,17 @@ impl of ty_visitor for my_visitor { fn visit_self() -> bool { true } fn visit_type() -> bool { true } fn visit_opaque_box() -> bool { true } - fn visit_constr(_inner: *tydesc) -> bool { true } + fn visit_constr(_inner: *TyDesc) -> bool { true } fn visit_closure_ptr(_ck: uint) -> bool { true } } -fn visit_ty<T>(v: ty_visitor) { +fn visit_ty<T>(v: TyVisitor) { visit_tydesc(get_tydesc::<T>(), v); } fn main() { let v = my_visitor(@{mut types: ~[]}); - let vv = v as ty_visitor; + let vv = v as TyVisitor; visit_ty::<bool>(vv); visit_ty::<int>(vv); diff --git a/src/test/run-pass/regions-borrow-evec-fixed.rs b/src/test/run-pass/regions-borrow-evec-fixed.rs index 5a0875109f6..2526540bde1 100644 --- a/src/test/run-pass/regions-borrow-evec-fixed.rs +++ b/src/test/run-pass/regions-borrow-evec-fixed.rs @@ -5,6 +5,6 @@ fn foo(x: &[int]) -> int { } fn main() { - let p = [1,2,3,4,5]/_; + let p = [1,2,3,4,5]; assert foo(p) == 1; } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 2e03c5f82c4..834272ca920 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -2,8 +2,8 @@ struct closure_box { cl: &fn(), } -fn box_it(x: &r/fn()) -> closure_box/&r { - closure_box {cl: x} +fn box_it(+x: &r/fn()) -> closure_box/&r { + closure_box {cl: move x} } fn main() { diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index 61e04c4e776..6622a6aa569 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -2,8 +2,8 @@ struct closure_box { cl: &fn(), } -fn box_it(x: &r/fn()) -> closure_box/&r { - closure_box {cl: x} +fn box_it(+x: &r/fn()) -> closure_box/&r { + closure_box {cl: move x} } fn call_static_closure(cl: closure_box/&static) { @@ -12,5 +12,5 @@ fn call_static_closure(cl: closure_box/&static) { fn main() { let cl_box = box_it(|| debug!("Hello, world!")); - call_static_closure(cl_box); + call_static_closure(move cl_box); } diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index 7f3bc016a6a..f0bea875df9 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -14,8 +14,8 @@ fn main() { // Even though these look like copies, they are guaranteed not to be { let a = r(i); - let b = (a, 10); - let (c, _d) = b; + let b = (move a, 10); + let (c, _d) = move b; log(debug, c); } assert *i == 1; diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index 26e19ee1b0c..893042842d0 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -24,10 +24,10 @@ enum t = { fn main() unsafe { let i1 = ~0; let i1p = cast::reinterpret_cast(&i1); - cast::forget(i1); + cast::forget(move i1); let i2 = ~0; let i2p = cast::reinterpret_cast(&i2); - cast::forget(i2); + cast::forget(move i2); let x1 = @t({ mut next: None, @@ -35,7 +35,7 @@ fn main() unsafe { let rs = r(i1p); debug!("r = %x", cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs))); - rs } + move rs } }); debug!("x1 = %x, x1.r = %x", @@ -48,7 +48,7 @@ fn main() unsafe { let rs = r(i2p); debug!("r2 = %x", cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs))); - rs + move rs } }); diff --git a/src/test/run-pass/resource-cycle2.rs b/src/test/run-pass/resource-cycle2.rs index b522808c494..a38950e17e3 100644 --- a/src/test/run-pass/resource-cycle2.rs +++ b/src/test/run-pass/resource-cycle2.rs @@ -27,10 +27,10 @@ enum t = { fn main() unsafe { let i1 = ~0xA; let i1p = cast::reinterpret_cast(&i1); - cast::forget(i1); + cast::forget(move i1); let i2 = ~0xA; let i2p = cast::reinterpret_cast(&i2); - cast::forget(i2); + cast::forget(move i2); let u1 = {a: 0xB, b: 0xC, c: i1p}; let u2 = {a: 0xB, b: 0xC, c: i2p}; diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index efb1915799c..aa0f18089d9 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -34,10 +34,10 @@ enum t = { fn main() unsafe { let i1 = ~0xA; let i1p = cast::reinterpret_cast(&i1); - cast::forget(i1); + cast::forget(move i1); let i2 = ~0xA; let i2p = cast::reinterpret_cast(&i2); - cast::forget(i2); + cast::forget(move i2); let u1 = {a: 0xB, b: 0xC, c: i1p}; let u2 = {a: 0xB, b: 0xC, c: i2p}; diff --git a/src/test/run-pass/rt-sched-1.rs b/src/test/run-pass/rt-sched-1.rs index 690d93172eb..976225c0e23 100644 --- a/src/test/run-pass/rt-sched-1.rs +++ b/src/test/run-pass/rt-sched-1.rs @@ -35,6 +35,6 @@ fn main() unsafe { }; let fptr = cast::reinterpret_cast(&ptr::addr_of(&f)); rustrt::start_task(new_task_id, fptr); - cast::forget(f); + cast::forget(move f); comm::recv(po); } diff --git a/src/test/run-pass/select-macro.rs b/src/test/run-pass/select-macro.rs index 78bddffcc1d..271ed99057f 100644 --- a/src/test/run-pass/select-macro.rs +++ b/src/test/run-pass/select-macro.rs @@ -17,19 +17,18 @@ macro_rules! select_if ( $count:expr, $port:path => [ $(type_this $message:path$(($(x $x: ident),+))dont_type_this* - -> $next:ident => { $e:expr }),+ + -> $next:ident => { move $e:expr }),+ ] $(, $ports:path => [ $(type_this $messages:path$(($(x $xs: ident),+))dont_type_this* - -> $nexts:ident => { $es:expr }),+ + -> $nexts:ident => { move $es:expr }),+ ] )* } => { if $index == $count { match move pipes::try_recv($port) { - $(Some($message($($(ref $x,)+)* ref next)) => { - // FIXME (#2329) we really want move out of enum here. - let $next = unsafe { let x <- *ptr::addr_of(&(*next)); x }; - $e + $(Some($message($($(move $x,)+)* move next)) => { + let $next = move next; + move $e })+ _ => fail } @@ -39,7 +38,7 @@ macro_rules! select_if ( $count + 1 $(, $ports => [ $(type_this $messages$(($(x $xs),+))dont_type_this* - -> $nexts => { $es }),+ + -> $nexts => { move $es }),+ ])* ) } @@ -53,9 +52,9 @@ macro_rules! select ( -> $next:ident $e:expr),+ } )+ } => { - let index = pipes::selecti([$(($port).header()),+]/_); + let index = pipes::selecti([$(($port).header()),+]); select_if!(index, 0 $(, $port => [ - $(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+ + $(type_this $message$(($(x $x),+))dont_type_this* -> $next => { move $e }),+ ])+) } ) diff --git a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs new file mode 100644 index 00000000000..ac00f6a645b --- /dev/null +++ b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs @@ -0,0 +1,25 @@ +trait Deserializer { + fn read_int() -> int; +} + +trait Deserializable<D: Deserializer> { + static fn deserialize(d: &D) -> self; +} + +impl<D: Deserializer> int: Deserializable<D> { + static fn deserialize(d: &D) -> int { + return d.read_int(); + } +} + +struct FromThinAir { dummy: () } + +impl FromThinAir: Deserializer { + fn read_int() -> int { 22 } +} + +fn main() { + let d = FromThinAir { dummy: () }; + let i: int = deserialize(&d); + assert i == 22; +} \ No newline at end of file diff --git a/src/test/run-pass/static-method-test.rs b/src/test/run-pass/static-method-test.rs index 57d6558dd77..6ce4ff34815 100644 --- a/src/test/run-pass/static-method-test.rs +++ b/src/test/run-pass/static-method-test.rs @@ -13,13 +13,13 @@ fn andand<T: bool_like Copy>(x1: T, x2: T) -> T { impl bool: bool_like { static fn select<A>(&&b: bool, +x1: A, +x2: A) -> A { - if b { x1 } else { x2 } + if b { move x1 } else { move x2 } } } impl int: bool_like { static fn select<A>(&&b: int, +x1: A, +x2: A) -> A { - if b != 0 { x1 } else { x2 } + if b != 0 { move x1 } else { move x2 } } } diff --git a/src/test/run-pass/struct-literal-dtor.rs b/src/test/run-pass/struct-literal-dtor.rs index e182fa67cf0..2b56cee9f6b 100644 --- a/src/test/run-pass/struct-literal-dtor.rs +++ b/src/test/run-pass/struct-literal-dtor.rs @@ -1,6 +1,6 @@ struct foo { x: ~str, - drop { #error["%s", self.x]; } + drop { error!("%s", self.x); } } fn main() { diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs index d8586e7ef39..1244af227f4 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -19,7 +19,7 @@ fn test05_start(ch : Chan<int>) { fn test05() { let (ch, po) = pipes::stream(); - task::spawn(|| test05_start(ch) ); + task::spawn(|move ch| test05_start(ch) ); let mut value = po.recv(); log(error, value); value = po.recv(); diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 0c69f414cc8..55fff5422e3 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -5,7 +5,7 @@ extern mod std; fn start(c: pipes::Chan<pipes::Chan<~str>>) { let (ch, p) = pipes::stream(); - c.send(ch); + c.send(move ch); let mut a; let mut b; @@ -14,12 +14,12 @@ fn start(c: pipes::Chan<pipes::Chan<~str>>) { log(error, a); b = p.recv(); assert b == ~"B"; - log(error, b); + log(error, move b); } fn main() { let (ch, p) = pipes::stream(); - let child = task::spawn(|| start(ch) ); + let child = task::spawn(|move ch| start(ch) ); let c = p.recv(); c.send(~"A"); diff --git a/src/test/run-pass/task-comm-11.rs b/src/test/run-pass/task-comm-11.rs index c660ecd3a92..86fb20ad818 100644 --- a/src/test/run-pass/task-comm-11.rs +++ b/src/test/run-pass/task-comm-11.rs @@ -5,11 +5,11 @@ extern mod std; fn start(c: pipes::Chan<pipes::Chan<int>>) { let (ch, p) = pipes::stream(); - c.send(ch); + c.send(move ch); } fn main() { let (ch, p) = pipes::stream(); - let child = task::spawn(|| start(ch) ); + let child = task::spawn(|move ch| start(ch) ); let c = p.recv(); } diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs index c0f97c85bce..64ea3fb9d0e 100644 --- a/src/test/run-pass/task-comm-12.rs +++ b/src/test/run-pass/task-comm-12.rs @@ -7,7 +7,7 @@ fn start(&&task_number: int) { debug!("Started / Finished task."); } fn test00() { let i: int = 0; let mut result = None; - do task::task().future_result(|+r| { result = Some(r); }).spawn { + do task::task().future_result(|+r| { result = Some(move r); }).spawn { start(i) } @@ -19,7 +19,7 @@ fn test00() { } // Try joining tasks that have already finished. - future::get(&option::unwrap(result)); + future::get(&option::unwrap(move result)); debug!("Joined task."); } diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs index 7302bcdaa94..9827b3c36b9 100644 --- a/src/test/run-pass/task-comm-13.rs +++ b/src/test/run-pass/task-comm-13.rs @@ -12,6 +12,6 @@ fn start(c: pipes::Chan<int>, start: int, number_of_messages: int) { fn main() { debug!("Check that we don't deadlock."); let (ch, p) = pipes::stream(); - task::try(|| start(ch, 0, 10) ); + task::try(|move ch| start(ch, 0, 10) ); debug!("Joined task"); } diff --git a/src/test/run-pass/task-comm-14.rs b/src/test/run-pass/task-comm-14.rs index 14f8e3bfa2b..7f63d22be47 100644 --- a/src/test/run-pass/task-comm-14.rs +++ b/src/test/run-pass/task-comm-14.rs @@ -9,8 +9,8 @@ fn main() { while (i > 0) { log(debug, i); let (ch, p) = pipes::stream(); - po.add(p); - task::spawn(|copy i| child(i, ch) ); + po.add(move p); + task::spawn(|move ch, copy i| child(i, ch) ); i = i - 1; } diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs index 98b095426ea..c3734cb5d9c 100644 --- a/src/test/run-pass/task-comm-15.rs +++ b/src/test/run-pass/task-comm-15.rs @@ -18,6 +18,6 @@ fn main() { // the child's point of view the receiver may die. We should // drop messages on the floor in this case, and not crash! let (ch, p) = pipes::stream(); - task::spawn(|| start(ch, 10)); + task::spawn(|move ch| start(ch, 10)); p.recv(); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index a69b7b0c15b..47bc99b53f4 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -91,7 +91,7 @@ fn test_tag() { fn test_chan() { let (ch, po) = pipes::stream(); let (ch0, po0) = pipes::stream(); - ch.send(ch0); + ch.send(move ch0); let ch1 = po.recv(); // Does the transmitted channel still work? diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index 4faac4fdac1..7082cd55ac8 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -34,8 +34,8 @@ fn test00() { while i < number_of_tasks { let ch = po.chan(); do task::task().future_result(|+r| { - results.push(r); - }).spawn |copy i| { + results.push(move r); + }).spawn |move ch, copy i| { test00_start(ch, i, number_of_messages) } i = i + 1; diff --git a/src/test/run-pass/task-comm-7.rs b/src/test/run-pass/task-comm-7.rs index d4cba9f71ab..c34dfb319d8 100644 --- a/src/test/run-pass/task-comm-7.rs +++ b/src/test/run-pass/task-comm-7.rs @@ -17,19 +17,19 @@ fn test00() { let number_of_messages: int = 10; let c = p.chan(); - do task::spawn { + do task::spawn |move c| { test00_start(c, number_of_messages * 0, number_of_messages); } let c = p.chan(); - do task::spawn { + do task::spawn |move c| { test00_start(c, number_of_messages * 1, number_of_messages); } let c = p.chan(); - do task::spawn { + do task::spawn |move c| { test00_start(c, number_of_messages * 2, number_of_messages); } let c = p.chan(); - do task::spawn { + do task::spawn |move c| { test00_start(c, number_of_messages * 3, number_of_messages); } diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index c159b7b77e5..5ed5899658d 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -18,7 +18,8 @@ fn test00() { let ch = p.chan(); let mut result = None; - do task::task().future_result(|+r| { result = Some(r); }).spawn { + do task::task().future_result(|+r| { result = Some(move r); }).spawn + |move ch| { test00_start(ch, number_of_messages); } @@ -29,7 +30,7 @@ fn test00() { i += 1; } - future::get(&option::unwrap(result)); + future::get(&option::unwrap(move result)); assert (sum == number_of_messages * (number_of_messages - 1) / 2); } diff --git a/src/test/run-pass/task-comm.rs b/src/test/run-pass/task-comm.rs index c88b556fd53..aba0bd66005 100644 --- a/src/test/run-pass/task-comm.rs +++ b/src/test/run-pass/task-comm.rs @@ -40,7 +40,7 @@ fn test00() { while i < number_of_tasks { i = i + 1; do task::task().future_result(|+r| { - results.push(r); + results.push(move r); }).spawn |copy i| { test00_start(ch, i, number_of_messages); } @@ -127,7 +127,7 @@ fn test06() { while i < number_of_tasks { i = i + 1; do task::task().future_result(|+r| { - results.push(r); + results.push(move r); }).spawn |copy i| { test06_start(i); }; diff --git a/src/test/run-pass/task-compare.rs b/src/test/run-pass/task-compare.rs index 652d131584f..4b5852a1d97 100644 --- a/src/test/run-pass/task-compare.rs +++ b/src/test/run-pass/task-compare.rs @@ -1,23 +1,60 @@ +// xfail-test /** A test case for issue #577, which also exposes #588 */ -// FIXME: This won't work until we can compare resources (#2601) -// xfail-test - extern mod std; -use task::join; fn child() { } +struct notify { + ch: comm::Chan<bool>, v: @mut bool, + drop { + error!("notify: task=%? v=%x unwinding=%b b=%b", + task::get_task(), + ptr::addr_of(&(*(self.v))) as uint, + task::failing(), + *(self.v)); + let b = *(self.v); + comm::send(self.ch, b); + } +} + +fn notify(ch: comm::Chan<bool>, v: @mut bool) -> notify { + notify { + ch: ch, + v: v + } +} + +fn joinable(+f: fn~()) -> comm::Port<bool> { + fn wrapper(+c: comm::Chan<bool>, +f: fn()) { + let b = @mut false; + error!("wrapper: task=%? allocated v=%x", + task::get_task(), + ptr::addr_of(&(*b)) as uint); + let _r = notify(c, b); + f(); + *b = true; + } + let p = comm::Port(); + let c = comm::Chan(&p); + do task::spawn_unlinked { wrapper(c, copy f) }; + p +} + +fn join(port: comm::Port<bool>) -> bool { + comm::recv(port) +} + fn main() { // tasks let t1; let t2; let c1 = child, c2 = child; - t1 = task::spawn_joinable(c1); - t2 = task::spawn_joinable(c2); + t1 = joinable(c1); + t2 = joinable(c2); assert (t1 == t1); assert (t1 != t2); @@ -26,15 +63,15 @@ fn main() { let p1; let p2; - p1 = comm::port::<int>(); - p2 = comm::port::<int>(); + p1 = comm::Port::<int>(); + p2 = comm::Port::<int>(); assert (p1 == p1); assert (p1 != p2); // channels - let c1 = comm::chan(p1); - let c2 = comm::chan(p2); + let c1 = comm::Chan(p1); + let c2 = comm::Chan(p2); assert (c1 == c1); assert (c1 != c2); diff --git a/src/test/run-pass/test-ignore-cfg.rs b/src/test/run-pass/test-ignore-cfg.rs index 0482fc278c8..0baabecb0ab 100644 --- a/src/test/run-pass/test-ignore-cfg.rs +++ b/src/test/run-pass/test-ignore-cfg.rs @@ -20,10 +20,10 @@ fn checktests() { let tests = __test::tests(); let shouldignore = option::get( - &vec::find(tests, |t| t.name == ~"shouldignore" )); + vec::find(tests, |t| t.name == ~"shouldignore" )); assert shouldignore.ignore == true; let shouldnotignore = option::get( - &vec::find(tests, |t| t.name == ~"shouldnotignore" )); + vec::find(tests, |t| t.name == ~"shouldnotignore" )); assert shouldnotignore.ignore == false; } \ No newline at end of file diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 14ca4df66a0..2dfe48c4951 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -30,7 +30,7 @@ fn main() { assert indirect(~[10, 20]) == ~"[10, 20]!"; fn indirect2<T: to_str>(x: T) -> ~str { - indirect(x) + indirect(move x) } assert indirect2(~[1]) == ~"[1]!"; } diff --git a/src/test/run-pass/unique-fn-arg-move.rs b/src/test/run-pass/unique-fn-arg-move.rs index 2126e329247..3e162e13d78 100644 --- a/src/test/run-pass/unique-fn-arg-move.rs +++ b/src/test/run-pass/unique-fn-arg-move.rs @@ -4,5 +4,5 @@ fn f(-i: ~int) { fn main() { let i = ~100; - f(i); + f(move i); } \ No newline at end of file diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs index 10c9fcae8e7..850adcf6746 100644 --- a/src/test/run-pass/use.rs +++ b/src/test/run-pass/use.rs @@ -1,7 +1,7 @@ #[no_core]; extern mod core; extern mod zed(name = "core"); -extern mod bar(name = "core", vers = "0.4"); +extern mod bar(name = "core", vers = "0.5"); use core::str; diff --git a/src/test/run-pass/yield.rs b/src/test/run-pass/yield.rs index f9c2ad2547d..11208a969db 100644 --- a/src/test/run-pass/yield.rs +++ b/src/test/run-pass/yield.rs @@ -4,13 +4,13 @@ use task::*; fn main() { let mut result = None; - task::task().future_result(|+r| { result = Some(r); }).spawn(child); + task::task().future_result(|+r| { result = Some(move r); }).spawn(child); error!("1"); yield(); error!("2"); yield(); error!("3"); - future::get(&option::unwrap(result)); + future::get(&option::unwrap(move result)); } fn child() { diff --git a/src/test/run-pass/yield1.rs b/src/test/run-pass/yield1.rs index 05c5e833bab..ec77a686324 100644 --- a/src/test/run-pass/yield1.rs +++ b/src/test/run-pass/yield1.rs @@ -4,10 +4,10 @@ use task::*; fn main() { let mut result = None; - task::task().future_result(|+r| { result = Some(r); }).spawn(child); + task::task().future_result(|+r| { result = Some(move r); }).spawn(child); error!("1"); yield(); - future::get(&option::unwrap(result)); + future::get(&option::unwrap(move result)); } fn child() { error!("2"); } |
