Skip to content

Commit 178882c

Browse files
committed
tests/tutorials: Get rid of move.
1 parent e244f10 commit 178882c

File tree

150 files changed

+409
-411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+409
-411
lines changed

doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ else enum extern
213213
false fn for
214214
if impl
215215
let log loop
216-
match mod move mut
216+
match mod mut
217217
priv pub pure
218218
ref return
219219
self static struct super

doc/tutorial-borrowed-ptr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ fn example5c(x: @S) -> int {
431431
let y = &v.g;
432432
...
433433
}
434-
x.f = move v; // Replace x.f
434+
x.f = v; // Replace x.f
435435
...
436436
# return 0;
437437
}

doc/tutorial-tasks.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ use pipes::{stream, Port, Chan};
161161
162162
let (port, chan): (Port<int>, Chan<int>) = stream();
163163
164-
do spawn |move chan| {
164+
do spawn || {
165165
let result = some_expensive_computation();
166166
chan.send(result);
167167
}
@@ -192,7 +192,7 @@ spawns the child task.
192192
# use pipes::{stream, Port, Chan};
193193
# fn some_expensive_computation() -> int { 42 }
194194
# let (port, chan) = stream();
195-
do spawn |move chan| {
195+
do spawn || {
196196
let result = some_expensive_computation();
197197
chan.send(result);
198198
}
@@ -229,7 +229,7 @@ following program is ill-typed:
229229
# fn some_expensive_computation() -> int { 42 }
230230
let (port, chan) = stream();
231231
232-
do spawn |move chan| {
232+
do spawn {
233233
chan.send(some_expensive_computation());
234234
}
235235
@@ -248,12 +248,12 @@ Instead we can use a `SharedChan`, a type that allows a single
248248
use pipes::{stream, SharedChan};
249249
250250
let (port, chan) = stream();
251-
let chan = SharedChan(move chan);
251+
let chan = SharedChan(chan);
252252
253253
for uint::range(0, 3) |init_val| {
254254
// Create a new channel handle to distribute to the child task
255255
let child_chan = chan.clone();
256-
do spawn |move child_chan| {
256+
do spawn {
257257
child_chan.send(some_expensive_computation(init_val));
258258
}
259259
}
@@ -283,10 +283,10 @@ might look like the example below.
283283
// Create a vector of ports, one for each child task
284284
let ports = do vec::from_fn(3) |init_val| {
285285
let (port, chan) = stream();
286-
do spawn |move chan| {
286+
do spawn {
287287
chan.send(some_expensive_computation(init_val));
288288
}
289-
move port
289+
port
290290
};
291291
292292
// Wait on each port, accumulating the results
@@ -398,13 +398,13 @@ before returning. Hence:
398398
# fn sleep_forever() { loop { task::yield() } }
399399
# do task::try {
400400
let (receiver, sender): (Port<int>, Chan<int>) = stream();
401-
do spawn |move receiver| { // Bidirectionally linked
401+
do spawn { // Bidirectionally linked
402402
// Wait for the supervised child task to exist.
403403
let message = receiver.recv();
404404
// Kill both it and the parent task.
405405
assert message != 42;
406406
}
407-
do try |move sender| { // Unidirectionally linked
407+
do try { // Unidirectionally linked
408408
sender.send(42);
409409
sleep_forever(); // Will get woken up by force
410410
}
@@ -505,7 +505,7 @@ Here is the code for the parent task:
505505
506506
let (from_child, to_child) = DuplexStream();
507507
508-
do spawn |move to_child| {
508+
do spawn {
509509
stringifier(&to_child);
510510
};
511511

doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ Moving it into a mutable slot makes the elements assignable.
12601260
let crayons: ~[Crayon] = ~[BananaMania, Beaver, Bittersweet];
12611261
12621262
// Put the vector into a mutable slot
1263-
let mut mutable_crayons = move crayons;
1263+
let mut mutable_crayons = crayons;
12641264
12651265
// Now it's mutable to the bone
12661266
mutable_crayons[0] = Apricot;

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ pub fn encode_metadata(parms: encode_parms, crate: &crate) -> ~[u8] {
12291229
let ecx: @encode_ctxt = @encode_ctxt({
12301230
diag: parms.diag,
12311231
tcx: parms.tcx,
1232-
stats: @mut move stats,
1232+
stats: @mut stats,
12331233
reachable: parms.reachable,
12341234
reexports2: parms.reexports2,
12351235
item_symbols: parms.item_symbols,

src/test/auxiliary/cci_class_6.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod kitties {
2727
cat {
2828
meows: in_x,
2929
how_hungry: in_y,
30-
info: move in_info
30+
info: in_info
3131
}
3232
}
3333
}

src/test/bench/core-vec-append.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn collect_dvec(num: uint) -> ~[uint] {
2727
for uint::range(0u, num) |i| {
2828
result.push(i);
2929
}
30-
return dvec::unwrap(move result);
30+
return dvec::unwrap(result);
3131
}
3232

3333
fn main() {

src/test/bench/graph500-bfs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
141141
};
142142
}
143143

144-
move marks
144+
marks
145145
}
146146

147147
/**
@@ -260,7 +260,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
260260
i += 1;
261261
let old_len = colors.len();
262262
263-
let color = arc::ARC(move colors);
263+
let color = arc::ARC(colors);
264264
265265
let color_vec = arc::get(&color); // FIXME #3387 requires this temp
266266
colors = do par::mapi(*color_vec) {

src/test/bench/msgsend-pipes-shared.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use io::WriterUtil;
2727
use pipes::{Port, Chan, SharedChan};
2828

2929
macro_rules! move_out (
30-
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
30+
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
3131
)
3232

3333
enum request {
@@ -58,7 +58,7 @@ fn run(args: &[~str]) {
5858
let (from_child, to_parent) = pipes::stream();
5959
let (from_parent, to_child) = pipes::stream();
6060

61-
let to_child = SharedChan(move to_child);
61+
let to_child = SharedChan(to_child);
6262

6363
let size = uint::from_str(args[1]).get();
6464
let workers = uint::from_str(args[2]).get();
@@ -68,16 +68,16 @@ fn run(args: &[~str]) {
6868
for uint::range(0, workers) |_i| {
6969
let to_child = to_child.clone();
7070
do task::task().future_result(|+r| {
71-
worker_results.push(move r);
72-
}).spawn |move to_child| {
71+
worker_results.push(r);
72+
}).spawn || {
7373
for uint::range(0, size / workers) |_i| {
7474
//error!("worker %?: sending %? bytes", i, num_bytes);
7575
to_child.send(bytes(num_bytes));
7676
}
7777
//error!("worker %? exiting", i);
7878
};
7979
}
80-
do task::spawn |move from_parent, move to_parent| {
80+
do task::spawn || {
8181
server(from_parent, to_parent);
8282
}
8383

src/test/bench/msgsend-pipes.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use io::WriterUtil;
2323
use pipes::{Port, PortSet, Chan};
2424

2525
macro_rules! move_out (
26-
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
26+
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
2727
)
2828

2929
enum request {
@@ -54,7 +54,7 @@ fn run(args: &[~str]) {
5454
let (from_child, to_parent) = pipes::stream();
5555
let (from_parent_, to_child) = pipes::stream();
5656
let from_parent = PortSet();
57-
from_parent.add(move from_parent_);
57+
from_parent.add(from_parent_);
5858

5959
let size = uint::from_str(args[1]).get();
6060
let workers = uint::from_str(args[2]).get();
@@ -63,18 +63,18 @@ fn run(args: &[~str]) {
6363
let mut worker_results = ~[];
6464
for uint::range(0, workers) |_i| {
6565
let (from_parent_, to_child) = pipes::stream();
66-
from_parent.add(move from_parent_);
66+
from_parent.add(from_parent_);
6767
do task::task().future_result(|+r| {
68-
worker_results.push(move r);
69-
}).spawn |move to_child| {
68+
worker_results.push(r);
69+
}).spawn || {
7070
for uint::range(0, size / workers) |_i| {
7171
//error!("worker %?: sending %? bytes", i, num_bytes);
7272
to_child.send(bytes(num_bytes));
7373
}
7474
//error!("worker %? exiting", i);
7575
};
7676
}
77-
do task::spawn |move from_parent, move to_parent| {
77+
do task::spawn || {
7878
server(from_parent, to_parent);
7979
}
8080

src/test/bench/msgsend-ring-mutex-arcs.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ fn recv(p: &pipe) -> uint {
4040

4141
fn init() -> (pipe,pipe) {
4242
let m = arc::MutexARC(~[]);
43-
((&m).clone(), move m)
43+
((&m).clone(), m)
4444
}
4545

4646

4747
fn thread_ring(i: uint,
4848
count: uint,
4949
+num_chan: pipe,
5050
+num_port: pipe) {
51-
let mut num_chan = move Some(move num_chan);
52-
let mut num_port = move Some(move num_port);
51+
let mut num_chan = Some(num_chan);
52+
let mut num_port = Some(num_port);
5353
// Send/Receive lots of messages.
5454
for uint::range(0u, count) |j| {
5555
//error!("task %?, iter %?", i, j);
5656
let mut num_chan2 = option::swap_unwrap(&mut num_chan);
5757
let mut num_port2 = option::swap_unwrap(&mut num_port);
5858
send(&num_chan2, i * j);
59-
num_chan = Some(move num_chan2);
59+
num_chan = Some(num_chan2);
6060
let _n = recv(&num_port2);
6161
//log(error, _n);
62-
num_port = Some(move num_port2);
62+
num_port = Some(num_port2);
6363
};
6464
}
6565

@@ -77,7 +77,7 @@ fn main() {
7777
let msg_per_task = uint::from_str(args[2]).get();
7878

7979
let (num_chan, num_port) = init();
80-
let mut num_chan = Some(move num_chan);
80+
let mut num_chan = Some(num_chan);
8181

8282
let start = time::precise_time_s();
8383

@@ -89,22 +89,22 @@ fn main() {
8989
let (new_chan, num_port) = init();
9090
let num_chan2 = ~mut None;
9191
*num_chan2 <-> num_chan;
92-
let num_port = ~mut Some(move num_port);
93-
let new_future = future::spawn(|move num_chan2, move num_port| {
92+
let num_port = ~mut Some(num_port);
93+
let new_future = do future::spawn() || {
9494
let mut num_chan = None;
9595
num_chan <-> *num_chan2;
9696
let mut num_port1 = None;
9797
num_port1 <-> *num_port;
9898
thread_ring(i, msg_per_task,
99-
option::unwrap(move num_chan),
100-
option::unwrap(move num_port1))
101-
});
102-
futures.push(move new_future);
103-
num_chan = Some(move new_chan);
99+
option::unwrap(num_chan),
100+
option::unwrap(num_port1))
101+
};
102+
futures.push(new_future);
103+
num_chan = Some(new_chan);
104104
};
105105

106106
// do our iteration
107-
thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port);
107+
thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
108108

109109
// synchronize
110110
for futures.each |f| { f.get() };

src/test/bench/msgsend-ring-pipes.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ proto! ring (
2929
)
3030

3131
macro_rules! move_out (
32-
($x:expr) => { unsafe { let y = move *ptr::addr_of(&$x); move y } }
32+
($x:expr) => { unsafe { let y = *ptr::addr_of(&$x); y } }
3333
)
3434

3535
fn thread_ring(i: uint,
3636
count: uint,
3737
+num_chan: ring::client::num,
3838
+num_port: ring::server::num) {
39-
let mut num_chan = move Some(move num_chan);
40-
let mut num_port = move Some(move num_port);
39+
let mut num_chan = Some(num_chan);
40+
let mut num_port = Some(num_port);
4141
// Send/Receive lots of messages.
4242
for uint::range(0, count) |j| {
4343
//error!("task %?, iter %?", i, j);
4444
let mut num_chan2 = None;
4545
let mut num_port2 = None;
4646
num_chan2 <-> num_chan;
4747
num_port2 <-> num_port;
48-
num_chan = Some(ring::client::num(option::unwrap(move num_chan2), i * j));
49-
let port = option::unwrap(move num_port2);
50-
match recv(move port) {
48+
num_chan = Some(ring::client::num(option::unwrap(num_chan2), i * j));
49+
let port = option::unwrap(num_port2);
50+
match recv(port) {
5151
ring::num(_n, p) => {
5252
//log(error, _n);
5353
num_port = Some(move_out!(p));
@@ -70,7 +70,7 @@ fn main() {
7070
let msg_per_task = uint::from_str(args[2]).get();
7171

7272
let (num_chan, num_port) = ring::init();
73-
let mut num_chan = Some(move num_chan);
73+
let mut num_chan = Some(num_chan);
7474

7575
let start = time::precise_time_s();
7676

@@ -82,23 +82,22 @@ fn main() {
8282
let (new_chan, num_port) = ring::init();
8383
let num_chan2 = ~mut None;
8484
*num_chan2 <-> num_chan;
85-
let num_port = ~mut Some(move num_port);
86-
let new_future = do future::spawn
87-
|move num_chan2, move num_port| {
85+
let num_port = ~mut Some(num_port);
86+
let new_future = do future::spawn || {
8887
let mut num_chan = None;
8988
num_chan <-> *num_chan2;
9089
let mut num_port1 = None;
9190
num_port1 <-> *num_port;
9291
thread_ring(i, msg_per_task,
93-
option::unwrap(move num_chan),
94-
option::unwrap(move num_port1))
92+
option::unwrap(num_chan),
93+
option::unwrap(num_port1))
9594
};
96-
futures.push(move new_future);
97-
num_chan = Some(move new_chan);
95+
futures.push(new_future);
96+
num_chan = Some(new_chan);
9897
};
9998

10099
// do our iteration
101-
thread_ring(0, msg_per_task, option::unwrap(move num_chan), move num_port);
100+
thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
102101

103102
// synchronize
104103
for futures.each |f| { f.get() };

0 commit comments

Comments
 (0)