Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove move #4964

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial-borrowed-ptr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 10 additions & 10 deletions doc/tutorial-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
}

Expand All @@ -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));
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
};

Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub fn make_tests(config: config) -> ~[test::TestDescAndFn] {
tests.push(make_test(config, file))
}
}
move tests
tests
}

pub fn is_test(config: config, testfile: &Path) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ pub fn run(lib_path: ~str,
writeclose(pipe_in.out, input);
let p = pipes::PortSet();
let ch = p.chan();
do task::spawn_sched(task::SingleThreaded) |move ch| {
do task::spawn_sched(task::SingleThreaded) || {
let errput = readclose(pipe_err.in);
ch.send((2, errput));
}
let ch = p.chan();
do task::spawn_sched(task::SingleThreaded) |move ch| {
do task::spawn_sched(task::SingleThreaded) || {
let output = readclose(pipe_out.in);
ch.send((1, output));
}
Expand Down
6 changes: 3 additions & 3 deletions src/libcargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ pub fn configure(opts: Options) -> Cargo {
~" or package manager to get it to work correctly");
}

move c
c
}

pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
Expand Down Expand Up @@ -1655,10 +1655,10 @@ pub fn dump_sources(c: &Cargo) {
_ => ()
}

hash.insert(copy k, json::Object(move chash));
hash.insert(copy k, json::Object(chash));
}

json::to_writer(writer, &json::Object(move hash))
json::to_writer(writer, &json::Object(hash))
}
result::Err(e) => {
error(fmt!("could not dump sources: %s", e));
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ pub mod raw {
(**repr).unboxed.fill += sys::size_of::<T>();
let p = addr_of(&((**repr).unboxed.data));
let p = ptr::offset(p, fill) as *mut T;
rusti::move_val_init(&mut(*p), move initval);
rusti::move_val_init(&mut(*p), initval);
}

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

/**
Expand Down
20 changes: 10 additions & 10 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
* reinterpret_cast on pointer types.
*/
#[inline(always)]
pub unsafe fn forget<T>(thing: T) { rusti::forget(move thing); }
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }

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

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

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

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

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

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

/// Transforms lifetime of the second pointer to match the first.
Expand Down Expand Up @@ -132,9 +132,9 @@ pub mod tests {
use managed::raw::BoxRepr;
unsafe {
let x = @100u8;
let x: *BoxRepr = transmute(move x);
let x: *BoxRepr = transmute(x);
assert (*x).data == 100;
let _x: @int = transmute(move x);
let _x: @int = transmute(x);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ impl<T: Copy> DList<T> {
v[index] = *data;
}
}
move v
v
}
}

Expand Down
Loading