提交 178882c9 编写于 作者: L Luqman Aden

tests/tutorials: Get rid of `move`.

上级 e244f103
......@@ -213,7 +213,7 @@ else enum extern
false fn for
if impl
let log loop
match mod move mut
match mod mut
priv pub pure
ref return
self static struct super
......
......@@ -431,7 +431,7 @@ fn example5c(x: @S) -> int {
let y = &v.g;
...
}
x.f = move v; // Replace x.f
x.f = v; // Replace x.f
...
# return 0;
}
......
......@@ -161,7 +161,7 @@ use pipes::{stream, Port, Chan};
let (port, chan): (Port<int>, Chan<int>) = stream();
do spawn |move chan| {
do spawn || {
let result = some_expensive_computation();
chan.send(result);
}
......@@ -192,7 +192,7 @@ spawns the child task.
# use pipes::{stream, Port, Chan};
# fn some_expensive_computation() -> int { 42 }
# let (port, chan) = stream();
do spawn |move chan| {
do spawn || {
let result = some_expensive_computation();
chan.send(result);
}
......@@ -229,7 +229,7 @@ following program is ill-typed:
# fn some_expensive_computation() -> int { 42 }
let (port, chan) = stream();
do spawn |move chan| {
do spawn {
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};
let (port, chan) = stream();
let chan = SharedChan(move chan);
let chan = SharedChan(chan);
for uint::range(0, 3) |init_val| {
// Create a new channel handle to distribute to the child task
let child_chan = chan.clone();
do spawn |move child_chan| {
do spawn {
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
let ports = do vec::from_fn(3) |init_val| {
let (port, chan) = stream();
do spawn |move chan| {
do spawn {
chan.send(some_expensive_computation(init_val));
}
move port
port
};
// Wait on each port, accumulating the results
......@@ -398,13 +398,13 @@ before returning. Hence:
# fn sleep_forever() { loop { task::yield() } }
# do task::try {
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.
let message = receiver.recv();
// Kill both it and the parent task.
assert message != 42;
}
do try |move sender| { // Unidirectionally linked
do try { // Unidirectionally linked
sender.send(42);
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();
do spawn |move to_child| {
do spawn {
stringifier(&to_child);
};
......
......@@ -1260,7 +1260,7 @@ Moving it into a mutable slot makes the elements assignable.
let crayons: ~[Crayon] = ~[BananaMania, Beaver, Bittersweet];
// 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
mutable_crayons[0] = Apricot;
......
......@@ -1229,7 +1229,7 @@ pub fn encode_metadata(parms: encode_parms, crate: &crate) -> ~[u8] {
let ecx: @encode_ctxt = @encode_ctxt({
diag: parms.diag,
tcx: parms.tcx,
stats: @mut move stats,
stats: @mut stats,
reachable: parms.reachable,
reexports2: parms.reexports2,
item_symbols: parms.item_symbols,
......
......@@ -27,7 +27,7 @@ pub fn cat<U>(in_x : uint, in_y : int, -in_info: ~[U]) -> cat<U> {
cat {
meows: in_x,
how_hungry: in_y,
info: move in_info
info: in_info
}
}
}
......
......@@ -27,7 +27,7 @@ fn collect_dvec(num: uint) -> ~[uint] {
for uint::range(0u, num) |i| {
result.push(i);
}
return dvec::unwrap(move result);
return dvec::unwrap(result);
}
fn main() {
......
......@@ -141,7 +141,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
};
}
move marks
marks
}
/**
......@@ -260,7 +260,7 @@ fn is_gray_factory() -> ~fn(c: &color) -> bool {
i += 1;
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
colors = do par::mapi(*color_vec) {
......
......@@ -27,7 +27,7 @@
use pipes::{Port, Chan, SharedChan};
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 {
......@@ -58,7 +58,7 @@ fn run(args: &[~str]) {
let (from_child, to_parent) = 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 workers = uint::from_str(args[2]).get();
......@@ -68,8 +68,8 @@ fn run(args: &[~str]) {
for uint::range(0, workers) |_i| {
let to_child = to_child.clone();
do task::task().future_result(|+r| {
worker_results.push(move r);
}).spawn |move to_child| {
worker_results.push(r);
}).spawn || {
for uint::range(0, size / workers) |_i| {
//error!("worker %?: sending %? bytes", i, num_bytes);
to_child.send(bytes(num_bytes));
......@@ -77,7 +77,7 @@ fn run(args: &[~str]) {
//error!("worker %? exiting", i);
};
}
do task::spawn |move from_parent, move to_parent| {
do task::spawn || {
server(from_parent, to_parent);
}
......
......@@ -23,7 +23,7 @@
use pipes::{Port, PortSet, Chan};
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 {
......@@ -54,7 +54,7 @@ fn run(args: &[~str]) {
let (from_child, to_parent) = pipes::stream();
let (from_parent_, to_child) = pipes::stream();
let from_parent = PortSet();
from_parent.add(move from_parent_);
from_parent.add(from_parent_);
let size = uint::from_str(args[1]).get();
let workers = uint::from_str(args[2]).get();
......@@ -63,10 +63,10 @@ fn run(args: &[~str]) {
let mut worker_results = ~[];
for uint::range(0, workers) |_i| {
let (from_parent_, to_child) = pipes::stream();
from_parent.add(move from_parent_);
from_parent.add(from_parent_);
do task::task().future_result(|+r| {
worker_results.push(move r);
}).spawn |move to_child| {
worker_results.push(r);
}).spawn || {
for uint::range(0, size / workers) |_i| {
//error!("worker %?: sending %? bytes", i, num_bytes);
to_child.send(bytes(num_bytes));
......@@ -74,7 +74,7 @@ fn run(args: &[~str]) {
//error!("worker %? exiting", i);
};
}
do task::spawn |move from_parent, move to_parent| {
do task::spawn || {
server(from_parent, to_parent);
}
......
......@@ -40,7 +40,7 @@ fn recv(p: &pipe) -> uint {
fn init() -> (pipe,pipe) {
let m = arc::MutexARC(~[]);
((&m).clone(), move m)
((&m).clone(), m)
}
......@@ -48,18 +48,18 @@ fn thread_ring(i: uint,
count: uint,
+num_chan: pipe,
+num_port: pipe) {
let mut num_chan = move Some(move num_chan);
let mut num_port = move Some(move num_port);
let mut num_chan = Some(num_chan);
let mut num_port = Some(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(move num_chan2);
num_chan = Some(num_chan2);
let _n = recv(&num_port2);
//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 (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();
......@@ -89,22 +89,22 @@ fn main() {
let (new_chan, num_port) = init();
let num_chan2 = ~mut None;
*num_chan2 <-> num_chan;
let num_port = ~mut Some(move num_port);
let new_future = future::spawn(|move num_chan2, move num_port| {
let num_port = ~mut Some(num_port);
let new_future = do future::spawn() || {
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(move num_chan),
option::unwrap(move num_port1))
});
futures.push(move new_future);
num_chan = Some(move new_chan);
option::unwrap(num_chan),
option::unwrap(num_port1))
};
futures.push(new_future);
num_chan = Some(new_chan);
};
// 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
for futures.each |f| { f.get() };
......
......@@ -29,15 +29,15 @@
)
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,
count: uint,
+num_chan: ring::client::num,
+num_port: ring::server::num) {
let mut num_chan = move Some(move num_chan);
let mut num_port = move Some(move num_port);
let mut num_chan = Some(num_chan);
let mut num_port = Some(num_port);
// Send/Receive lots of messages.
for uint::range(0, count) |j| {
//error!("task %?, iter %?", i, j);
......@@ -45,9 +45,9 @@ fn thread_ring(i: uint,
let mut num_port2 = None;
num_chan2 <-> num_chan;
num_port2 <-> num_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) {
num_chan = Some(ring::client::num(option::unwrap(num_chan2), i * j));
let port = option::unwrap(num_port2);
match recv(port) {
ring::num(_n, p) => {
//log(error, _n);
num_port = Some(move_out!(p));
......@@ -70,7 +70,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(move num_chan);
let mut num_chan = Some(num_chan);
let start = time::precise_time_s();
......@@ -82,23 +82,22 @@ fn main() {
let (new_chan, num_port) = ring::init();
let num_chan2 = ~mut None;
*num_chan2 <-> num_chan;
let num_port = ~mut Some(move num_port);
let new_future = do future::spawn
|move num_chan2, move num_port| {
let num_port = ~mut Some(num_port);
let new_future = do future::spawn || {
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(move num_chan),
option::unwrap(move num_port1))
option::unwrap(num_chan),
option::unwrap(num_port1))
};
futures.push(move new_future);
num_chan = Some(move new_chan);
futures.push(new_future);
num_chan = Some(new_chan);
};
// 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
for futures.each |f| { f.get() };
......
......@@ -40,7 +40,7 @@ fn recv(p: &pipe) -> uint {
fn init() -> (pipe,pipe) {
let x = arc::RWARC(~[]);
((&x).clone(), move x)
((&x).clone(), x)
}
......@@ -48,18 +48,18 @@ fn thread_ring(i: uint,
count: uint,
+num_chan: pipe,
+num_port: pipe) {
let mut num_chan = move Some(move num_chan);
let mut num_port = move Some(move num_port);
let mut num_chan = Some(num_chan);
let mut num_port = Some(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(move num_chan2);
num_chan = Some(num_chan2);
let _n = recv(&num_port2);
//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 (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();
......@@ -89,23 +89,22 @@ fn main() {
let (new_chan, num_port) = init();
let num_chan2 = ~mut None;
*num_chan2 <-> num_chan;
let num_port = ~mut Some(move num_port);
let new_future = do future::spawn
|move num_chan2, move num_port| {
let num_port = ~mut Some(num_port);
let new_future = do future::spawn || {
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(move num_chan),
option::unwrap(move num_port1))
option::unwrap(num_chan),
option::unwrap(num_port1))
};
futures.push(move new_future);
num_chan = Some(move new_chan);
futures.push(new_future);
num_chan = Some(new_chan);
};
// 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
for futures.each |f| { f.get() };
......
......@@ -35,8 +35,8 @@ fn Noise2DContext() -> ~Noise2DContext {
r.shuffle_mut(permutations);
~Noise2DContext{
rgradients: move rgradients,
permutations: move permutations,
rgradients: rgradients,
permutations: permutations,
}
}
......
......@@ -45,17 +45,17 @@
// This stuff should go in libcore::pipes
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 (
{
$($message:path($($x: ident),+) -> $next:ident $e:expr)+
} => (
|m| match move m {
$(Some($message($($x,)* move next)) => {
let $next = move next;
move $e })+
|m| match m {
$(Some($message($($x,)* next)) => {
let $next = next;
$e })+
_ => { fail!() }
}
);
......@@ -63,10 +63,10 @@
{
$($message:path -> $next:ident $e:expr)+
} => (
|m| match move m {
$(Some($message(move next)) => {
let $next = move next;
move $e })+
|m| match m {
$(Some($message(next)) => {
let $next = next;
$e })+
_ => { fail!() }
}
)
......@@ -74,7 +74,7 @@
fn switch<T: Owned, Tb: Owned, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
f: fn(+v: Option<T>) -> U) -> U {
f(pipes::try_recv(move endp))
f(pipes::try_recv(endp))
}
// Here's the benchmark
......@@ -84,10 +84,10 @@ fn bounded(count: uint) {
let mut ch = do spawn_service(init) |ch| {
let mut count = count;
let mut ch = move ch;
let mut ch = ch;
while count > 0 {
ch = switch(move ch, follow! (
ping -> next { server::pong(move next) }
ch = switch(ch, follow! (
ping -> next { server::pong(next) }
));
count -= 1;
......@@ -96,10 +96,10 @@ fn bounded(count: uint) {
let mut count = count;
while count > 0 {
let ch_ = client::ping(move ch);
let ch_ = client::ping(ch);
ch = switch(move ch_, follow! (
pong -> next { move next }
ch = switch(ch_, follow! (
pong -> next { next }
));
count -= 1;
......@@ -111,10 +111,10 @@ fn unbounded(count: uint) {
let mut ch = do spawn_service(init) |ch| {
let mut count = count;
let mut ch = move ch;
let mut ch = ch;
while count > 0 {
ch = switch(move ch, follow! (
ping -> next { server::pong(move next) }
ch = switch(ch, follow! (
ping -> next { server::pong(next) }
));
count -= 1;
......@@ -123,10 +123,10 @@ fn unbounded(count: uint) {
let mut count = count;
while count > 0 {
let ch_ = client::ping(move ch);
let ch_ = client::ping(ch);
ch = switch(move ch_, follow! (
pong -> next { move next }
ch = switch(ch_, follow! (
pong -> next { next }
));
count -= 1;
......
......@@ -156,7 +156,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
let to_rendezvous_log = to_rendezvous_log.clone();
let (from_rendezvous, to_creature) = stream();
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(),
to_rendezvous_log.clone());
}
......
......@@ -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
......@@ -149,23 +149,23 @@ fn main() {
// initialize each sequence sorter
let sizes = ~[1,2,3,4,6,12,18];
let streams = vec::map(sizes, |_sz| Some(stream()));
let mut streams = move streams;
let mut streams = streams;
let mut from_child = ~[];
let to_child = vec::mapi(sizes, |ii, sz| {
let sz = *sz;
let mut stream = None;
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();
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_);
};
move to_child
to_child
});
......
......@@ -172,7 +172,7 @@ fn main() {
let pchan = pipes::SharedChan(pchan);
for uint::range(0_u, size) |j| {
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);
}
......@@ -43,15 +43,15 @@ fn pfib(c: Chan<int>, n: int) {
} else {
let p = pipes::PortSet();
let ch = p.chan();
task::spawn(|move ch| pfib(ch, n - 1) );
task::spawn(|| pfib(ch, n - 1) );
let ch = p.chan();
task::spawn(|move ch| pfib(ch, n - 2) );
task::spawn(|| pfib(ch, n - 2) );
c.send(p.recv() + p.recv());
}
}
let (p, ch) = pipes::stream();
let _t = task::spawn(|move ch| pfib(ch, n) );
let _t = task::spawn(|| pfib(ch, n) );
p.recv()
}
......@@ -86,7 +86,7 @@ fn stress(num_tasks: int) {
let mut results = ~[];
for range(0, num_tasks) |i| {
do task::task().future_result(|+r| {
results.push(move r);
results.push(r);
}).spawn {
stress_task(i);
}
......
......@@ -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));
}
}
......@@ -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.
// With this code, only as many generations are alive at a time as tasks
// alive at a time,
let c = ~mut Some(move c);
do task::spawn_supervised |move c| {
let c = ~mut Some(c);
do task::spawn_supervised || {
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, move c); // recurse
child_generation(gens_left - 1, c); // recurse
} else {
c.send(())
}
......@@ -44,7 +44,7 @@ fn main() {
};
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() {
fail!(~"it happened when we slumbered");
}
......
......@@ -46,9 +46,9 @@ fn grandchild_group(num_tasks: uint) {
fn spawn_supervised_blocking(myname: &str, +f: fn~()) {
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);
let x = option::unwrap(move res).recv();
let x = option::unwrap(res).recv();
assert x == task::Success;
}
......
......@@ -18,8 +18,8 @@ fn finalize(&self) {
fn main() {
let x = Some(X { x: () });
match move x {
Some(ref _y @ move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
match x {
Some(ref _y @ _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!()
}
}
......@@ -18,8 +18,8 @@ fn finalize(&self) {
fn main() {
let x = Some((X { x: () }, X { x: () }));
match move x {
Some((ref _y, move _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
match x {
Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!()
}
}
......@@ -20,8 +20,8 @@ enum double_option<T,U> { some2(T,U), none2 }
fn main() {
let x = some2(X { x: () }, X { x: () });
match move x {
some2(ref _y, move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
match x {
some2(ref _y, _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
none2 => fail!()
}
}
......@@ -18,8 +18,8 @@ fn finalize(&self) {
fn main() {
let x = Some((X { x: () }, X { x: () }));
match move x {
Some((move _y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
match x {
Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!()
}
}
......@@ -12,9 +12,9 @@ fn main() {
let (p,c) = pipes::stream();
let x = Some(p);
c.send(false);
match move x {
Some(move z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard
Some(move z) => { assert !z.recv(); },
match x {
Some(z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard
Some(z) => { assert !z.recv(); },
None => fail!()
}
}
......@@ -21,7 +21,7 @@ fn finalize(&self) {
fn main() {
let x = Some(X { 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!()
}
}
......@@ -23,7 +23,7 @@ struct Y { y: Option<X> }
fn main() {
let x = Y { y: Some(X { x: () }) };
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!()
}
}
......@@ -18,8 +18,8 @@ fn finalize(&self) {
fn main() {
let x = Some(X { x: () });
match move x {
Some(move _y @ ref _z) => { }, //~ ERROR cannot bind by-move with sub-bindings
match x {
Some(_y @ ref _z) => { }, //~ ERROR cannot bind by-move with sub-bindings
None => fail!()
}
}
......@@ -20,6 +20,6 @@ impl Add<foo, foo> for foo {
fn main() {
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
}
......@@ -9,7 +9,7 @@
// except according to those terms.
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;
}
......
......@@ -4,7 +4,7 @@ fn a() -> &[int] {
[_a, ..tail] => tail,
_ => fail!(~"foo")
};
move tail
tail
}
fn main() {
......
......@@ -4,7 +4,7 @@ fn a() -> &int {
[_a, ..tail] => &tail[0],
_ => fail!(~"foo")
};
move tail
tail
}
fn main() {
......
......@@ -23,7 +23,7 @@ fn foo(i:int) -> foo {
}
fn main() {
let x = move foo(10);
let x = foo(10);
let _y = copy x;
//~^ ERROR copying a value of non-copyable type `foo`
log(error, x);
......
......@@ -34,7 +34,7 @@ fn main() {
let mut res = foo(x);
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);
}
......
......@@ -17,5 +17,5 @@ struct S<T: Const> {
fn main() {
let a1 = ~S{ s: true, cant_nest: () };
let _a2 = ~S{ s: move a1, cant_nest: () };
let _a2 = ~S{ s: a1, cant_nest: () };
}
......@@ -14,5 +14,5 @@ fn main() {
let x = @3u;
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~(move x) { foo(x); }; //~ ERROR value has non-owned type `@uint`
let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
}
......@@ -68,5 +68,5 @@ fn finalize(&self) {}
fn main() {
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
}
......@@ -37,7 +37,7 @@ fn foo(i:int) -> foo {
}
fn main() {
let x = move foo(10);
let x = foo(10);
let _y = copy x; //~ ERROR copying a value of non-copyable type
log(error, x);
}
......@@ -17,7 +17,7 @@ fn finalize(&self) {}
}
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
log(debug, i);
}
......@@ -13,5 +13,5 @@ fn f<T: Owned>(_i: T) {
fn main() {
let i = ~@100;
f(move i); //~ ERROR does not fulfill `Owned`
f(i); //~ ERROR does not fulfill `Owned`
}
......@@ -24,8 +24,8 @@ fn f<T>(+_i: ~[T], +_j: ~[T]) {
fn main() {
let i1 = @mut 0;
let i2 = @mut 1;
let r1 = move ~[~r { i: i1 }];
let r2 = move ~[~r { i: i2 }];
let r1 = ~[~r { i: i1 }];
let r2 = ~[~r { i: i2 }];
f(copy r1, copy r2);
//~^ ERROR copying a value of non-copyable type
//~^^ ERROR copying a value of non-copyable type
......
......@@ -26,5 +26,5 @@ fn foo(i:int, j: @~str) -> foo {
fn main() {
let cat = ~"kitty";
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`
}
......@@ -22,8 +22,8 @@ fn finalize(&self) {}
fn main() {
// This can't make sense as it would copy the classes
let i = move ~[r(0)];
let j = move ~[r(1)];
let i = ~[r(0)];
let j = ~[r(1)];
let k = i + j;
log(debug, j);
}
......@@ -15,11 +15,11 @@
// error-pattern:ran out of stack
fn main() {
eat(move @0);
eat(@0);
}
fn eat(
+a: @int
) {
eat(move a)
eat(a)
}
......@@ -11,11 +11,11 @@
// xfail-test
// error-pattern:ran out of stack
fn main() {
eat(move ~0);
eat(~0);
}
fn eat(
+a: ~int
) {
eat(move a)
eat(a)
}
......@@ -36,7 +36,7 @@ fn main() {
unsafe {
let i1 = ~0;
let i1p = cast::reinterpret_cast(&i1);
cast::forget(move i1);
cast::forget(i1);
let x = @r(i1p);
failfn();
log(error, x);
......
......@@ -16,6 +16,6 @@ fn f(a: @int) {
fn main() {
let b = @0;
let g : fn@() = |move b|f(b);
let g : fn@() = || f(b);
g();
}
......@@ -15,5 +15,5 @@ fn f(-_a: @int) {
fn main() {
let a = @0;
f(move a);
f(a);
}
......@@ -19,5 +19,5 @@ fn r(i: int) -> r { r { i: i } }
fn main() {
@0;
let r = move r(0);
let r = r(0);
}
......@@ -20,6 +20,6 @@ fn r(i: int) -> r { r { i: i } }
fn main() {
@0;
let r = move r(0);
let r = r(0);
fail!();
}
......@@ -10,7 +10,7 @@
pub fn main() {
let x = Some(private::exclusive(true));
match move x {
match x {
Some(ref z) if z.with(|b| *b) => {
do z.with |b| { assert *b; }
},
......
......@@ -24,7 +24,7 @@ fn f1(a: X, b: &mut int, -c: int) -> int {
pub fn main() {
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 (b == 10);
assert (f2(a.x, |x| a.x = 50 ) == 0);
......
......@@ -46,7 +46,7 @@ fn test_ebml<A:
let ebml_w = &EBWriter::Encoder(wr);
a1.encode(ebml_w)
};
let d = EBReader::Doc(@move bytes);
let d = EBReader::Doc(@bytes);
let a2: A = Decodable::decode(&EBReader::Decoder(d));
assert *a1 == a2;
}
......
......@@ -14,7 +14,7 @@ trait Pushable<T> {
impl<T> Pushable<T> for ~[T] {
fn push_val(&mut self, +t: T) {
self.push(move t);
self.push(t);
}
}
......
......@@ -17,8 +17,8 @@ fn dispose(+_x: arc::ARC<bool>) unsafe { }
pub fn main() {
let p = arc::arc(true);
let x = Some(p);
match move x {
Some(move z) => { dispose(z); },
match x {
Some(z) => { dispose(z); },
None => fail!()
}
}
......@@ -12,7 +12,7 @@
fn bar(x: *~int) -> ~int {
unsafe {
let y = move *x;
let y = *x;
return y;
}
}
......
......@@ -11,21 +11,21 @@
pub fn main() {
let x = ~1;
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;
let x = ~2;
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;
let x = ~3;
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;
let x = ~4;
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;
}
......@@ -26,7 +26,7 @@ fn cat<U>(in_x : uint, in_y : int, -in_info: ~[U]) -> cat<U> {
cat {
meows: in_x,
how_hungry: in_y,
info: move in_info
info: in_info
}
}
......
......@@ -31,6 +31,6 @@ pub fn main() {
assert *e == exp[i];
}
let v = dvec::unwrap(move d);
let v = dvec::unwrap(d);
assert v == exp;
}
......@@ -11,7 +11,7 @@
// This is what the signature to spawn should look like with bare functions
fn spawn<T: Owned>(val: T, f: extern fn(T)) {
f(move val);
f(val);
}
fn f(+i: int) {
......
......@@ -39,7 +39,7 @@ fn start_mappers(ctrl: SharedChan<ctrl_proto>, inputs: ~[~str]) {
for inputs.each |i| {
let ctrl = ctrl.clone();
let i = copy *i;
task::spawn(|move i| map_task(ctrl.clone(), copy i) );
task::spawn(|| map_task(ctrl.clone(), copy i) );
}
}
......
......@@ -32,7 +32,7 @@ fn r(i: @mut int) -> r {
fn test_box() {
let i = @mut 0;
{
let a = move @r(i);
let a = @r(i);
}
assert *i == 1;
}
......@@ -40,7 +40,7 @@ fn test_box() {
fn test_rec() {
let i = @mut 0;
{
let a = move Box {x: r(i)};
let a = Box {x: r(i)};
}
assert *i == 1;
}
......@@ -52,7 +52,7 @@ enum t {
let i = @mut 0;
{
let a = move t0(r(i));
let a = t0(r(i));
}
assert *i == 1;
}
......@@ -60,7 +60,7 @@ enum t {
fn test_tup() {
let i = @mut 0;
{
let a = move (r(i), 0);
let a = (r(i), 0);
}
assert *i == 1;
}
......@@ -68,7 +68,7 @@ fn test_tup() {
fn test_unique() {
let i = @mut 0;
{
let a = move ~r(i);
let a = ~r(i);
}
assert *i == 1;
}
......@@ -76,7 +76,7 @@ fn test_unique() {
fn test_box_rec() {
let i = @mut 0;
{
let a = move @Box {
let a = @Box {
x: r(i)
};
}
......
......@@ -18,7 +18,7 @@ pub fn main() {
unsafe {
let mut x = @1;
let mut y = @2;
rusti::move_val(&mut y, move x);
rusti::move_val(&mut y, x);
assert *y == 1;
}
}
......@@ -10,7 +10,7 @@
pub fn main() {
let x = 1;
let y = fn@(move x) -> int {
let y = fn@() -> int {
x
}();
}
......
......@@ -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 {
let mut b = move b0;
let mut b = b0;
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)) {
......
......@@ -61,18 +61,18 @@ mod rusti {
// We should consider moving this to ::core::unsafe, although I
// suspect graydon would want us to use void pointers instead.
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 {
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 {
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 fn send<T: Owned>(-p: send_packet<T>, -payload: T) {
let p = p.unwrap();
let p = unsafe { uniquify(p) };
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);
match old_state {
empty => {
// Yay, fastpath.
// The receiver will eventually clean this up.
unsafe { forget(move p); }
unsafe { forget(p); }
}
full => { fail!(~"duplicate send") }
blocked => {
// The receiver will eventually clean this up.
unsafe { forget(move p); }
unsafe { forget(p); }
}
terminated => {
// The receiver will never receive this. Rely on drop_glue
......@@ -113,7 +113,7 @@ pub fn recv<T: Owned>(-p: recv_packet<T>) -> Option<T> {
full => {
let mut payload = None;
payload <-> (*p).payload;
return Some(option::unwrap(move payload))
return Some(option::unwrap(payload))
}
terminated => {
assert old_state == terminated;
......@@ -128,7 +128,7 @@ pub fn sender_terminate<T: Owned>(p: *packet<T>) {
match swap_state_rel(&mut (*p).state, terminated) {
empty | blocked => {
// The receiver will eventually clean up.
unsafe { forget(move p) }
unsafe { forget(p) }
}
full => {
// This is impossible
......@@ -145,7 +145,7 @@ pub fn receiver_terminate<T: Owned>(p: *packet<T>) {
match swap_state_rel(&mut (*p).state, terminated) {
empty => {
// the sender will clean up
unsafe { forget(move p) }
unsafe { forget(p) }
}
blocked => {
// this shouldn't happen.
......@@ -166,7 +166,7 @@ fn finalize(&self) {
if self.p != None {
let mut p = None;
p <-> self.p;
sender_terminate(option::unwrap(move p))
sender_terminate(option::unwrap(p))
}
}
}
......@@ -175,7 +175,7 @@ pub impl<T: Owned> send_packet<T> {
fn unwrap() -> *packet<T> {
let mut p = None;
p <-> self.p;
option::unwrap(move p)
option::unwrap(p)
}
}
......@@ -194,7 +194,7 @@ fn finalize(&self) {
if self.p != None {
let mut p = None;
p <-> self.p;
receiver_terminate(option::unwrap(move p))
receiver_terminate(option::unwrap(p))
}
}
}
......@@ -203,7 +203,7 @@ pub impl<T: Owned> recv_packet<T> {
fn unwrap() -> *packet<T> {
let mut p = None;
p <-> self.p;
option::unwrap(move p)
option::unwrap(p)
}
}
......@@ -231,9 +231,9 @@ pub fn liberate_ping(-p: ping) -> ::pipes::send_packet<pong> {
let addr : *::pipes::send_packet<pong> = match &p {
&ping(ref x) => { cast::transmute(ptr::addr_of(x)) }
};
let liberated_value = move *addr;
cast::forget(move p);
move liberated_value
let liberated_value = *addr;
cast::forget(p);
liberated_value
}
}
......@@ -242,9 +242,9 @@ pub fn liberate_pong(-p: pong) -> ::pipes::send_packet<ping> {
let addr : *::pipes::send_packet<ping> = match &p {
&pong(ref x) => { cast::transmute(ptr::addr_of(x)) }
};
let liberated_value = move *addr;
cast::forget(move p);
move liberated_value
let liberated_value = *addr;
cast::forget(p);
liberated_value
}
}
......@@ -262,16 +262,16 @@ pub mod client {
pub fn do_ping(-c: ping) -> pong {
let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pingpong::ping(move sp));
move rp
::pipes::send(c, pingpong::ping(sp));
rp
}
pub fn do_pong(-c: pong) -> (ping, ()) {
let packet = ::pipes::recv(move c);
let packet = ::pipes::recv(c);
if packet.is_none() {
fail!(~"sender closed the connection")
}
(pingpong::liberate_pong(option::unwrap(move packet)), ())
(pingpong::liberate_pong(option::unwrap(packet)), ())
}
}
......@@ -282,32 +282,32 @@ pub mod server {
pub type pong = ::pipes::send_packet<pingpong::pong>;
pub fn do_ping(-c: ping) -> (pong, ()) {
let packet = ::pipes::recv(move c);
let packet = ::pipes::recv(c);
if packet.is_none() {
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 {
let (sp, rp) = ::pipes::entangle();
::pipes::send(move c, pingpong::pong(move sp));
move rp
::pipes::send(c, pingpong::pong(sp));
rp
}
}
}
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");
let (_chan, _data) = pingpong::client::do_pong(move chan);
let (_chan, _data) = pingpong::client::do_pong(chan);
log(error, ~"Received pong");
}
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");
let _chan = pingpong::server::do_pong(move chan);
let _chan = pingpong::server::do_pong(chan);
log(error, ~"Sent pong");
}
......@@ -319,12 +319,12 @@ pub fn main() {
let client_ = ~mut Some(client_);
let server_ = ~mut Some(server_);
task::spawn {|move client_|
task::spawn {|client_|
let mut client__ = none;
*client_ <-> client__;
client(option::unwrap(client__));
};
task::spawn {|move server_|
task::spawn {|server_|
let mut server_ˊ = none;
*server_ <-> server_ˊ;
server(option::unwrap(server_ˊ));
......
......@@ -19,7 +19,7 @@
fn rendezvous() {
let (c, s) = streamp::init();
let streams: ~[streamp::client::open<int>] = ~[move c];
let streams: ~[streamp::client::open<int>] = ~[c];
error!("%?", streams[0]);
}
......
......@@ -60,7 +60,7 @@ fn square_from_char(c: char) -> 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 = ~[];
for in.each_line |line| {
let mut row = ~[];
......
......@@ -17,5 +17,5 @@
pub fn main() {
let (bc, _bp) = stream::init();
stream::client::send(move bc, ~"abc");
stream::client::send(bc, ~"abc");
}
......@@ -12,15 +12,15 @@
pub fn main() {
let (p,c) = pipes::stream();
do task::try |move c| {
do task::try || {
let (p2,c2) = pipes::stream();
do task::spawn |move p2| {
do task::spawn || {
p2.recv();
error!("sibling fails");
fail!();
}
let (p3,c3) = pipes::stream();
c.send(move c3);
c.send(c3);
c2.send(());
error!("child blocks");
p3.recv();
......
......@@ -14,19 +14,19 @@
pub fn main() {
let (p,c) = pipes::stream();
do task::try |move c| {
do task::try || {
let (p2,c2) = pipes::stream();
do task::spawn |move p2| {
do task::spawn || {
p2.recv();
error!("sibling fails");
fail!();
}
let (p3,c3) = pipes::stream();
c.send(move c3);
c.send(c3);
c2.send(());
error!("child blocks");
let (p, c) = pipes::stream();
(move p, move p3).select();
(p, p3).select();
c.send(());
};
error!("parent tries");
......
......@@ -23,5 +23,5 @@ impl thing { fn f(self) {} }
pub fn main() {
let z = thing();
(move z).f();
(z).f();
}
......@@ -20,7 +20,7 @@ fn addEnd(&self, element: &self/T) {
next: option::None
};
self.next = Some(@(move newList));
self.next = Some(@(newList));
}
}
......
......@@ -11,5 +11,5 @@
pub fn main()
{
let y = ~1;
move y;
y;
}
......@@ -20,7 +20,7 @@ trait JD : Deserializable<json::Deserializer> { }
fn exec<T: JD>() {
let doc = result::unwrap(json::from_str(""));
let _v: T = deserialize(&json::Deserializer(move doc));
let _v: T = deserialize(&json::Deserializer(doc));
fail!()
}
......
......@@ -13,14 +13,14 @@
fn lp<T>(s: ~str, f: fn(~str) -> T) -> T {
while false {
let r = f(s);
return (move r);
return (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); move r })
g(s, |v| { let r = f(v); r })
}
pub fn main() {}
......@@ -15,7 +15,7 @@ struct A { a: ~int }
fn foo() -> fn@() -> int {
let k = ~22;
let _u = A {a: copy k};
return fn@(move k) -> int { 22 };
return fn@() -> int { 22 };
}
pub fn main() {
......
......@@ -15,7 +15,7 @@ fn the_loop() {
loop {
let x = 5;
if x > 3 {
list += ~[take(move x)];
list += ~[take(x)];
} else {
break;
}
......
......@@ -21,7 +21,7 @@ struct V<T> { v: ~[option<T>] }
fn mk<T>() -> @Smallintmap<T> {
let mut v: ~[option<T>] = ~[];
return @Smallintmap {mut v: move v};
return @Smallintmap {mut v: v};
}
fn f<T,U>() {
......
......@@ -25,7 +25,7 @@ struct F<A> { a: A }
impl<A: Copy Serializable> Serializable for F<A> {
fn serialize<S: Serializer>(s: S) {
self.a.serialize(move s);
self.a.serialize(s);
}
}
......
......@@ -13,7 +13,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: ~Triple) -> int {
let bar = foo;
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;
}
......
......@@ -13,7 +13,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: @Triple) -> int {
let bar = foo;
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;
}
......
......@@ -11,4 +11,4 @@
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); }
......@@ -11,4 +11,4 @@
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); }
......@@ -15,7 +15,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: ~Triple) -> int {
let bar = foo;
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;
}
......
......@@ -15,7 +15,7 @@ struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: @Triple) -> int {
let bar = foo;
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;
}
......
......@@ -14,9 +14,9 @@ struct Triple {a: int, b: int, c: int}
fn test(foo: ~Triple) -> ~Triple {
let foo = foo;
let bar = move foo;
let baz = move bar;
let quux = move baz;
let bar = foo;
let baz = bar;
let quux = baz;
return quux;
}
......
......@@ -15,9 +15,9 @@ struct Triple { a: int, b: int, c: int }
fn test(foo: @Triple) -> @Triple {
let foo = foo;
let bar = move foo;
let baz = move bar;
let quux = move baz;
let bar = foo;
let baz = bar;
let quux = baz;
return quux;
}
......
......@@ -13,7 +13,7 @@
pub fn main() {
let x = ~~[10];
// Test forgetting a local by move-in
test(move x);
test(x);
// Test forgetting a temporary by move-in.
test(~~[10]);
......
......@@ -13,7 +13,7 @@
pub fn main() {
let x = @~[10];
// Test forgetting a local by move-in
test(move x);
test(x);
// Test forgetting a temporary by move-in.
test(@~[10]);
......
......@@ -10,4 +10,4 @@
fn test(-foo: int) { assert (foo == 10); }
pub fn main() { let x = 10; test(move x); }
pub fn main() { let x = 10; test(x); }
......@@ -12,7 +12,7 @@
fn f2(-thing: fn@()) { }
fn f(-thing: fn@()) {
f2(move thing);
f2(thing);
}
pub fn main() {
......
......@@ -12,6 +12,6 @@ pub fn main() {
let y: int = 42;
let mut x: int;
x = move y;
x = y;
assert (x == 42);
}
......@@ -4,7 +4,7 @@ struct S {
impl S {
fn foo(self) {
(move self).bar();
self.bar();
}
fn bar(self) {
......
......@@ -13,7 +13,7 @@ struct X {
}
fn apply<T>(x: T, f: fn(T)) {
f(move x);
f(x);
}
fn check_int(x: int) {
......
......@@ -21,8 +21,8 @@ fn finalize(&self) {
}
fn unwrap<T>(+o: Option<T>) -> T {
match move o {
Some(move v) => move v,
match o {
Some(v) => v,
None => fail!()
}
}
......@@ -32,7 +32,7 @@ pub fn main() {
{
let b = Some(dtor { x:x });
let c = unwrap(move b);
let c = unwrap(b);
}
assert *x == 0;
......
......@@ -44,21 +44,21 @@
)
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>,
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 (
{
$($message:path$(($($x: ident),+))||* -> $next:ident $e:expr)+
} => (
|m| match move m {
|m| match m {
$(Some($message($($($x,)+)* next)) => {
let $next = move_it!(next);
$e })+
......@@ -70,15 +70,15 @@ fn move_it<T>(-x: T) -> T { move x }
fn client_follow(+bank: bank::client::login) {
use bank::*;
let bank = client::login(move bank, ~"theincredibleholk", ~"1234");
let bank = switch(move bank, follow! (
ok -> connected { move connected }
let bank = client::login(bank, ~"theincredibleholk", ~"1234");
let bank = switch(bank, follow! (
ok -> connected { connected }
invalid -> _next { fail!(~"bank closed the connected") }
));
let bank = client::deposit(move bank, 100.00);
let bank = client::withdrawal(move bank, 50.00);
switch(move bank, follow! (
let bank = client::deposit(bank, 100.00);
let bank = client::withdrawal(bank, 50.00);
switch(bank, follow! (
money(m) -> _next {
io::println(~"Yay! I got money!");
}
......@@ -91,8 +91,8 @@ fn client_follow(+bank: bank::client::login) {
fn bank_client(+bank: bank::client::login) {
use bank::*;
let bank = client::login(move bank, ~"theincredibleholk", ~"1234");
let bank = match try_recv(move bank) {
let bank = client::login(bank, ~"theincredibleholk", ~"1234");
let bank = match try_recv(bank) {
Some(ok(connected)) => {
move_it!(connected)
}
......@@ -100,9 +100,9 @@ fn bank_client(+bank: bank::client::login) {
None => { fail!(~"bank closed the connection") }
};
let bank = client::deposit(move bank, 100.00);
let bank = client::withdrawal(move bank, 50.00);
match try_recv(move bank) {
let bank = client::deposit(bank, 100.00);
let bank = client::withdrawal(bank, 50.00);
match try_recv(bank) {
Some(money(*)) => {
io::println(~"Yay! I got money!");
}
......
......@@ -32,7 +32,7 @@ pub fn main() {
let iotask = &uv::global_loop::get();
pipes::spawn_service(oneshot::init, |p| {
match try_recv(move p) {
match try_recv(p) {
Some(*) => { fail!() }
None => { }
}
......@@ -47,11 +47,11 @@ pub fn main() {
fn failtest() {
let (c, p) = oneshot::init();
do task::spawn_with(move c) |_c| {
do task::spawn_with(c) |_c| {
fail!();
}
error!("%?", recv(move p));
error!("%?", recv(p));
// make sure we get killed if we missed it in the receive.
loop { task::yield() }
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册