tests/tutorials: Get rid of move.

This commit is contained in:
Luqman Aden 2013-02-15 02:44:18 -08:00
parent e244f103c9
commit 178882c98f
150 changed files with 409 additions and 411 deletions

View File

@ -213,7 +213,7 @@ else enum extern
false fn for false fn for
if impl if impl
let log loop let log loop
match mod move mut match mod mut
priv pub pure priv pub pure
ref return ref return
self static struct super self static struct super

View File

@ -431,7 +431,7 @@ fn example5c(x: @S) -> int {
let y = &v.g; let y = &v.g;
... ...
} }
x.f = move v; // Replace x.f x.f = v; // Replace x.f
... ...
# return 0; # return 0;
} }

View File

@ -161,7 +161,7 @@ use pipes::{stream, Port, Chan};
let (port, chan): (Port<int>, Chan<int>) = stream(); let (port, chan): (Port<int>, Chan<int>) = stream();
do spawn |move chan| { do spawn || {
let result = some_expensive_computation(); let result = some_expensive_computation();
chan.send(result); chan.send(result);
} }
@ -192,7 +192,7 @@ spawns the child task.
# use pipes::{stream, Port, Chan}; # use pipes::{stream, Port, Chan};
# fn some_expensive_computation() -> int { 42 } # fn some_expensive_computation() -> int { 42 }
# let (port, chan) = stream(); # let (port, chan) = stream();
do spawn |move chan| { do spawn || {
let result = some_expensive_computation(); let result = some_expensive_computation();
chan.send(result); chan.send(result);
} }
@ -229,7 +229,7 @@ following program is ill-typed:
# fn some_expensive_computation() -> int { 42 } # fn some_expensive_computation() -> int { 42 }
let (port, chan) = stream(); let (port, chan) = stream();
do spawn |move chan| { do spawn {
chan.send(some_expensive_computation()); chan.send(some_expensive_computation());
} }
@ -248,12 +248,12 @@ Instead we can use a `SharedChan`, a type that allows a single
use pipes::{stream, SharedChan}; use pipes::{stream, SharedChan};
let (port, chan) = stream(); let (port, chan) = stream();
let chan = SharedChan(move chan); let chan = SharedChan(chan);
for uint::range(0, 3) |init_val| { for uint::range(0, 3) |init_val| {
// Create a new channel handle to distribute to the child task // Create a new channel handle to distribute to the child task
let child_chan = chan.clone(); let child_chan = chan.clone();
do spawn |move child_chan| { do spawn {
child_chan.send(some_expensive_computation(init_val)); child_chan.send(some_expensive_computation(init_val));
} }
} }
@ -283,10 +283,10 @@ might look like the example below.
// Create a vector of ports, one for each child task // Create a vector of ports, one for each child task
let ports = do vec::from_fn(3) |init_val| { let ports = do vec::from_fn(3) |init_val| {
let (port, chan) = stream(); let (port, chan) = stream();
do spawn |move chan| { do spawn {
chan.send(some_expensive_computation(init_val)); chan.send(some_expensive_computation(init_val));
} }
move port port
}; };
// Wait on each port, accumulating the results // Wait on each port, accumulating the results
@ -398,13 +398,13 @@ before returning. Hence:
# fn sleep_forever() { loop { task::yield() } } # fn sleep_forever() { loop { task::yield() } }
# do task::try { # do task::try {
let (receiver, sender): (Port<int>, Chan<int>) = stream(); let (receiver, sender): (Port<int>, Chan<int>) = stream();
do spawn |move receiver| { // Bidirectionally linked do spawn { // Bidirectionally linked
// Wait for the supervised child task to exist. // Wait for the supervised child task to exist.
let message = receiver.recv(); let message = receiver.recv();
// Kill both it and the parent task. // Kill both it and the parent task.
assert message != 42; assert message != 42;
} }
do try |move sender| { // Unidirectionally linked do try { // Unidirectionally linked
sender.send(42); sender.send(42);
sleep_forever(); // Will get woken up by force sleep_forever(); // Will get woken up by force
} }
@ -505,7 +505,7 @@ Here is the code for the parent task:
let (from_child, to_child) = DuplexStream(); let (from_child, to_child) = DuplexStream();
do spawn |move to_child| { do spawn {
stringifier(&to_child); stringifier(&to_child);
}; };

View File

@ -1260,7 +1260,7 @@ Moving it into a mutable slot makes the elements assignable.
let crayons: ~[Crayon] = ~[BananaMania, Beaver, Bittersweet]; let crayons: ~[Crayon] = ~[BananaMania, Beaver, Bittersweet];
// Put the vector into a mutable slot // Put the vector into a mutable slot
let mut mutable_crayons = move crayons; let mut mutable_crayons = crayons;
// Now it's mutable to the bone // Now it's mutable to the bone
mutable_crayons[0] = Apricot; mutable_crayons[0] = Apricot;

View File

@ -1229,7 +1229,7 @@ pub fn encode_metadata(parms: encode_parms, crate: &crate) -> ~[u8] {
let ecx: @encode_ctxt = @encode_ctxt({ let ecx: @encode_ctxt = @encode_ctxt({
diag: parms.diag, diag: parms.diag,
tcx: parms.tcx, tcx: parms.tcx,
stats: @mut move stats, stats: @mut stats,
reachable: parms.reachable, reachable: parms.reachable,
reexports2: parms.reexports2, reexports2: parms.reexports2,
item_symbols: parms.item_symbols, item_symbols: parms.item_symbols,

View File

@ -27,7 +27,7 @@ pub mod kitties {
cat { cat {
meows: in_x, meows: in_x,
how_hungry: in_y, how_hungry: in_y,
info: move in_info info: in_info
} }
} }
} }

View File

@ -27,7 +27,7 @@ fn collect_dvec(num: uint) -> ~[uint] {
for uint::range(0u, num) |i| { for uint::range(0u, num) |i| {
result.push(i); result.push(i);
} }
return dvec::unwrap(move result); return dvec::unwrap(result);
} }
fn main() { fn main() {

View File

@ -141,7 +141,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
}; };
} }
move marks marks
} }
/** /**
@ -260,7 +260,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
i += 1; i += 1;
let old_len = colors.len(); let old_len = colors.len();
let color = arc::ARC(move colors); let color = arc::ARC(colors);
let color_vec = arc::get(&color); // FIXME #3387 requires this temp let color_vec = arc::get(&color); // FIXME #3387 requires this temp
colors = do par::mapi(*color_vec) { colors = do par::mapi(*color_vec) {

View File

@ -27,7 +27,7 @@ use io::WriterUtil;
use pipes::{Port, Chan, SharedChan}; use pipes::{Port, Chan, SharedChan};
macro_rules! move_out ( macro_rules! move_out (
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } } { $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
) )
enum request { enum request {
@ -58,7 +58,7 @@ fn run(args: &[~str]) {
let (from_child, to_parent) = pipes::stream(); let (from_child, to_parent) = pipes::stream();
let (from_parent, to_child) = pipes::stream(); let (from_parent, to_child) = pipes::stream();
let to_child = SharedChan(move to_child); let to_child = SharedChan(to_child);
let size = uint::from_str(args[1]).get(); let size = uint::from_str(args[1]).get();
let workers = uint::from_str(args[2]).get(); let workers = uint::from_str(args[2]).get();
@ -68,8 +68,8 @@ fn run(args: &[~str]) {
for uint::range(0, workers) |_i| { for uint::range(0, workers) |_i| {
let to_child = to_child.clone(); let to_child = to_child.clone();
do task::task().future_result(|+r| { do task::task().future_result(|+r| {
worker_results.push(move r); worker_results.push(r);
}).spawn |move to_child| { }).spawn || {
for uint::range(0, size / workers) |_i| { for uint::range(0, size / workers) |_i| {
//error!("worker %?: sending %? bytes", i, num_bytes); //error!("worker %?: sending %? bytes", i, num_bytes);
to_child.send(bytes(num_bytes)); to_child.send(bytes(num_bytes));
@ -77,7 +77,7 @@ fn run(args: &[~str]) {
//error!("worker %? exiting", i); //error!("worker %? exiting", i);
}; };
} }
do task::spawn |move from_parent, move to_parent| { do task::spawn || {
server(from_parent, to_parent); server(from_parent, to_parent);
} }

View File

@ -23,7 +23,7 @@ use io::WriterUtil;
use pipes::{Port, PortSet, Chan}; use pipes::{Port, PortSet, Chan};
macro_rules! move_out ( macro_rules! move_out (
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } } { $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
) )
enum request { enum request {
@ -54,7 +54,7 @@ fn run(args: &[~str]) {
let (from_child, to_parent) = pipes::stream(); let (from_child, to_parent) = pipes::stream();
let (from_parent_, to_child) = pipes::stream(); let (from_parent_, to_child) = pipes::stream();
let from_parent = PortSet(); let from_parent = PortSet();
from_parent.add(move from_parent_); from_parent.add(from_parent_);
let size = uint::from_str(args[1]).get(); let size = uint::from_str(args[1]).get();
let workers = uint::from_str(args[2]).get(); let workers = uint::from_str(args[2]).get();
@ -63,10 +63,10 @@ fn run(args: &[~str]) {
let mut worker_results = ~[]; let mut worker_results = ~[];
for uint::range(0, workers) |_i| { for uint::range(0, workers) |_i| {
let (from_parent_, to_child) = pipes::stream(); let (from_parent_, to_child) = pipes::stream();
from_parent.add(move from_parent_); from_parent.add(from_parent_);
do task::task().future_result(|+r| { do task::task().future_result(|+r| {
worker_results.push(move r); worker_results.push(r);
}).spawn |move to_child| { }).spawn || {
for uint::range(0, size / workers) |_i| { for uint::range(0, size / workers) |_i| {
//error!("worker %?: sending %? bytes", i, num_bytes); //error!("worker %?: sending %? bytes", i, num_bytes);
to_child.send(bytes(num_bytes)); to_child.send(bytes(num_bytes));
@ -74,7 +74,7 @@ fn run(args: &[~str]) {
//error!("worker %? exiting", i); //error!("worker %? exiting", i);
}; };
} }
do task::spawn |move from_parent, move to_parent| { do task::spawn || {
server(from_parent, to_parent); server(from_parent, to_parent);
} }

View File

@ -40,7 +40,7 @@ fn recv(p: &pipe) -> uint {
fn init() -> (pipe,pipe) { fn init() -> (pipe,pipe) {
let m = arc::MutexARC(~[]); let m = arc::MutexARC(~[]);
((&m).clone(), move m) ((&m).clone(), m)
} }
@ -48,18 +48,18 @@ fn thread_ring(i: uint,
count: uint, count: uint,
+num_chan: pipe, +num_chan: pipe,
+num_port: pipe) { +num_port: pipe) {
let mut num_chan = move Some(move num_chan); let mut num_chan = Some(num_chan);
let mut num_port = move Some(move num_port); let mut num_port = Some(num_port);
// Send/Receive lots of messages. // Send/Receive lots of messages.
for uint::range(0u, count) |j| { for uint::range(0u, count) |j| {
//error!("task %?, iter %?", i, j); //error!("task %?, iter %?", i, j);
let mut num_chan2 = option::swap_unwrap(&mut num_chan); let mut num_chan2 = option::swap_unwrap(&mut num_chan);
let mut num_port2 = option::swap_unwrap(&mut num_port); let mut num_port2 = option::swap_unwrap(&mut num_port);
send(&num_chan2, i * j); send(&num_chan2, i * j);
num_chan = Some(move num_chan2); num_chan = Some(num_chan2);
let _n = recv(&num_port2); let _n = recv(&num_port2);
//log(error, _n); //log(error, _n);
num_port = Some(move num_port2); num_port = Some(num_port2);
}; };
} }
@ -77,7 +77,7 @@ fn main() {
let msg_per_task = uint::from_str(args[2]).get(); let msg_per_task = uint::from_str(args[2]).get();
let (num_chan, num_port) = init(); let (num_chan, num_port) = init();
let mut num_chan = Some(move num_chan); let mut num_chan = Some(num_chan);
let start = time::precise_time_s(); let start = time::precise_time_s();
@ -89,22 +89,22 @@ fn main() {
let (new_chan, num_port) = init(); let (new_chan, num_port) = init();
let num_chan2 = ~mut None; let num_chan2 = ~mut None;
*num_chan2 <-> num_chan; *num_chan2 <-> num_chan;
let num_port = ~mut Some(move num_port); let num_port = ~mut Some(num_port);
let new_future = future::spawn(|move num_chan2, move num_port| { let new_future = do future::spawn() || {
let mut num_chan = None; let mut num_chan = None;
num_chan <-> *num_chan2; num_chan <-> *num_chan2;
let mut num_port1 = None; let mut num_port1 = None;
num_port1 <-> *num_port; num_port1 <-> *num_port;
thread_ring(i, msg_per_task, thread_ring(i, msg_per_task,
option::unwrap(move num_chan), option::unwrap(num_chan),
option::unwrap(move num_port1)) option::unwrap(num_port1))
}); };
futures.push(move new_future); futures.push(new_future);
num_chan = Some(move new_chan); num_chan = Some(new_chan);
}; };
// do our iteration // do our iteration
thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port); thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
// synchronize // synchronize
for futures.each |f| { f.get() }; for futures.each |f| { f.get() };

View File

@ -29,15 +29,15 @@ proto! ring (
) )
macro_rules! move_out ( macro_rules! move_out (
($x:expr) => { unsafe { let y = move *ptr::addr_of(&$x); move y } } ($x:expr) => { unsafe { let y = *ptr::addr_of(&$x); y } }
) )
fn thread_ring(i: uint, fn thread_ring(i: uint,
count: uint, count: uint,
+num_chan: ring::client::num, +num_chan: ring::client::num,
+num_port: ring::server::num) { +num_port: ring::server::num) {
let mut num_chan = move Some(move num_chan); let mut num_chan = Some(num_chan);
let mut num_port = move Some(move num_port); let mut num_port = Some(num_port);
// Send/Receive lots of messages. // Send/Receive lots of messages.
for uint::range(0, count) |j| { for uint::range(0, count) |j| {
//error!("task %?, iter %?", i, j); //error!("task %?, iter %?", i, j);
@ -45,9 +45,9 @@ fn thread_ring(i: uint,
let mut num_port2 = None; let mut num_port2 = None;
num_chan2 <-> num_chan; num_chan2 <-> num_chan;
num_port2 <-> num_port; num_port2 <-> num_port;
num_chan = Some(ring::client::num(option::unwrap(move num_chan2), i * j)); num_chan = Some(ring::client::num(option::unwrap(num_chan2), i * j));
let port = option::unwrap(move num_port2); let port = option::unwrap(num_port2);
match recv(move port) { match recv(port) {
ring::num(_n, p) => { ring::num(_n, p) => {
//log(error, _n); //log(error, _n);
num_port = Some(move_out!(p)); num_port = Some(move_out!(p));
@ -70,7 +70,7 @@ fn main() {
let msg_per_task = uint::from_str(args[2]).get(); let msg_per_task = uint::from_str(args[2]).get();
let (num_chan, num_port) = ring::init(); let (num_chan, num_port) = ring::init();
let mut num_chan = Some(move num_chan); let mut num_chan = Some(num_chan);
let start = time::precise_time_s(); let start = time::precise_time_s();
@ -82,23 +82,22 @@ fn main() {
let (new_chan, num_port) = ring::init(); let (new_chan, num_port) = ring::init();
let num_chan2 = ~mut None; let num_chan2 = ~mut None;
*num_chan2 <-> num_chan; *num_chan2 <-> num_chan;
let num_port = ~mut Some(move num_port); let num_port = ~mut Some(num_port);
let new_future = do future::spawn let new_future = do future::spawn || {
|move num_chan2, move num_port| {
let mut num_chan = None; let mut num_chan = None;
num_chan <-> *num_chan2; num_chan <-> *num_chan2;
let mut num_port1 = None; let mut num_port1 = None;
num_port1 <-> *num_port; num_port1 <-> *num_port;
thread_ring(i, msg_per_task, thread_ring(i, msg_per_task,
option::unwrap(move num_chan), option::unwrap(num_chan),
option::unwrap(move num_port1)) option::unwrap(num_port1))
}; };
futures.push(move new_future); futures.push(new_future);
num_chan = Some(move new_chan); num_chan = Some(new_chan);
}; };
// do our iteration // do our iteration
thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port); thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
// synchronize // synchronize
for futures.each |f| { f.get() }; for futures.each |f| { f.get() };

View File

@ -40,7 +40,7 @@ fn recv(p: &pipe) -> uint {
fn init() -> (pipe,pipe) { fn init() -> (pipe,pipe) {
let x = arc::RWARC(~[]); let x = arc::RWARC(~[]);
((&x).clone(), move x) ((&x).clone(), x)
} }
@ -48,18 +48,18 @@ fn thread_ring(i: uint,
count: uint, count: uint,
+num_chan: pipe, +num_chan: pipe,
+num_port: pipe) { +num_port: pipe) {
let mut num_chan = move Some(move num_chan); let mut num_chan = Some(num_chan);
let mut num_port = move Some(move num_port); let mut num_port = Some(num_port);
// Send/Receive lots of messages. // Send/Receive lots of messages.
for uint::range(0u, count) |j| { for uint::range(0u, count) |j| {
//error!("task %?, iter %?", i, j); //error!("task %?, iter %?", i, j);
let mut num_chan2 = option::swap_unwrap(&mut num_chan); let mut num_chan2 = option::swap_unwrap(&mut num_chan);
let mut num_port2 = option::swap_unwrap(&mut num_port); let mut num_port2 = option::swap_unwrap(&mut num_port);
send(&num_chan2, i * j); send(&num_chan2, i * j);
num_chan = Some(move num_chan2); num_chan = Some(num_chan2);
let _n = recv(&num_port2); let _n = recv(&num_port2);
//log(error, _n); //log(error, _n);
num_port = Some(move num_port2); num_port = Some(num_port2);
}; };
} }
@ -77,7 +77,7 @@ fn main() {
let msg_per_task = uint::from_str(args[2]).get(); let msg_per_task = uint::from_str(args[2]).get();
let (num_chan, num_port) = init(); let (num_chan, num_port) = init();
let mut num_chan = Some(move num_chan); let mut num_chan = Some(num_chan);
let start = time::precise_time_s(); let start = time::precise_time_s();
@ -89,23 +89,22 @@ fn main() {
let (new_chan, num_port) = init(); let (new_chan, num_port) = init();
let num_chan2 = ~mut None; let num_chan2 = ~mut None;
*num_chan2 <-> num_chan; *num_chan2 <-> num_chan;
let num_port = ~mut Some(move num_port); let num_port = ~mut Some(num_port);
let new_future = do future::spawn let new_future = do future::spawn || {
|move num_chan2, move num_port| {
let mut num_chan = None; let mut num_chan = None;
num_chan <-> *num_chan2; num_chan <-> *num_chan2;
let mut num_port1 = None; let mut num_port1 = None;
num_port1 <-> *num_port; num_port1 <-> *num_port;
thread_ring(i, msg_per_task, thread_ring(i, msg_per_task,
option::unwrap(move num_chan), option::unwrap(num_chan),
option::unwrap(move num_port1)) option::unwrap(num_port1))
}; };
futures.push(move new_future); futures.push(new_future);
num_chan = Some(move new_chan); num_chan = Some(new_chan);
}; };
// do our iteration // do our iteration
thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port); thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
// synchronize // synchronize
for futures.each |f| { f.get() }; for futures.each |f| { f.get() };

View File

@ -35,8 +35,8 @@ fn Noise2DContext() -> ~Noise2DContext {
r.shuffle_mut(permutations); r.shuffle_mut(permutations);
~Noise2DContext{ ~Noise2DContext{
rgradients: move rgradients, rgradients: rgradients,
permutations: move permutations, permutations: permutations,
} }
} }

View File

@ -45,17 +45,17 @@ proto! pingpong_unbounded (
// This stuff should go in libcore::pipes // This stuff should go in libcore::pipes
macro_rules! move_it ( macro_rules! move_it (
{ $x:expr } => { let t = move *ptr::addr_of(&($x)); move t } { $x:expr } => { let t = *ptr::addr_of(&($x)); t }
) )
macro_rules! follow ( macro_rules! follow (
{ {
$($message:path($($x: ident),+) -> $next:ident $e:expr)+ $($message:path($($x: ident),+) -> $next:ident $e:expr)+
} => ( } => (
|m| match move m { |m| match m {
$(Some($message($($x,)* move next)) => { $(Some($message($($x,)* next)) => {
let $next = move next; let $next = next;
move $e })+ $e })+
_ => { fail!() } _ => { fail!() }
} }
); );
@ -63,10 +63,10 @@ macro_rules! follow (
{ {
$($message:path -> $next:ident $e:expr)+ $($message:path -> $next:ident $e:expr)+
} => ( } => (
|m| match move m { |m| match m {
$(Some($message(move next)) => { $(Some($message(next)) => {
let $next = move next; let $next = next;
move $e })+ $e })+
_ => { fail!() } _ => { fail!() }
} }
) )
@ -74,7 +74,7 @@ macro_rules! follow (
fn switch<T: Owned, Tb: Owned, U>(+endp: pipes::RecvPacketBuffered<T, Tb>, fn switch<T: Owned, Tb: Owned, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
f: fn(+v: Option<T>) -> U) -> U { f: fn(+v: Option<T>) -> U) -> U {
f(pipes::try_recv(move endp)) f(pipes::try_recv(endp))
} }
// Here's the benchmark // Here's the benchmark
@ -84,10 +84,10 @@ fn bounded(count: uint) {
let mut ch = do spawn_service(init) |ch| { let mut ch = do spawn_service(init) |ch| {
let mut count = count; let mut count = count;
let mut ch = move ch; let mut ch = ch;
while count > 0 { while count > 0 {
ch = switch(move ch, follow! ( ch = switch(ch, follow! (
ping -> next { server::pong(move next) } ping -> next { server::pong(next) }
)); ));
count -= 1; count -= 1;
@ -96,10 +96,10 @@ fn bounded(count: uint) {
let mut count = count; let mut count = count;
while count > 0 { while count > 0 {
let ch_ = client::ping(move ch); let ch_ = client::ping(ch);
ch = switch(move ch_, follow! ( ch = switch(ch_, follow! (
pong -> next { move next } pong -> next { next }
)); ));
count -= 1; count -= 1;
@ -111,10 +111,10 @@ fn unbounded(count: uint) {
let mut ch = do spawn_service(init) |ch| { let mut ch = do spawn_service(init) |ch| {
let mut count = count; let mut count = count;
let mut ch = move ch; let mut ch = ch;
while count > 0 { while count > 0 {
ch = switch(move ch, follow! ( ch = switch(ch, follow! (
ping -> next { server::pong(move next) } ping -> next { server::pong(next) }
)); ));
count -= 1; count -= 1;
@ -123,10 +123,10 @@ fn unbounded(count: uint) {
let mut count = count; let mut count = count;
while count > 0 { while count > 0 {
let ch_ = client::ping(move ch); let ch_ = client::ping(ch);
ch = switch(move ch_, follow! ( ch = switch(ch_, follow! (
pong -> next { move next } pong -> next { next }
)); ));
count -= 1; count -= 1;

View File

@ -156,7 +156,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
let to_rendezvous_log = to_rendezvous_log.clone(); let to_rendezvous_log = to_rendezvous_log.clone();
let (from_rendezvous, to_creature) = stream(); let (from_rendezvous, to_creature) = stream();
let from_rendezvous = Cell(from_rendezvous); let from_rendezvous = Cell(from_rendezvous);
do task::spawn |move ii, move col| { do task::spawn || {
creature(ii, col, from_rendezvous.take(), to_rendezvous.clone(), creature(ii, col, from_rendezvous.take(), to_rendezvous.clone(),
to_rendezvous_log.clone()); to_rendezvous_log.clone());
} }

View File

@ -128,7 +128,7 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::Port<~[u8]>,
_ => { ~"" } _ => { ~"" }
}; };
to_parent.send(move buffer); to_parent.send(buffer);
} }
// given a FASTA file on stdin, process sequence THREE // given a FASTA file on stdin, process sequence THREE
@ -149,23 +149,23 @@ fn main() {
// initialize each sequence sorter // initialize each sequence sorter
let sizes = ~[1,2,3,4,6,12,18]; let sizes = ~[1,2,3,4,6,12,18];
let streams = vec::map(sizes, |_sz| Some(stream())); let streams = vec::map(sizes, |_sz| Some(stream()));
let mut streams = move streams; let mut streams = streams;
let mut from_child = ~[]; let mut from_child = ~[];
let to_child = vec::mapi(sizes, |ii, sz| { let to_child = vec::mapi(sizes, |ii, sz| {
let sz = *sz; let sz = *sz;
let mut stream = None; let mut stream = None;
stream <-> streams[ii]; stream <-> streams[ii];
let (from_child_, to_parent_) = option::unwrap(move stream); let (from_child_, to_parent_) = option::unwrap(stream);
from_child.push(move from_child_); from_child.push(from_child_);
let (from_parent, to_child) = pipes::stream(); let (from_parent, to_child) = pipes::stream();
do task::spawn_with(move from_parent) |move to_parent_, from_parent| { do task::spawn_with(from_parent) |from_parent| {
make_sequence_processor(sz, from_parent, to_parent_); make_sequence_processor(sz, from_parent, to_parent_);
}; };
move to_child to_child
}); });

View File

@ -172,7 +172,7 @@ fn main() {
let pchan = pipes::SharedChan(pchan); let pchan = pipes::SharedChan(pchan);
for uint::range(0_u, size) |j| { for uint::range(0_u, size) |j| {
let cchan = pchan.clone(); let cchan = pchan.clone();
do task::spawn |move cchan| { cchan.send(chanmb(j, size)) }; do task::spawn || { cchan.send(chanmb(j, size)) };
}; };
writer(path, pport, size); writer(path, pport, size);
} }

View File

@ -43,15 +43,15 @@ fn fib(n: int) -> int {
} else { } else {
let p = pipes::PortSet(); let p = pipes::PortSet();
let ch = p.chan(); let ch = p.chan();
task::spawn(|move ch| pfib(ch, n - 1) ); task::spawn(|| pfib(ch, n - 1) );
let ch = p.chan(); let ch = p.chan();
task::spawn(|move ch| pfib(ch, n - 2) ); task::spawn(|| pfib(ch, n - 2) );
c.send(p.recv() + p.recv()); c.send(p.recv() + p.recv());
} }
} }
let (p, ch) = pipes::stream(); let (p, ch) = pipes::stream();
let _t = task::spawn(|move ch| pfib(ch, n) ); let _t = task::spawn(|| pfib(ch, n) );
p.recv() p.recv()
} }
@ -86,7 +86,7 @@ fn stress(num_tasks: int) {
let mut results = ~[]; let mut results = ~[];
for range(0, num_tasks) |i| { for range(0, num_tasks) |i| {
do task::task().future_result(|+r| { do task::task().future_result(|+r| {
results.push(move r); results.push(r);
}).spawn { }).spawn {
stress_task(i); stress_task(i);
} }

View File

@ -99,6 +99,6 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
} }
}; };
recurse_or_fail(depth, Some(move st)); recurse_or_fail(depth, Some(st));
} }
} }

View File

@ -19,14 +19,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. // 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 // With this code, only as many generations are alive at a time as tasks
// alive at a time, // alive at a time,
let c = ~mut Some(move c); let c = ~mut Some(c);
do task::spawn_supervised |move c| { do task::spawn_supervised || {
let c = option::swap_unwrap(c); let c = option::swap_unwrap(c);
if gens_left & 1 == 1 { if gens_left & 1 == 1 {
task::yield(); // shake things up a bit task::yield(); // shake things up a bit
} }
if gens_left > 0 { if gens_left > 0 {
child_generation(gens_left - 1, move c); // recurse child_generation(gens_left - 1, c); // recurse
} else { } else {
c.send(()) c.send(())
} }
@ -44,7 +44,7 @@ fn main() {
}; };
let (p,c) = pipes::stream(); let (p,c) = pipes::stream();
child_generation(uint::from_str(args[1]).get(), move c); child_generation(uint::from_str(args[1]).get(), c);
if p.try_recv().is_none() { if p.try_recv().is_none() {
fail!(~"it happened when we slumbered"); fail!(~"it happened when we slumbered");
} }

View File

@ -46,9 +46,9 @@ fn grandchild_group(num_tasks: uint) {
fn spawn_supervised_blocking(myname: &str, +f: fn~()) { fn spawn_supervised_blocking(myname: &str, +f: fn~()) {
let mut res = None; let mut res = None;
task::task().future_result(|+r| res = Some(move r)).supervised().spawn(move f); task::task().future_result(|+r| res = Some(r)).supervised().spawn(f);
error!("%s group waiting", myname); error!("%s group waiting", myname);
let x = option::unwrap(move res).recv(); let x = option::unwrap(res).recv();
assert x == task::Success; assert x == task::Success;
} }

View File

@ -18,8 +18,8 @@ impl Drop for X {
fn main() { fn main() {
let x = Some(X { x: () }); let x = Some(X { x: () });
match move x { match x {
Some(ref _y @ move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern Some(ref _y @ _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!() None => fail!()
} }
} }

View File

@ -18,8 +18,8 @@ impl Drop for X {
fn main() { fn main() {
let x = Some((X { x: () }, X { x: () })); let x = Some((X { x: () }, X { x: () }));
match move x { match x {
Some((ref _y, move _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!() None => fail!()
} }
} }

View File

@ -20,8 +20,8 @@ enum double_option<T,U> { some2(T,U), none2 }
fn main() { fn main() {
let x = some2(X { x: () }, X { x: () }); let x = some2(X { x: () }, X { x: () });
match move x { match x {
some2(ref _y, move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern some2(ref _y, _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
none2 => fail!() none2 => fail!()
} }
} }

View File

@ -18,8 +18,8 @@ impl Drop for X {
fn main() { fn main() {
let x = Some((X { x: () }, X { x: () })); let x = Some((X { x: () }, X { x: () }));
match move x { match x {
Some((move _y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!() None => fail!()
} }
} }

View File

@ -12,9 +12,9 @@ fn main() {
let (p,c) = pipes::stream(); let (p,c) = pipes::stream();
let x = Some(p); let x = Some(p);
c.send(false); c.send(false);
match move x { match x {
Some(move z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard Some(z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard
Some(move z) => { assert !z.recv(); }, Some(z) => { assert !z.recv(); },
None => fail!() None => fail!()
} }
} }

View File

@ -21,7 +21,7 @@ impl Drop for X {
fn main() { fn main() {
let x = Some(X { x: () }); let x = Some(X { x: () });
match x { match x {
Some(move _z) => { }, //~ ERROR cannot bind by-move when matching an lvalue Some(_z) => { }, //~ ERROR cannot bind by-move when matching an lvalue
None => fail!() None => fail!()
} }
} }

View File

@ -23,7 +23,7 @@ struct Y { y: Option<X> }
fn main() { fn main() {
let x = Y { y: Some(X { x: () }) }; let x = Y { y: Some(X { x: () }) };
match x.y { match x.y {
Some(move _z) => { }, //~ ERROR cannot bind by-move when matching an lvalue Some(_z) => { }, //~ ERROR cannot bind by-move when matching an lvalue
None => fail!() None => fail!()
} }
} }

View File

@ -18,8 +18,8 @@ impl Drop for X {
fn main() { fn main() {
let x = Some(X { x: () }); let x = Some(X { x: () });
match move x { match x {
Some(move _y @ ref _z) => { }, //~ ERROR cannot bind by-move with sub-bindings Some(_y @ ref _z) => { }, //~ ERROR cannot bind by-move with sub-bindings
None => fail!() None => fail!()
} }
} }

View File

@ -20,6 +20,6 @@ impl Add<foo, foo> for foo {
fn main() { fn main() {
let x = foo(~3); let x = foo(~3);
let _y = x + move x; let _y = x + x;
//~^ ERROR moving out of immutable local variable prohibited due to outstanding loan //~^ ERROR moving out of immutable local variable prohibited due to outstanding loan
} }

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn foo(x: *~int) -> ~int { fn foo(x: *~int) -> ~int {
let y = move *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block let y = *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
return y; return y;
} }

View File

@ -4,7 +4,7 @@ fn a() -> &[int] {
[_a, ..tail] => tail, [_a, ..tail] => tail,
_ => fail!(~"foo") _ => fail!(~"foo")
}; };
move tail tail
} }
fn main() { fn main() {

View File

@ -4,7 +4,7 @@ fn a() -> &int {
[_a, ..tail] => &tail[0], [_a, ..tail] => &tail[0],
_ => fail!(~"foo") _ => fail!(~"foo")
}; };
move tail tail
} }
fn main() { fn main() {

View File

@ -23,7 +23,7 @@ fn foo(i:int) -> foo {
} }
fn main() { fn main() {
let x = move foo(10); let x = foo(10);
let _y = copy x; let _y = copy x;
//~^ ERROR copying a value of non-copyable type `foo` //~^ ERROR copying a value of non-copyable type `foo`
log(error, x); log(error, x);

View File

@ -34,7 +34,7 @@ fn main() {
let mut res = foo(x); let mut res = foo(x);
let mut v = ~[]; let mut v = ~[];
v = move ~[(move res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Copy` v = ~[(res)] + v; //~ instantiating a type parameter with an incompatible type `foo`, which does not fulfill `Copy`
assert (v.len() == 2); assert (v.len() == 2);
} }

View File

@ -17,5 +17,5 @@ struct S<T: Const> {
fn main() { fn main() {
let a1 = ~S{ s: true, cant_nest: () }; let a1 = ~S{ s: true, cant_nest: () };
let _a2 = ~S{ s: move a1, cant_nest: () }; let _a2 = ~S{ s: a1, cant_nest: () };
} }

View File

@ -14,5 +14,5 @@ fn main() {
let x = @3u; let x = @3u;
let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
let _ = fn~(copy x) { foo(x); }; //~ ERROR value has non-owned type `@uint` let _ = fn~(copy x) { foo(x); }; //~ ERROR value has non-owned type `@uint`
let _ = fn~(move x) { foo(x); }; //~ ERROR value has non-owned type `@uint` let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
} }

View File

@ -68,5 +68,5 @@ impl Drop for r {
fn main() { fn main() {
let x = r { x: () }; let x = r { x: () };
fn@(move x) { copy x; }; //~ ERROR copying a value of non-copyable type fn@() { copy x; }; //~ ERROR copying a value of non-copyable type
} }

View File

@ -37,7 +37,7 @@ fn foo(i:int) -> foo {
} }
fn main() { fn main() {
let x = move foo(10); let x = foo(10);
let _y = copy x; //~ ERROR copying a value of non-copyable type let _y = copy x; //~ ERROR copying a value of non-copyable type
log(error, x); log(error, x);
} }

View File

@ -17,7 +17,7 @@ impl Drop for r {
} }
fn main() { fn main() {
let i = move ~r { b: true }; let i = ~r { b: true };
let _j = copy i; //~ ERROR copying a value of non-copyable type let _j = copy i; //~ ERROR copying a value of non-copyable type
log(debug, i); log(debug, i);
} }

View File

@ -13,5 +13,5 @@ fn f<T: Owned>(_i: T) {
fn main() { fn main() {
let i = ~@100; let i = ~@100;
f(move i); //~ ERROR does not fulfill `Owned` f(i); //~ ERROR does not fulfill `Owned`
} }

View File

@ -24,8 +24,8 @@ fn f<T>(+_i: ~[T], +_j: ~[T]) {
fn main() { fn main() {
let i1 = @mut 0; let i1 = @mut 0;
let i2 = @mut 1; let i2 = @mut 1;
let r1 = move ~[~r { i: i1 }]; let r1 = ~[~r { i: i1 }];
let r2 = move ~[~r { i: i2 }]; let r2 = ~[~r { i: i2 }];
f(copy r1, copy r2); f(copy r1, copy r2);
//~^ ERROR copying a value of non-copyable type //~^ ERROR copying a value of non-copyable type
//~^^ ERROR copying a value of non-copyable type //~^^ ERROR copying a value of non-copyable type

View File

@ -26,5 +26,5 @@ fn foo(i:int, j: @~str) -> foo {
fn main() { fn main() {
let cat = ~"kitty"; let cat = ~"kitty";
let (_, ch) = pipes::stream(); //~ ERROR does not fulfill `Owned` let (_, ch) = pipes::stream(); //~ ERROR does not fulfill `Owned`
ch.send(foo(42, @(move cat))); //~ ERROR does not fulfill `Owned` ch.send(foo(42, @(cat))); //~ ERROR does not fulfill `Owned`
} }

View File

@ -22,8 +22,8 @@ impl Drop for r {
fn main() { fn main() {
// This can't make sense as it would copy the classes // This can't make sense as it would copy the classes
let i = move ~[r(0)]; let i = ~[r(0)];
let j = move ~[r(1)]; let j = ~[r(1)];
let k = i + j; let k = i + j;
log(debug, j); log(debug, j);
} }

View File

@ -15,11 +15,11 @@
// error-pattern:ran out of stack // error-pattern:ran out of stack
fn main() { fn main() {
eat(move @0); eat(@0);
} }
fn eat( fn eat(
+a: @int +a: @int
) { ) {
eat(move a) eat(a)
} }

View File

@ -11,11 +11,11 @@
// xfail-test // xfail-test
// error-pattern:ran out of stack // error-pattern:ran out of stack
fn main() { fn main() {
eat(move ~0); eat(~0);
} }
fn eat( fn eat(
+a: ~int +a: ~int
) { ) {
eat(move a) eat(a)
} }

View File

@ -36,7 +36,7 @@ fn main() {
unsafe { unsafe {
let i1 = ~0; let i1 = ~0;
let i1p = cast::reinterpret_cast(&i1); let i1p = cast::reinterpret_cast(&i1);
cast::forget(move i1); cast::forget(i1);
let x = @r(i1p); let x = @r(i1p);
failfn(); failfn();
log(error, x); log(error, x);

View File

@ -16,6 +16,6 @@ fn f(a: @int) {
fn main() { fn main() {
let b = @0; let b = @0;
let g : fn@() = |move b|f(b); let g : fn@() = || f(b);
g(); g();
} }

View File

@ -15,5 +15,5 @@ fn f(-_a: @int) {
fn main() { fn main() {
let a = @0; let a = @0;
f(move a); f(a);
} }

View File

@ -19,5 +19,5 @@ fn r(i: int) -> r { r { i: i } }
fn main() { fn main() {
@0; @0;
let r = move r(0); let r = r(0);
} }

View File

@ -20,6 +20,6 @@ fn r(i: int) -> r { r { i: i } }
fn main() { fn main() {
@0; @0;
let r = move r(0); let r = r(0);
fail!(); fail!();
} }

View File

@ -10,7 +10,7 @@
pub fn main() { pub fn main() {
let x = Some(private::exclusive(true)); let x = Some(private::exclusive(true));
match move x { match x {
Some(ref z) if z.with(|b| *b) => { Some(ref z) if z.with(|b| *b) => {
do z.with |b| { assert *b; } do z.with |b| { assert *b; }
}, },

View File

@ -24,7 +24,7 @@ fn f2(a: int, f: fn(int)) -> int { f(1); return a; }
pub fn main() { pub fn main() {
let mut a = X {mut x: 1}, b = 2, c = 3; let mut a = X {mut x: 1}, b = 2, c = 3;
assert (f1(a, &mut b, move c) == 6); assert (f1(a, &mut b, c) == 6);
assert (a.x == 0); assert (a.x == 0);
assert (b == 10); assert (b == 10);
assert (f2(a.x, |x| a.x = 50 ) == 0); assert (f2(a.x, |x| a.x = 50 ) == 0);

View File

@ -46,7 +46,7 @@ fn test_ebml<A:
let ebml_w = &EBWriter::Encoder(wr); let ebml_w = &EBWriter::Encoder(wr);
a1.encode(ebml_w) a1.encode(ebml_w)
}; };
let d = EBReader::Doc(@move bytes); let d = EBReader::Doc(@bytes);
let a2: A = Decodable::decode(&EBReader::Decoder(d)); let a2: A = Decodable::decode(&EBReader::Decoder(d));
assert *a1 == a2; assert *a1 == a2;
} }

View File

@ -14,7 +14,7 @@ trait Pushable<T> {
impl<T> Pushable<T> for ~[T] { impl<T> Pushable<T> for ~[T] {
fn push_val(&mut self, +t: T) { fn push_val(&mut self, +t: T) {
self.push(move t); self.push(t);
} }
} }

View File

@ -17,8 +17,8 @@ fn dispose(+_x: arc::ARC<bool>) unsafe { }
pub fn main() { pub fn main() {
let p = arc::arc(true); let p = arc::arc(true);
let x = Some(p); let x = Some(p);
match move x { match x {
Some(move z) => { dispose(z); }, Some(z) => { dispose(z); },
None => fail!() None => fail!()
} }
} }

View File

@ -12,7 +12,7 @@
fn bar(x: *~int) -> ~int { fn bar(x: *~int) -> ~int {
unsafe { unsafe {
let y = move *x; let y = *x;
return y; return y;
} }
} }

View File

@ -11,21 +11,21 @@
pub fn main() { pub fn main() {
let x = ~1; let x = ~1;
let y = ptr::addr_of(&(*x)) as uint; let y = ptr::addr_of(&(*x)) as uint;
let lam_move = fn@(move x) -> uint { ptr::addr_of(&(*x)) as uint }; let lam_move = fn@() -> uint { ptr::addr_of(&(*x)) as uint };
assert lam_move() == y; assert lam_move() == y;
let x = ~2; let x = ~2;
let y = ptr::addr_of(&(*x)) as uint; let y = ptr::addr_of(&(*x)) as uint;
let lam_move: fn@() -> uint = |move x| ptr::addr_of(&(*x)) as uint; let lam_move: fn@() -> uint = || ptr::addr_of(&(*x)) as uint;
assert lam_move() == y; assert lam_move() == y;
let x = ~3; let x = ~3;
let y = ptr::addr_of(&(*x)) as uint; let y = ptr::addr_of(&(*x)) as uint;
let snd_move = fn~(move x) -> uint { ptr::addr_of(&(*x)) as uint }; let snd_move = fn~() -> uint { ptr::addr_of(&(*x)) as uint };
assert snd_move() == y; assert snd_move() == y;
let x = ~4; let x = ~4;
let y = ptr::addr_of(&(*x)) as uint; let y = ptr::addr_of(&(*x)) as uint;
let lam_move: fn~() -> uint = |move x| ptr::addr_of(&(*x)) as uint; let lam_move: fn~() -> uint = || ptr::addr_of(&(*x)) as uint;
assert lam_move() == y; assert lam_move() == y;
} }

View File

@ -26,7 +26,7 @@ fn cat<U>(in_x : uint, in_y : int, -in_info: ~[U]) -> cat<U> {
cat { cat {
meows: in_x, meows: in_x,
how_hungry: in_y, how_hungry: in_y,
info: move in_info info: in_info
} }
} }

View File

@ -31,6 +31,6 @@ pub fn main() {
assert *e == exp[i]; assert *e == exp[i];
} }
let v = dvec::unwrap(move d); let v = dvec::unwrap(d);
assert v == exp; assert v == exp;
} }

View File

@ -11,7 +11,7 @@
// This is what the signature to spawn should look like with bare functions // This is what the signature to spawn should look like with bare functions
fn spawn<T: Owned>(val: T, f: extern fn(T)) { fn spawn<T: Owned>(val: T, f: extern fn(T)) {
f(move val); f(val);
} }
fn f(+i: int) { fn f(+i: int) {

View File

@ -39,7 +39,7 @@ mod map_reduce {
for inputs.each |i| { for inputs.each |i| {
let ctrl = ctrl.clone(); let ctrl = ctrl.clone();
let i = copy *i; let i = copy *i;
task::spawn(|move i| map_task(ctrl.clone(), copy i) ); task::spawn(|| map_task(ctrl.clone(), copy i) );
} }
} }

View File

@ -32,7 +32,7 @@ fn r(i: @mut int) -> r {
fn test_box() { fn test_box() {
let i = @mut 0; let i = @mut 0;
{ {
let a = move @r(i); let a = @r(i);
} }
assert *i == 1; assert *i == 1;
} }
@ -40,7 +40,7 @@ fn test_box() {
fn test_rec() { fn test_rec() {
let i = @mut 0; let i = @mut 0;
{ {
let a = move Box {x: r(i)}; let a = Box {x: r(i)};
} }
assert *i == 1; assert *i == 1;
} }
@ -52,7 +52,7 @@ fn test_tag() {
let i = @mut 0; let i = @mut 0;
{ {
let a = move t0(r(i)); let a = t0(r(i));
} }
assert *i == 1; assert *i == 1;
} }
@ -60,7 +60,7 @@ fn test_tag() {
fn test_tup() { fn test_tup() {
let i = @mut 0; let i = @mut 0;
{ {
let a = move (r(i), 0); let a = (r(i), 0);
} }
assert *i == 1; assert *i == 1;
} }
@ -68,7 +68,7 @@ fn test_tup() {
fn test_unique() { fn test_unique() {
let i = @mut 0; let i = @mut 0;
{ {
let a = move ~r(i); let a = ~r(i);
} }
assert *i == 1; assert *i == 1;
} }
@ -76,7 +76,7 @@ fn test_unique() {
fn test_box_rec() { fn test_box_rec() {
let i = @mut 0; let i = @mut 0;
{ {
let a = move @Box { let a = @Box {
x: r(i) x: r(i)
}; };
} }

View File

@ -18,7 +18,7 @@ pub fn main() {
unsafe { unsafe {
let mut x = @1; let mut x = @1;
let mut y = @2; let mut y = @2;
rusti::move_val(&mut y, move x); rusti::move_val(&mut y, x);
assert *y == 1; assert *y == 1;
} }
} }

View File

@ -10,7 +10,7 @@
pub fn main() { pub fn main() {
let x = 1; let x = 1;
let y = fn@(move x) -> int { let y = fn@() -> int {
x x
}(); }();
} }

View File

@ -35,11 +35,11 @@ fn filter<A,IA:iterable<A>>(self: IA, prd: fn@(A) -> bool, blk: fn(A)) {
} }
fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
let mut b = move b0; let mut b = b0;
do self.iter |a| { do self.iter |a| {
b = move blk(b, a); b = blk(b, a);
} }
move b b
} }
fn range(lo: uint, hi: uint, it: fn(uint)) { fn range(lo: uint, hi: uint, it: fn(uint)) {

View File

@ -61,18 +61,18 @@ pub mod pipes {
// We should consider moving this to ::core::unsafe, although I // We should consider moving this to ::core::unsafe, although I
// suspect graydon would want us to use void pointers instead. // suspect graydon would want us to use void pointers instead.
pub unsafe fn uniquify<T>(+x: *T) -> ~T { pub unsafe fn uniquify<T>(+x: *T) -> ~T {
unsafe { cast::transmute(move x) } unsafe { cast::transmute(x) }
} }
pub fn swap_state_acq(+dst: &mut state, src: state) -> state { pub fn swap_state_acq(+dst: &mut state, src: state) -> state {
unsafe { unsafe {
transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int)) transmute(rusti::atomic_xchg_acq(transmute(dst), src as int))
} }
} }
pub fn swap_state_rel(+dst: &mut state, src: state) -> state { pub fn swap_state_rel(+dst: &mut state, src: state) -> state {
unsafe { unsafe {
transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int)) transmute(rusti::atomic_xchg_rel(transmute(dst), src as int))
} }
} }
@ -80,20 +80,20 @@ pub mod pipes {
let p = p.unwrap(); let p = p.unwrap();
let p = unsafe { uniquify(p) }; let p = unsafe { uniquify(p) };
assert (*p).payload.is_none(); assert (*p).payload.is_none();
(*p).payload = move Some(move payload); (*p).payload = Some(payload);
let old_state = swap_state_rel(&mut (*p).state, full); let old_state = swap_state_rel(&mut (*p).state, full);
match old_state { match old_state {
empty => { empty => {
// Yay, fastpath. // Yay, fastpath.
// The receiver will eventually clean this up. // The receiver will eventually clean this up.
unsafe { forget(move p); } unsafe { forget(p); }
} }
full => { fail!(~"duplicate send") } full => { fail!(~"duplicate send") }
blocked => { blocked => {
// The receiver will eventually clean this up. // The receiver will eventually clean this up.
unsafe { forget(move p); } unsafe { forget(p); }
} }
terminated => { terminated => {
// The receiver will never receive this. Rely on drop_glue // The receiver will never receive this. Rely on drop_glue
@ -113,7 +113,7 @@ pub mod pipes {
full => { full => {
let mut payload = None; let mut payload = None;
payload <-> (*p).payload; payload <-> (*p).payload;
return Some(option::unwrap(move payload)) return Some(option::unwrap(payload))
} }
terminated => { terminated => {
assert old_state == terminated; assert old_state == terminated;
@ -128,7 +128,7 @@ pub mod pipes {
match swap_state_rel(&mut (*p).state, terminated) { match swap_state_rel(&mut (*p).state, terminated) {
empty | blocked => { empty | blocked => {
// The receiver will eventually clean up. // The receiver will eventually clean up.
unsafe { forget(move p) } unsafe { forget(p) }
} }
full => { full => {
// This is impossible // This is impossible
@ -145,7 +145,7 @@ pub mod pipes {
match swap_state_rel(&mut (*p).state, terminated) { match swap_state_rel(&mut (*p).state, terminated) {
empty => { empty => {
// the sender will clean up // the sender will clean up
unsafe { forget(move p) } unsafe { forget(p) }
} }
blocked => { blocked => {
// this shouldn't happen. // this shouldn't happen.
@ -166,7 +166,7 @@ pub mod pipes {
if self.p != None { if self.p != None {
let mut p = None; let mut p = None;
p <-> self.p; p <-> self.p;
sender_terminate(option::unwrap(move p)) sender_terminate(option::unwrap(p))
} }
} }
} }
@ -175,7 +175,7 @@ pub mod pipes {
fn unwrap() -> *packet<T> { fn unwrap() -> *packet<T> {
let mut p = None; let mut p = None;
p <-> self.p; p <-> self.p;
option::unwrap(move p) option::unwrap(p)
} }
} }
@ -194,7 +194,7 @@ pub mod pipes {
if self.p != None { if self.p != None {
let mut p = None; let mut p = None;
p <-> self.p; p <-> self.p;
receiver_terminate(option::unwrap(move p)) receiver_terminate(option::unwrap(p))
} }
} }
} }
@ -203,7 +203,7 @@ pub mod pipes {
fn unwrap() -> *packet<T> { fn unwrap() -> *packet<T> {
let mut p = None; let mut p = None;
p <-> self.p; p <-> self.p;
option::unwrap(move p) option::unwrap(p)
} }
} }
@ -231,9 +231,9 @@ pub mod pingpong {
let addr : *::pipes::send_packet<pong> = match &p { let addr : *::pipes::send_packet<pong> = match &p {
&ping(ref x) => { cast::transmute(ptr::addr_of(x)) } &ping(ref x) => { cast::transmute(ptr::addr_of(x)) }
}; };
let liberated_value = move *addr; let liberated_value = *addr;
cast::forget(move p); cast::forget(p);
move liberated_value liberated_value
} }
} }
@ -242,9 +242,9 @@ pub mod pingpong {
let addr : *::pipes::send_packet<ping> = match &p { let addr : *::pipes::send_packet<ping> = match &p {
&pong(ref x) => { cast::transmute(ptr::addr_of(x)) } &pong(ref x) => { cast::transmute(ptr::addr_of(x)) }
}; };
let liberated_value = move *addr; let liberated_value = *addr;
cast::forget(move p); cast::forget(p);
move liberated_value liberated_value
} }
} }
@ -262,16 +262,16 @@ pub mod pingpong {
pub fn do_ping(-c: ping) -> pong { pub fn do_ping(-c: ping) -> pong {
let (sp, rp) = ::pipes::entangle(); let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pingpong::ping(move sp)); ::pipes::send(c, pingpong::ping(sp));
move rp rp
} }
pub fn do_pong(-c: pong) -> (ping, ()) { pub fn do_pong(-c: pong) -> (ping, ()) {
let packet = ::pipes::recv(move c); let packet = ::pipes::recv(c);
if packet.is_none() { if packet.is_none() {
fail!(~"sender closed the connection") fail!(~"sender closed the connection")
} }
(pingpong::liberate_pong(option::unwrap(move packet)), ()) (pingpong::liberate_pong(option::unwrap(packet)), ())
} }
} }
@ -282,32 +282,32 @@ pub mod pingpong {
pub type pong = ::pipes::send_packet<pingpong::pong>; pub type pong = ::pipes::send_packet<pingpong::pong>;
pub fn do_ping(-c: ping) -> (pong, ()) { pub fn do_ping(-c: ping) -> (pong, ()) {
let packet = ::pipes::recv(move c); let packet = ::pipes::recv(c);
if packet.is_none() { if packet.is_none() {
fail!(~"sender closed the connection") fail!(~"sender closed the connection")
} }
(pingpong::liberate_ping(option::unwrap(move packet)), ()) (pingpong::liberate_ping(option::unwrap(packet)), ())
} }
pub fn do_pong(-c: pong) -> ping { pub fn do_pong(-c: pong) -> ping {
let (sp, rp) = ::pipes::entangle(); let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pingpong::pong(move sp)); ::pipes::send(c, pingpong::pong(sp));
move rp rp
} }
} }
} }
fn client(-chan: pingpong::client::ping) { fn client(-chan: pingpong::client::ping) {
let chan = pingpong::client::do_ping(move chan); let chan = pingpong::client::do_ping(chan);
log(error, ~"Sent ping"); log(error, ~"Sent ping");
let (_chan, _data) = pingpong::client::do_pong(move chan); let (_chan, _data) = pingpong::client::do_pong(chan);
log(error, ~"Received pong"); log(error, ~"Received pong");
} }
fn server(-chan: pingpong::server::ping) { fn server(-chan: pingpong::server::ping) {
let (chan, _data) = pingpong::server::do_ping(move chan); let (chan, _data) = pingpong::server::do_ping(chan);
log(error, ~"Received ping"); log(error, ~"Received ping");
let _chan = pingpong::server::do_pong(move chan); let _chan = pingpong::server::do_pong(chan);
log(error, ~"Sent pong"); log(error, ~"Sent pong");
} }
@ -319,12 +319,12 @@ pub fn main() {
let client_ = ~mut Some(client_); let client_ = ~mut Some(client_);
let server_ = ~mut Some(server_); let server_ = ~mut Some(server_);
task::spawn {|move client_| task::spawn {|client_|
let mut client__ = none; let mut client__ = none;
*client_ <-> client__; *client_ <-> client__;
client(option::unwrap(client__)); client(option::unwrap(client__));
}; };
task::spawn {|move server_| task::spawn {|server_|
let mut server_ˊ = none; let mut server_ˊ = none;
*server_ <-> server_ˊ; *server_ <-> server_ˊ;
server(option::unwrap(server_ˊ)); server(option::unwrap(server_ˊ));

View File

@ -19,7 +19,7 @@ proto! streamp (
fn rendezvous() { fn rendezvous() {
let (c, s) = streamp::init(); let (c, s) = streamp::init();
let streams: ~[streamp::client::open<int>] = ~[move c]; let streams: ~[streamp::client::open<int>] = ~[c];
error!("%?", streams[0]); error!("%?", streams[0]);
} }

View File

@ -60,7 +60,7 @@ fn square_from_char(c: char) -> square {
} }
fn read_board_grid<rdr: &static io::Reader>(+in: rdr) -> ~[~[square]] { fn read_board_grid<rdr: &static io::Reader>(+in: rdr) -> ~[~[square]] {
let in = (move in) as io::Reader; let in = (in) as io::Reader;
let mut grid = ~[]; let mut grid = ~[];
for in.each_line |line| { for in.each_line |line| {
let mut row = ~[]; let mut row = ~[];

View File

@ -17,5 +17,5 @@ proto! stream (
pub fn main() { pub fn main() {
let (bc, _bp) = stream::init(); let (bc, _bp) = stream::init();
stream::client::send(move bc, ~"abc"); stream::client::send(bc, ~"abc");
} }

View File

@ -12,15 +12,15 @@
pub fn main() { pub fn main() {
let (p,c) = pipes::stream(); let (p,c) = pipes::stream();
do task::try |move c| { do task::try || {
let (p2,c2) = pipes::stream(); let (p2,c2) = pipes::stream();
do task::spawn |move p2| { do task::spawn || {
p2.recv(); p2.recv();
error!("sibling fails"); error!("sibling fails");
fail!(); fail!();
} }
let (p3,c3) = pipes::stream(); let (p3,c3) = pipes::stream();
c.send(move c3); c.send(c3);
c2.send(()); c2.send(());
error!("child blocks"); error!("child blocks");
p3.recv(); p3.recv();

View File

@ -14,19 +14,19 @@ use pipes::{Select2, Selectable};
pub fn main() { pub fn main() {
let (p,c) = pipes::stream(); let (p,c) = pipes::stream();
do task::try |move c| { do task::try || {
let (p2,c2) = pipes::stream(); let (p2,c2) = pipes::stream();
do task::spawn |move p2| { do task::spawn || {
p2.recv(); p2.recv();
error!("sibling fails"); error!("sibling fails");
fail!(); fail!();
} }
let (p3,c3) = pipes::stream(); let (p3,c3) = pipes::stream();
c.send(move c3); c.send(c3);
c2.send(()); c2.send(());
error!("child blocks"); error!("child blocks");
let (p, c) = pipes::stream(); let (p, c) = pipes::stream();
(move p, move p3).select(); (p, p3).select();
c.send(()); c.send(());
}; };
error!("parent tries"); error!("parent tries");

View File

@ -23,5 +23,5 @@ impl thing { fn f(self) {} }
pub fn main() { pub fn main() {
let z = thing(); let z = thing();
(move z).f(); (z).f();
} }

View File

@ -20,7 +20,7 @@ impl<T> list<T>{
next: option::None next: option::None
}; };
self.next = Some(@(move newList)); self.next = Some(@(newList));
} }
} }

View File

@ -11,5 +11,5 @@
pub fn main() pub fn main()
{ {
let y = ~1; let y = ~1;
move y; y;
} }

View File

@ -20,7 +20,7 @@ trait JD : Deserializable<json::Deserializer> { }
fn exec<T: JD>() { fn exec<T: JD>() {
let doc = result::unwrap(json::from_str("")); let doc = result::unwrap(json::from_str(""));
let _v: T = deserialize(&json::Deserializer(move doc)); let _v: T = deserialize(&json::Deserializer(doc));
fail!() fail!()
} }

View File

@ -13,14 +13,14 @@
fn lp<T>(s: ~str, f: fn(~str) -> T) -> T { fn lp<T>(s: ~str, f: fn(~str) -> T) -> T {
while false { while false {
let r = f(s); let r = f(s);
return (move r); return (r);
} }
fail!(); fail!();
} }
fn apply<T>(s: ~str, f: fn(~str) -> T) -> T { fn apply<T>(s: ~str, f: fn(~str) -> T) -> T {
fn g<T>(s: ~str, f: fn(~str) -> T) -> T {f(s)} fn g<T>(s: ~str, f: fn(~str) -> T) -> T {f(s)}
g(s, |v| { let r = f(v); move r }) g(s, |v| { let r = f(v); r })
} }
pub fn main() {} pub fn main() {}

View File

@ -15,7 +15,7 @@ struct A { a: ~int }
fn foo() -> fn@() -> int { fn foo() -> fn@() -> int {
let k = ~22; let k = ~22;
let _u = A {a: copy k}; let _u = A {a: copy k};
return fn@(move k) -> int { 22 }; return fn@() -> int { 22 };
} }
pub fn main() { pub fn main() {

View File

@ -15,7 +15,7 @@ fn the_loop() {
loop { loop {
let x = 5; let x = 5;
if x > 3 { if x > 3 {
list += ~[take(move x)]; list += ~[take(x)];
} else { } else {
break; break;
} }

View File

@ -21,7 +21,7 @@ struct V<T> { v: ~[option<T>] }
fn mk<T>() -> @Smallintmap<T> { fn mk<T>() -> @Smallintmap<T> {
let mut v: ~[option<T>] = ~[]; let mut v: ~[option<T>] = ~[];
return @Smallintmap {mut v: move v}; return @Smallintmap {mut v: v};
} }
fn f<T,U>() { fn f<T,U>() {

View File

@ -25,7 +25,7 @@ struct F<A> { a: A }
impl<A: Copy Serializable> Serializable for F<A> { impl<A: Copy Serializable> Serializable for F<A> {
fn serialize<S: Serializer>(s: S) { fn serialize<S: Serializer>(s: S) {
self.a.serialize(move s); self.a.serialize(s);
} }
} }

View File

@ -13,7 +13,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: ~Triple) -> int { fn test(x: bool, foo: ~Triple) -> int {
let bar = foo; let bar = foo;
let mut y: ~Triple; let mut y: ~Triple;
if x { y = move bar; } else { y = ~Triple{x: 4, y: 5, z: 6}; } if x { y = bar; } else { y = ~Triple{x: 4, y: 5, z: 6}; }
return y.y; return y.y;
} }

View File

@ -13,7 +13,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: @Triple) -> int { fn test(x: bool, foo: @Triple) -> int {
let bar = foo; let bar = foo;
let mut y: @Triple; let mut y: @Triple;
if x { y = move bar; } else { y = @Triple{x: 4, y: 5, z: 6}; } if x { y = bar; } else { y = @Triple{x: 4, y: 5, z: 6}; }
return y.y; return y.y;
} }

View File

@ -11,4 +11,4 @@
struct X { x: int, y: int, z: int } struct X { x: int, y: int, z: int }
pub fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); } pub fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = x; assert (y.y == 2); }

View File

@ -11,4 +11,4 @@
struct X { x: int, y: int, z: int } struct X { x: int, y: int, z: int }
pub fn main() { let x = @X {x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); } pub fn main() { let x = @X {x: 1, y: 2, z: 3}; let y = x; assert (y.y == 2); }

View File

@ -15,7 +15,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: ~Triple) -> int { fn test(x: bool, foo: ~Triple) -> int {
let bar = foo; let bar = foo;
let mut y: ~Triple; let mut y: ~Triple;
if x { y = move bar; } else { y = ~Triple {x: 4, y: 5, z: 6}; } if x { y = bar; } else { y = ~Triple {x: 4, y: 5, z: 6}; }
return y.y; return y.y;
} }

View File

@ -15,7 +15,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: @Triple) -> int { fn test(x: bool, foo: @Triple) -> int {
let bar = foo; let bar = foo;
let mut y: @Triple; let mut y: @Triple;
if x { y = move bar; } else { y = @Triple{x: 4, y: 5, z: 6}; } if x { y = bar; } else { y = @Triple{x: 4, y: 5, z: 6}; }
return y.y; return y.y;
} }

View File

@ -14,9 +14,9 @@ struct Triple {a: int, b: int, c: int}
fn test(foo: ~Triple) -> ~Triple { fn test(foo: ~Triple) -> ~Triple {
let foo = foo; let foo = foo;
let bar = move foo; let bar = foo;
let baz = move bar; let baz = bar;
let quux = move baz; let quux = baz;
return quux; return quux;
} }

View File

@ -15,9 +15,9 @@ struct Triple { a: int, b: int, c: int }
fn test(foo: @Triple) -> @Triple { fn test(foo: @Triple) -> @Triple {
let foo = foo; let foo = foo;
let bar = move foo; let bar = foo;
let baz = move bar; let baz = bar;
let quux = move baz; let quux = baz;
return quux; return quux;
} }

View File

@ -13,7 +13,7 @@ fn test(-foo: ~~[int]) { assert (foo[0] == 10); }
pub fn main() { pub fn main() {
let x = ~~[10]; let x = ~~[10];
// Test forgetting a local by move-in // Test forgetting a local by move-in
test(move x); test(x);
// Test forgetting a temporary by move-in. // Test forgetting a temporary by move-in.
test(~~[10]); test(~~[10]);

View File

@ -13,7 +13,7 @@ fn test(-foo: @~[int]) { assert (foo[0] == 10); }
pub fn main() { pub fn main() {
let x = @~[10]; let x = @~[10];
// Test forgetting a local by move-in // Test forgetting a local by move-in
test(move x); test(x);
// Test forgetting a temporary by move-in. // Test forgetting a temporary by move-in.
test(@~[10]); test(@~[10]);

View File

@ -10,4 +10,4 @@
fn test(-foo: int) { assert (foo == 10); } fn test(-foo: int) { assert (foo == 10); }
pub fn main() { let x = 10; test(move x); } pub fn main() { let x = 10; test(x); }

View File

@ -12,7 +12,7 @@
fn f2(-thing: fn@()) { } fn f2(-thing: fn@()) { }
fn f(-thing: fn@()) { fn f(-thing: fn@()) {
f2(move thing); f2(thing);
} }
pub fn main() { pub fn main() {

View File

@ -12,6 +12,6 @@ pub fn main() {
let y: int = 42; let y: int = 42;
let mut x: int; let mut x: int;
x = move y; x = y;
assert (x == 42); assert (x == 42);
} }

View File

@ -4,7 +4,7 @@ struct S {
impl S { impl S {
fn foo(self) { fn foo(self) {
(move self).bar(); self.bar();
} }
fn bar(self) { fn bar(self) {

View File

@ -13,7 +13,7 @@ struct X {
} }
fn apply<T>(x: T, f: fn(T)) { fn apply<T>(x: T, f: fn(T)) {
f(move x); f(x);
} }
fn check_int(x: int) { fn check_int(x: int) {

View File

@ -21,8 +21,8 @@ impl Drop for dtor {
} }
fn unwrap<T>(+o: Option<T>) -> T { fn unwrap<T>(+o: Option<T>) -> T {
match move o { match o {
Some(move v) => move v, Some(v) => v,
None => fail!() None => fail!()
} }
} }
@ -32,7 +32,7 @@ pub fn main() {
{ {
let b = Some(dtor { x:x }); let b = Some(dtor { x:x });
let c = unwrap(move b); let c = unwrap(b);
} }
assert *x == 0; assert *x == 0;

View File

@ -44,21 +44,21 @@ proto! bank (
) )
macro_rules! move_it ( macro_rules! move_it (
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } } { $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
) )
fn switch<T: Owned, U>(+endp: pipes::RecvPacket<T>, fn switch<T: Owned, U>(+endp: pipes::RecvPacket<T>,
f: fn(+v: Option<T>) -> U) -> U { f: fn(+v: Option<T>) -> U) -> U {
f(pipes::try_recv(move endp)) f(pipes::try_recv(endp))
} }
fn move_it<T>(-x: T) -> T { move x } fn move_it<T>(-x: T) -> T { x }
macro_rules! follow ( macro_rules! follow (
{ {
$($message:path$(($($x: ident),+))||* -> $next:ident $e:expr)+ $($message:path$(($($x: ident),+))||* -> $next:ident $e:expr)+
} => ( } => (
|m| match move m { |m| match m {
$(Some($message($($($x,)+)* next)) => { $(Some($message($($($x,)+)* next)) => {
let $next = move_it!(next); let $next = move_it!(next);
$e })+ $e })+
@ -70,15 +70,15 @@ macro_rules! follow (
fn client_follow(+bank: bank::client::login) { fn client_follow(+bank: bank::client::login) {
use bank::*; use bank::*;
let bank = client::login(move bank, ~"theincredibleholk", ~"1234"); let bank = client::login(bank, ~"theincredibleholk", ~"1234");
let bank = switch(move bank, follow! ( let bank = switch(bank, follow! (
ok -> connected { move connected } ok -> connected { connected }
invalid -> _next { fail!(~"bank closed the connected") } invalid -> _next { fail!(~"bank closed the connected") }
)); ));
let bank = client::deposit(move bank, 100.00); let bank = client::deposit(bank, 100.00);
let bank = client::withdrawal(move bank, 50.00); let bank = client::withdrawal(bank, 50.00);
switch(move bank, follow! ( switch(bank, follow! (
money(m) -> _next { money(m) -> _next {
io::println(~"Yay! I got money!"); io::println(~"Yay! I got money!");
} }
@ -91,8 +91,8 @@ fn client_follow(+bank: bank::client::login) {
fn bank_client(+bank: bank::client::login) { fn bank_client(+bank: bank::client::login) {
use bank::*; use bank::*;
let bank = client::login(move bank, ~"theincredibleholk", ~"1234"); let bank = client::login(bank, ~"theincredibleholk", ~"1234");
let bank = match try_recv(move bank) { let bank = match try_recv(bank) {
Some(ok(connected)) => { Some(ok(connected)) => {
move_it!(connected) move_it!(connected)
} }
@ -100,9 +100,9 @@ fn bank_client(+bank: bank::client::login) {
None => { fail!(~"bank closed the connection") } None => { fail!(~"bank closed the connection") }
}; };
let bank = client::deposit(move bank, 100.00); let bank = client::deposit(bank, 100.00);
let bank = client::withdrawal(move bank, 50.00); let bank = client::withdrawal(bank, 50.00);
match try_recv(move bank) { match try_recv(bank) {
Some(money(*)) => { Some(money(*)) => {
io::println(~"Yay! I got money!"); io::println(~"Yay! I got money!");
} }

View File

@ -32,7 +32,7 @@ pub fn main() {
let iotask = &uv::global_loop::get(); let iotask = &uv::global_loop::get();
pipes::spawn_service(oneshot::init, |p| { pipes::spawn_service(oneshot::init, |p| {
match try_recv(move p) { match try_recv(p) {
Some(*) => { fail!() } Some(*) => { fail!() }
None => { } None => { }
} }
@ -47,11 +47,11 @@ pub fn main() {
fn failtest() { fn failtest() {
let (c, p) = oneshot::init(); let (c, p) = oneshot::init();
do task::spawn_with(move c) |_c| { do task::spawn_with(c) |_c| {
fail!(); fail!();
} }
error!("%?", recv(move p)); error!("%?", recv(p));
// make sure we get killed if we missed it in the receive. // make sure we get killed if we missed it in the receive.
loop { task::yield() } loop { task::yield() }
} }

Some files were not shown because too many files have changed in this diff Show More