Skip to content

Commit 0528329

Browse files
committed
auto merge of #4964 : luqmana/rust/demove, r=graydon
As per #4339/#3676 this pull removes all uses `move` and gets rid of parsing it in libsyntax. So that's one more thing to cross off #4707
2 parents 690d038 + 3a19eef commit 0528329

File tree

270 files changed

+1386
-1405
lines changed

Some content is hidden

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

270 files changed

+1386
-1405
lines changed

doc/rust.md

+1-1
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

+1-1
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

+10-10
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

+1-1
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/compiletest/compiletest.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub fn make_tests(config: config) -> ~[test::TestDescAndFn] {
177177
tests.push(make_test(config, file))
178178
}
179179
}
180-
move tests
180+
tests
181181
}
182182

183183
pub fn is_test(config: config, testfile: &Path) -> bool {

src/compiletest/procsrv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ pub fn run(lib_path: ~str,
7878
writeclose(pipe_in.out, input);
7979
let p = pipes::PortSet();
8080
let ch = p.chan();
81-
do task::spawn_sched(task::SingleThreaded) |move ch| {
81+
do task::spawn_sched(task::SingleThreaded) || {
8282
let errput = readclose(pipe_err.in);
8383
ch.send((2, errput));
8484
}
8585
let ch = p.chan();
86-
do task::spawn_sched(task::SingleThreaded) |move ch| {
86+
do task::spawn_sched(task::SingleThreaded) || {
8787
let output = readclose(pipe_out.in);
8888
ch.send((1, output));
8989
}

src/libcargo/cargo.rc

+3-3
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ pub fn configure(opts: Options) -> Cargo {
744744
~" or package manager to get it to work correctly");
745745
}
746746

747-
move c
747+
c
748748
}
749749

750750
pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
@@ -1655,10 +1655,10 @@ pub fn dump_sources(c: &Cargo) {
16551655
_ => ()
16561656
}
16571657

1658-
hash.insert(copy k, json::Object(move chash));
1658+
hash.insert(copy k, json::Object(chash));
16591659
}
16601660

1661-
json::to_writer(writer, &json::Object(move hash))
1661+
json::to_writer(writer, &json::Object(hash))
16621662
}
16631663
result::Err(e) => {
16641664
error(fmt!("could not dump sources: %s", e));

src/libcore/at_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ pub mod raw {
229229
(**repr).unboxed.fill += sys::size_of::<T>();
230230
let p = addr_of(&((**repr).unboxed.data));
231231
let p = ptr::offset(p, fill) as *mut T;
232-
rusti::move_val_init(&mut(*p), move initval);
232+
rusti::move_val_init(&mut(*p), initval);
233233
}
234234

235235
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
236236
reserve_at_least(&mut *v, v.len() + 1u);
237-
push_fast(v, move initval);
237+
push_fast(v, initval);
238238
}
239239

240240
/**

src/libcore/cast.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
2929
* reinterpret_cast on pointer types.
3030
*/
3131
#[inline(always)]
32-
pub unsafe fn forget<T>(thing: T) { rusti::forget(move thing); }
32+
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }
3333

3434
/**
3535
* Force-increment the reference count on a shared box. If used
3636
* carelessly, this can leak the box. Use this in conjunction with transmute
3737
* and/or reinterpret_cast when such calls would otherwise scramble a box's
3838
* reference count
3939
*/
40-
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(move t); }
40+
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
4141

4242
/**
4343
* Transform a value of one type into a value of another type.
@@ -50,23 +50,23 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(move t); }
5050
#[inline(always)]
5151
pub unsafe fn transmute<L, G>(thing: L) -> G {
5252
let newthing: G = reinterpret_cast(&thing);
53-
forget(move thing);
54-
move newthing
53+
forget(thing);
54+
newthing
5555
}
5656

5757
/// Coerce an immutable reference to be mutable.
5858
#[inline(always)]
59-
pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(move ptr) }
59+
pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(ptr) }
6060

6161
/// Coerce a mutable reference to be immutable.
6262
#[inline(always)]
6363
pub unsafe fn transmute_immut<T>(ptr: &a/mut T) -> &a/T {
64-
transmute(move ptr)
64+
transmute(ptr)
6565
}
6666

6767
/// Coerce a borrowed pointer to have an arbitrary associated region.
6868
#[inline(always)]
69-
pub unsafe fn transmute_region<T>(ptr: &a/T) -> &b/T { transmute(move ptr) }
69+
pub unsafe fn transmute_region<T>(ptr: &a/T) -> &b/T { transmute(ptr) }
7070

7171
/// Coerce an immutable reference to be mutable.
7272
#[inline(always)]
@@ -83,7 +83,7 @@ pub unsafe fn transmute_immut_unsafe<T>(ptr: *const T) -> *T {
8383
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
8484
#[inline(always)]
8585
pub unsafe fn transmute_mut_region<T>(ptr: &a/mut T) -> &b/mut T {
86-
transmute(move ptr)
86+
transmute(ptr)
8787
}
8888

8989
/// Transforms lifetime of the second pointer to match the first.
@@ -132,9 +132,9 @@ pub mod tests {
132132
use managed::raw::BoxRepr;
133133
unsafe {
134134
let x = @100u8;
135-
let x: *BoxRepr = transmute(move x);
135+
let x: *BoxRepr = transmute(x);
136136
assert (*x).data == 100;
137-
let _x: @int = transmute(move x);
137+
let _x: @int = transmute(x);
138138
}
139139
}
140140

src/libcore/dlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<T: Copy> DList<T> {
493493
v[index] = *data;
494494
}
495495
}
496-
move v
496+
v
497497
}
498498
}
499499

0 commit comments

Comments
 (0)