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
This commit is contained in:
bors 2013-02-15 12:09:15 -08:00
commit 0528329a4f
270 changed files with 1386 additions and 1405 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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;

View File

@ -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 {

View File

@ -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));
}

View File

@ -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)) {
@ -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));

View File

@ -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);
}
/**

View File

@ -29,7 +29,7 @@ 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
@ -37,7 +37,7 @@ pub unsafe fn forget<T>(thing: T) { rusti::forget(move thing); }
* 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.
@ -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)]
@ -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.
@ -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);
}
}

View File

@ -493,7 +493,7 @@ impl<T: Copy> DList<T> {
v[index] = *data;
}
}
move v
v
}
}

View File

@ -67,18 +67,18 @@ pub pure fn DVec<A>() -> DVec<A> {
/// Creates a new dvec with a single element
pub pure fn from_elem<A>(e: A) -> DVec<A> {
DVec {mut data: ~[move e]}
DVec {mut data: ~[e]}
}
/// Creates a new dvec with the contents of a vector
pub pure fn from_vec<A>(v: ~[A]) -> DVec<A> {
DVec {mut data: move v}
DVec {mut data: v}
}
/// Consumes the vector and returns its contents
pub pure fn unwrap<A>(d: DVec<A>) -> ~[A] {
let DVec {data: v} = move d;
move v
let DVec {data: v} = d;
v
}
priv impl<A> DVec<A> {
@ -99,14 +99,14 @@ priv impl<A> DVec<A> {
data <-> self.data;
let data_ptr: *() = cast::reinterpret_cast(&data);
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
return f(move data);
return f(data);
}
}
#[inline(always)]
fn give_back(data: ~[A]) {
unsafe {
self.data = move data;
self.data = data;
}
}
@ -130,7 +130,7 @@ impl<A> DVec<A> {
*/
#[inline(always)]
fn swap(f: &fn(v: ~[A]) -> ~[A]) {
self.check_out(|v| self.give_back(f(move v)))
self.check_out(|v| self.give_back(f(v)))
}
/**
@ -141,7 +141,7 @@ impl<A> DVec<A> {
#[inline(always)]
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
do self.swap |v| {
vec::cast_from_mut(f(vec::cast_to_mut(move v)))
vec::cast_from_mut(f(vec::cast_to_mut(v)))
}
}
@ -156,16 +156,16 @@ impl<A> DVec<A> {
#[inline(always)]
fn set(w: ~[A]) {
self.check_not_borrowed();
self.data = move w;
self.data = w;
}
/// Remove and return the last element
fn pop() -> A {
do self.check_out |v| {
let mut v = move v;
let mut v = v;
let result = v.pop();
self.give_back(move v);
move result
self.give_back(v);
result
}
}
@ -176,8 +176,8 @@ impl<A> DVec<A> {
data <-> self.data;
let data_ptr: *() = cast::reinterpret_cast(&data);
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
self.data = move ~[move t];
self.data.push_all_move(move data);
self.data = ~[t];
self.data.push_all_move(data);
}
}
@ -185,25 +185,25 @@ impl<A> DVec<A> {
#[inline(always)]
fn push(t: A) {
self.check_not_borrowed();
self.data.push(move t);
self.data.push(t);
}
/// Remove and return the first element
fn shift() -> A {
do self.check_out |v| {
let mut v = move v;
let mut v = v;
let result = v.shift();
self.give_back(move v);
move result
self.give_back(v);
result
}
}
/// Reverse the elements in the list, in place
fn reverse() {
do self.check_out |v| {
let mut v = move v;
let mut v = v;
vec::reverse(v);
self.give_back(move v);
self.give_back(v);
}
}
@ -211,18 +211,18 @@ impl<A> DVec<A> {
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
do self.check_out |v| {
let result = op(v);
self.give_back(move v);
move result
self.give_back(v);
result
}
}
/// Gives access to the vector as a slice with mutable contents
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
do self.check_out |v| {
let mut v = move v;
let mut v = v;
let result = op(v);
self.give_back(move v);
move result
self.give_back(v);
result
}
}
}
@ -240,7 +240,7 @@ impl<A: Copy> DVec<A> {
/// Appends elements from `from_idx` to `to_idx` (exclusive)
fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
do self.swap |v| {
let mut v = move v;
let mut v = v;
let new_len = vec::len(v) + to_idx - from_idx;
vec::reserve(&mut v, new_len);
let mut i = from_idx;
@ -248,7 +248,7 @@ impl<A: Copy> DVec<A> {
v.push(ts[i]);
i += 1u;
}
move v
v
}
}
@ -265,7 +265,7 @@ impl<A: Copy> DVec<A> {
none { v }
Some(h) {
let len = v.len() + h;
let mut v = move v;
let mut v = v;
vec::reserve(v, len);
v
}
@ -286,8 +286,8 @@ impl<A: Copy> DVec<A> {
unsafe {
do self.check_out |v| {
let w = copy v;
self.give_back(move v);
move w
self.give_back(v);
w
}
}
}
@ -312,9 +312,9 @@ impl<A: Copy> DVec<A> {
*/
fn grow_set_elt(idx: uint, initval: &A, val: A) {
do self.swap |v| {
let mut v = move v;
let mut v = v;
v.grow_set(idx, initval, val);
move v
v
}
}
@ -340,7 +340,7 @@ impl<A: Copy> DVec<A> {
for vec::rev_each(v) |e| {
if !f(e) { break; }
}
move v
v
}
}
@ -353,7 +353,7 @@ impl<A: Copy> DVec<A> {
for vec::rev_eachi(v) |i, e| {
if !f(i, e) { break; }
}
move v
v
}
}
}

View File

@ -84,7 +84,7 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>])
Right(r) => rights.push(r)
}
}
return (move lefts, move rights);
return (lefts, rights);
}
#[inline(always)]
@ -131,8 +131,8 @@ pub pure fn is_right<T, U>(eith: &Either<T, U>) -> bool {
pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
//! Retrieves the value in the left branch. Fails if the either is Right.
match move eith {
Left(move x) => move x,
match eith {
Left(x) => x,
Right(_) => fail!(~"either::unwrap_left Right")
}
}
@ -141,8 +141,8 @@ pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
//! Retrieves the value in the right branch. Fails if the either is Left.
match move eith {
Right(move x) => move x,
match eith {
Right(x) => x,
Left(_) => fail!(~"either::unwrap_right Left")
}
}

View File

@ -510,7 +510,7 @@ pub mod rt {
unsafe { str::unshift_char(&mut s, ' ') };
}
}
return unsafe { pad(cv, move s, PadSigned) };
return unsafe { pad(cv, s, PadSigned) };
}
pub pure fn conv_uint(cv: Conv, u: uint) -> ~str {
let prec = get_int_precision(cv);
@ -522,7 +522,7 @@ pub mod rt {
TyBits => uint_to_str_prec(u, 2, prec),
TyOctal => uint_to_str_prec(u, 8, prec)
};
return unsafe { pad(cv, move rs, PadUnsigned) };
return unsafe { pad(cv, rs, PadUnsigned) };
}
pub pure fn conv_bool(cv: Conv, b: bool) -> ~str {
let s = if b { ~"true" } else { ~"false" };
@ -532,7 +532,7 @@ pub mod rt {
}
pub pure fn conv_char(cv: Conv, c: char) -> ~str {
let mut s = str::from_char(c);
return unsafe { pad(cv, move s, PadNozero) };
return unsafe { pad(cv, s, PadNozero) };
}
pub pure fn conv_str(cv: Conv, s: &str) -> ~str {
// For strings, precision is the maximum characters
@ -545,7 +545,7 @@ pub mod rt {
s.to_owned()
}
};
return unsafe { pad(cv, move unpadded, PadNozero) };
return unsafe { pad(cv, unpadded, PadNozero) };
}
pub pure fn conv_float(cv: Conv, f: float) -> ~str {
let (to_str, digits) = match cv.precision {
@ -560,7 +560,7 @@ pub mod rt {
s = ~" " + s;
}
}
return unsafe { pad(cv, move s, PadFloat) };
return unsafe { pad(cv, s, PadFloat) };
}
pub pure fn conv_poly<T>(cv: Conv, v: &T) -> ~str {
let s = sys::log_str(v);
@ -589,7 +589,7 @@ pub mod rt {
let diff = prec - len;
let pad = str::from_chars(vec::from_elem(diff, '0'));
pad + s
} else { move s }
} else { s }
};
}
pub pure fn get_int_precision(cv: Conv) -> uint {
@ -603,13 +603,13 @@ pub mod rt {
pub enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
pub fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str {
let mut s = move s; // sadtimes
let mut s = s; // sadtimes
let uwidth : uint = match cv.width {
CountImplied => return (move s),
CountImplied => return (s),
CountIs(width) => { width as uint }
};
let strlen = str::char_len(s);
if uwidth <= strlen { return (move s); }
if uwidth <= strlen { return (s); }
let mut padchar = ' ';
let diff = uwidth - strlen;
if have_flag(cv.flags, flag_left_justify) {

View File

@ -50,7 +50,7 @@ pub fn deflate_bytes(bytes: &[const u8]) -> ~[u8] {
let out = vec::raw::from_buf_raw(res as *u8,
outsz as uint);
libc::free(res);
move out
out
}
}
}
@ -68,7 +68,7 @@ pub fn inflate_bytes(bytes: &[const u8]) -> ~[u8] {
let out = vec::raw::from_buf_raw(res as *u8,
outsz as uint);
libc::free(res);
move out
out
}
}
}

View File

@ -183,7 +183,7 @@ fn SipState(key0: u64, key1: u64) -> SipState {
mut ntail : 0u,
};
(&state).reset();
move state
state
}
@ -352,7 +352,7 @@ impl Streaming for &SipState {
for vec::each(r) |b| {
s += uint::to_str_radix(*b as uint, 16u);
}
move s
s
}
#[inline(always)]
@ -447,7 +447,7 @@ pub fn test_siphash() {
for vec::each(*r) |b| {
s += uint::to_str_radix(*b as uint, 16u);
}
move s
s
}
while t < 64 {

View File

@ -178,7 +178,7 @@ impl<T: Reader> ReaderUtil for T {
let count = self.read(bytes, len);
unsafe { vec::raw::set_len(&mut bytes, count); }
move bytes
bytes
}
fn read_line(&self) -> ~str {
@ -249,7 +249,7 @@ impl<T: Reader> ReaderUtil for T {
bytes = vec::slice(bytes, offset, bytes.len());
}
}
move chars
chars
}
fn read_char(&self) -> char {
@ -273,7 +273,7 @@ impl<T: Reader> ReaderUtil for T {
fn read_whole_stream(&self) -> ~[u8] {
let mut bytes: ~[u8] = ~[];
while !self.eof() { bytes.push_all(self.read_bytes(2048u)); }
move bytes
bytes
}
fn each_byte(&self, it: fn(int) -> bool) {
@ -999,7 +999,7 @@ pub struct BytesWriter {
impl Writer for BytesWriter {
fn write(&self, v: &[const u8]) {
do self.bytes.swap |bytes| {
let mut bytes = move bytes;
let mut bytes = bytes;
let v_len = v.len();
let bytes_len = bytes.len();
@ -1014,7 +1014,7 @@ impl Writer for BytesWriter {
self.pos += v_len;
move bytes
bytes
}
}
fn seek(&self, offset: int, whence: SeekStyle) {
@ -1035,7 +1035,7 @@ pub pure fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
let wr = @BytesWriter();
f(wr as Writer);
// FIXME (#3758): This should not be needed.
unsafe { wr.bytes.check_out(|bytes| move bytes) }
unsafe { wr.bytes.check_out(|bytes| bytes) }
}
pub pure fn with_str_writer(f: fn(Writer)) -> ~str {
@ -1048,7 +1048,7 @@ pub pure fn with_str_writer(f: fn(Writer)) -> ~str {
}
assert str::is_utf8(v);
unsafe { move ::cast::transmute(move v) }
unsafe { ::cast::transmute(v) }
}
// Utility functions
@ -1126,7 +1126,7 @@ pub mod fsync {
pub fn Res<t: Copy>(arg: Arg<t>) -> Res<t>{
Res {
arg: move arg
arg: arg
}
}

View File

@ -42,7 +42,7 @@ impl<A> iter::ExtendedIter<A> for IMPL_T<A> {
}
#[inline(always)]
pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B {
iter::foldl(self, move b0, blk)
iter::foldl(self, b0, blk)
}
#[inline(always)]
pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> {

View File

@ -25,7 +25,7 @@ mod inst {
unsafe {
do self.swap |v| {
v.each(f);
move v
v
}
}
}

View File

@ -154,11 +154,11 @@ pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(
pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B,
blk: fn(&B, &A) -> B)
-> B {
let mut b = move b0;
let mut b = b0;
for self.each |a| {
b = blk(&b, a);
}
move b
b
}
#[inline(always)]
@ -215,12 +215,12 @@ pub pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
match a {
&Some(ref a_) if *a_ < *b => {
*(move a)
*(a)
}
_ => Some(*b)
}
} {
Some(move val) => val,
Some(val) => val,
None => fail!(~"min called on empty iterator")
}
}
@ -230,12 +230,12 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
match a {
&Some(ref a_) if *a_ > *b => {
*(move a)
*(a)
}
_ => Some(*b)
}
} {
Some(move val) => val,
Some(val) => val,
None => fail!(~"max called on empty iterator")
}
}

View File

@ -32,15 +32,15 @@ struct Data<T> {
pub type Mut<T> = Data<T>;
pub fn Mut<T>(t: T) -> Mut<T> {
Data {value: move t, mode: ReadOnly}
Data {value: t, mode: ReadOnly}
}
pub fn unwrap<T>(m: Mut<T>) -> T {
// Borrowck should prevent us from calling unwrap while the value
// is in use, as that would be a move from a borrowed value.
assert (m.mode as uint) == (ReadOnly as uint);
let Data {value: move value, mode: _} = move m;
move value
let Data {value: value, mode: _} = m;
value
}
impl<T> Data<T> {

View File

@ -33,8 +33,8 @@ match msg {
}
// Remove the contained string, destroying the Option
let unwrapped_msg = match move msg {
Some(move m) => m,
let unwrapped_msg = match msg {
Some(m) => m,
None => ~"default message"
};
~~~
@ -126,8 +126,8 @@ pub pure fn chain<T, U>(opt: Option<T>,
* function that returns an option.
*/
match move opt {
Some(move t) => f(move t),
match opt {
Some(t) => f(t),
None => None
}
}
@ -148,9 +148,9 @@ pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
/*!
* Returns the leftmost Some() value, or None if both are None.
*/
match move opta {
Some(move opta) => Some(move opta),
_ => move optb
match opta {
Some(opta) => Some(opta),
_ => optb
}
}
@ -158,9 +158,9 @@ pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
pub pure fn while_some<T>(x: Option<T>, blk: fn(v: T) -> Option<T>) {
//! Applies a function zero or more times until the result is none.
let mut opt = move x;
let mut opt = x;
while opt.is_some() {
opt = blk(unwrap(move opt));
opt = blk(unwrap(opt));
}
}
@ -197,7 +197,7 @@ pub pure fn map_default<T, U>(opt: &r/Option<T>, def: U,
f: fn(&r/T) -> U) -> U {
//! Applies a function to the contained value or returns a default
match *opt { None => move def, Some(ref t) => f(t) }
match *opt { None => def, Some(ref t) => f(t) }
}
#[inline(always)]
@ -224,8 +224,8 @@ pub pure fn unwrap<T>(opt: Option<T>) -> T {
Instead, prefer to use pattern matching and handle the `None`
case explicitly.
*/
match move opt {
Some(move x) => move x,
match opt {
Some(x) => x,
None => fail!(~"option::unwrap none")
}
}
@ -247,8 +247,8 @@ pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
#[inline(always)]
pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T {
//! As unwrap, but with a specified failure message.
match move opt {
Some(move val) => val,
match opt {
Some(val) => val,
None => fail!(reason.to_owned()),
}
}
@ -285,7 +285,7 @@ impl<T> Option<T> {
/// Applies a function to the contained value or returns a default
#[inline(always)]
pure fn map_default<U>(&self, def: U, f: fn(&self/T) -> U) -> U {
map_default(self, move def, f)
map_default(self, def, f)
}
/// As `map_default`, but consumes the option and gives `f`
@ -402,8 +402,8 @@ impl<T: Copy Zero> Option<T> {
fn test_unwrap_ptr() {
let x = ~0;
let addr_x = ptr::addr_of(&(*x));
let opt = Some(move x);
let y = unwrap(move opt);
let opt = Some(x);
let y = unwrap(opt);
let addr_y = ptr::addr_of(&(*y));
assert addr_x == addr_y;
}
@ -412,8 +412,8 @@ fn test_unwrap_ptr() {
fn test_unwrap_str() {
let x = ~"test";
let addr_x = str::as_buf(x, |buf, _len| buf);
let opt = Some(move x);
let y = unwrap(move opt);
let opt = Some(x);
let y = unwrap(opt);
let addr_y = str::as_buf(y, |buf, _len| buf);
assert addr_x == addr_y;
}
@ -434,8 +434,8 @@ fn test_unwrap_resource() {
let i = @mut 0;
{
let x = R(i);
let opt = Some(move x);
let _y = unwrap(move opt);
let opt = Some(x);
let _y = unwrap(opt);
}
assert *i == 1;
}

View File

@ -171,7 +171,7 @@ pub fn env() -> ~[(~str,~str)] {
assert vec::len(vs) == 2u;
pairs.push((copy vs[0], copy vs[1]));
}
move pairs
pairs
}
}
}
@ -482,7 +482,7 @@ pub fn tmpdir() -> Path {
fn getenv_nonempty(v: &str) -> Option<Path> {
match getenv(v) {
Some(move x) =>
Some(x) =>
if str::is_empty(x) {
None
} else {
@ -915,7 +915,7 @@ unsafe fn load_argc_and_argv(argc: c_int, argv: **c_char) -> ~[~str] {
for uint::range(0, argc as uint) |i| {
vec::push(&mut args, str::raw::from_c_str(*argv.offset(i)));
}
move args
args
}
/**
@ -1137,7 +1137,7 @@ mod tests {
let rng: rand::Rng = rand::Rng();
let n = ~"TEST" + rng.gen_str(10u);
assert getenv(n).is_none();
move n
n
}
#[test]
@ -1171,7 +1171,7 @@ mod tests {
let n = make_rand_name();
setenv(n, s);
log(debug, copy s);
assert getenv(n) == option::Some(move s);
assert getenv(n) == option::Some(s);
}
#[test]
@ -1197,7 +1197,7 @@ mod tests {
// MingW seems to set some funky environment variables like
// "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
// from env() but not visible from getenv().
assert v2.is_none() || v2 == option::Some(move v);
assert v2.is_none() || v2 == option::Some(v);
}
}
@ -1210,7 +1210,7 @@ mod tests {
assert !vec::contains(e, &(copy n, ~"VALUE"));
e = env();
assert vec::contains(e, &(move n, ~"VALUE"));
assert vec::contains(e, &(n, ~"VALUE"));
}
#[test]

View File

@ -245,7 +245,7 @@ impl Path {
let mut st = stat::arch::default_stat();
let r = libc::stat(buf, &mut st);
if r == 0 { Some(move st) } else { None }
if r == 0 { Some(st) } else { None }
}
}
}
@ -257,7 +257,7 @@ impl Path {
let mut st = stat::arch::default_stat();
let r = libc::lstat(buf, &mut st);
if r == 0 { Some(move st) } else { None }
if r == 0 { Some(st) } else { None }
}
}
}
@ -381,7 +381,7 @@ impl GenericPath for PosixPath {
let mut components = str::split_nonempty(s, |c| c == '/');
let is_absolute = (s.len() != 0 && s[0] == '/' as u8);
return PosixPath { is_absolute: is_absolute,
components: move components }
components: components }
}
pure fn dirname() -> ~str {
@ -390,7 +390,7 @@ impl GenericPath for PosixPath {
if s.len() == 0 {
~"."
} else {
move s
s
}
}
}
@ -430,7 +430,7 @@ impl GenericPath for PosixPath {
let dpath = PosixPath(d);
match self.filename() {
Some(ref f) => dpath.push(*f),
None => move dpath
None => dpath
}
}
@ -477,7 +477,7 @@ impl GenericPath for PosixPath {
Some(ref f) => ~[copy *f]
};
return PosixPath { is_absolute: false,
components: move cs }
components: cs }
}
pure fn push_rel(other: &PosixPath) -> PosixPath {
@ -491,17 +491,17 @@ impl GenericPath for PosixPath {
let mut ss = str::split_nonempty(
*e,
|c| windows::is_sep(c as u8));
unsafe { v.push_all_move(move ss); }
unsafe { v.push_all_move(ss); }
}
PosixPath { is_absolute: self.is_absolute,
components: move v }
components: v }
}
pure fn push(s: &str) -> PosixPath {
let mut v = copy self.components;
let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8));
unsafe { v.push_all_move(move ss); }
PosixPath { components: move v, ..copy self }
unsafe { v.push_all_move(ss); }
PosixPath { components: v, ..copy self }
}
pure fn pop() -> PosixPath {
@ -511,7 +511,7 @@ impl GenericPath for PosixPath {
}
return PosixPath {
is_absolute: self.is_absolute,
components: move cs
components: cs
}
//..self }
}
@ -577,10 +577,10 @@ impl GenericPath for WindowsPath {
let mut components =
str::split_nonempty(rest, |c| windows::is_sep(c as u8));
let is_absolute = (rest.len() != 0 && windows::is_sep(rest[0]));
return WindowsPath { host: move host,
device: move device,
return WindowsPath { host: host,
device: device,
is_absolute: is_absolute,
components: move components }
components: components }
}
pure fn dirname() -> ~str {
@ -589,7 +589,7 @@ impl GenericPath for WindowsPath {
if s.len() == 0 {
~"."
} else {
move s
s
}
}
}
@ -629,7 +629,7 @@ impl GenericPath for WindowsPath {
let dpath = WindowsPath(d);
match self.filename() {
Some(ref f) => dpath.push(*f),
None => move dpath
None => dpath
}
}
@ -677,7 +677,7 @@ impl GenericPath for WindowsPath {
return WindowsPath { host: None,
device: None,
is_absolute: false,
components: move cs }
components: cs }
}
pure fn push_rel(other: &WindowsPath) -> WindowsPath {
@ -691,22 +691,22 @@ impl GenericPath for WindowsPath {
let mut ss = str::split_nonempty(
*e,
|c| windows::is_sep(c as u8));
unsafe { v.push_all_move(move ss); }
unsafe { v.push_all_move(ss); }
}
// tedious, but as-is, we can't use ..self
return WindowsPath {
host: copy self.host,
device: copy self.device,
is_absolute: self.is_absolute,
components: move v
components: v
}
}
pure fn push(s: &str) -> WindowsPath {
let mut v = copy self.components;
let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8));
unsafe { v.push_all_move(move ss); }
return WindowsPath { components: move v, ..copy self }
unsafe { v.push_all_move(ss); }
return WindowsPath { components: v, ..copy self }
}
pure fn pop() -> WindowsPath {
@ -718,7 +718,7 @@ impl GenericPath for WindowsPath {
host: copy self.host,
device: copy self.device,
is_absolute: self.is_absolute,
components: move cs
components: cs
}
}
@ -748,7 +748,7 @@ pub pure fn normalize(components: &[~str]) -> ~[~str] {
}
}
}
move cs
cs
}
// Various windows helpers, and tests for the impl.
@ -771,7 +771,7 @@ pub mod windows {
if s[i] == '\\' as u8 {
let pre = s.slice(2, i);
let rest = s.slice(i, s.len());
return Some((move pre, move rest));
return Some((pre, rest));
}
i += 1;
}
@ -789,7 +789,7 @@ pub mod windows {
} else {
s.slice(2, s.len())
};
return Some((s.slice(0,1), move rest));
return Some((s.slice(0,1), rest));
}
None
}

View File

@ -101,7 +101,7 @@ use vec;
const SPIN_COUNT: uint = 0;
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 } )
)
#[doc(hidden)]
@ -233,7 +233,7 @@ fn unibuffer<T>() -> ~Buffer<Packet<T>> {
unsafe {
b.data.header.buffer = reinterpret_cast(&b);
}
move b
b
}
#[doc(hidden)]
@ -241,7 +241,7 @@ pub fn packet<T>() -> *Packet<T> {
let b = unibuffer();
let p = ptr::addr_of(&(b.data));
// We'll take over memory management from here.
unsafe { forget(move b) }
unsafe { forget(b) }
p
}
@ -252,7 +252,7 @@ pub fn entangle_buffer<T: Owned, Tstart: Owned>(
-> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>)
{
let p = init(unsafe { reinterpret_cast(&buffer) }, &buffer.data);
unsafe { forget(move buffer) }
unsafe { forget(buffer) }
(SendPacketBuffered(p), RecvPacketBuffered(p))
}
@ -295,7 +295,7 @@ pub fn swap_task(dst: &mut *rust_task, src: *rust_task) -> *rust_task {
// It might be worth making both acquire and release versions of
// this.
unsafe {
transmute(rusti::atomic_xchg(transmute(move dst), src as int))
transmute(rusti::atomic_xchg(transmute(dst), src as int))
}
}
@ -335,14 +335,14 @@ fn wait_event(this: *rust_task) -> *libc::c_void {
#[doc(hidden)]
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))
}
}
#[doc(hidden)]
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))
}
}
@ -368,7 +368,7 @@ struct BufferResource<T> {
// go go gadget drop glue
}
else {
forget(move b)
forget(b)
}
}
}
@ -381,7 +381,7 @@ fn BufferResource<T>(b: ~Buffer<T>) -> BufferResource<T> {
BufferResource {
// tjc: ????
buffer: move b
buffer: b
}
}
@ -392,7 +392,7 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool {
let p = unsafe { &*p_ };
assert ptr::addr_of(&(p.header)) == header;
assert p.payload.is_none();
p.payload = move Some(move payload);
p.payload = Some(payload);
let old_state = swap_state_rel(&mut p.header.state, Full);
match old_state {
Empty => {
@ -434,7 +434,7 @@ Fails if the sender closes the connection.
*/
pub fn recv<T: Owned, Tbuffer: Owned>(
p: RecvPacketBuffered<T, Tbuffer>) -> T {
try_recv(move p).expect("connection closed")
try_recv(p).expect("connection closed")
}
/** Attempts to receive a message from a pipe.
@ -474,7 +474,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>)
let mut payload = None;
payload <-> p.payload;
p.header.state = Empty;
return Some(option::unwrap(move payload))
return Some(option::unwrap(payload))
},
Terminated => return None,
_ => {}
@ -532,7 +532,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>)
}
}
p.header.state = Empty;
return Some(option::unwrap(move payload))
return Some(option::unwrap(payload))
}
Terminated => {
// This assert detects when we've accidentally unsafely
@ -723,8 +723,8 @@ pub fn select2<A: Owned, Ab: Owned, B: Owned, Bb: Owned>(
let i = wait_many([a.header(), b.header()]);
match i {
0 => Left((try_recv(move a), move b)),
1 => Right((move a, try_recv(move b))),
0 => Left((try_recv(a), b)),
1 => Right((a, try_recv(b))),
_ => fail!(~"select2 return an invalid packet")
}
}
@ -761,10 +761,10 @@ pub fn select<T: Owned, Tb: Owned>(endpoints: ~[RecvPacketBuffered<T, Tb>])
-> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>])
{
let ready = wait_many(endpoints.map(|p| p.header()));
let mut remaining = move endpoints;
let mut remaining = endpoints;
let port = remaining.swap_remove(ready);
let result = try_recv(move port);
(ready, move result, move remaining)
let result = try_recv(port);
(ready, result, remaining)
}
/** The sending end of a pipe. It can be used to send exactly one
@ -791,7 +791,7 @@ impl<T:Owned,Tbuffer:Owned> ::ops::Drop for SendPacketBuffered<T,Tbuffer> {
if self.p != None {
let mut p = None;
p <-> self.p;
sender_terminate(option::unwrap(move p))
sender_terminate(option::unwrap(p))
}
//unsafe { error!("send_drop: %?",
// if self.buffer == none {
@ -816,7 +816,7 @@ impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
fn unwrap() -> *Packet<T> {
let mut p = None;
p <-> self.p;
option::unwrap(move p)
option::unwrap(p)
}
pure fn header() -> *PacketHeader {
@ -835,7 +835,7 @@ impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
//error!("send reuse_buffer");
let mut tmp = None;
tmp <-> self.buffer;
option::unwrap(move tmp)
option::unwrap(tmp)
}
}
@ -860,7 +860,7 @@ impl<T:Owned, Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> {
if self.p != None {
let mut p = None;
p <-> self.p;
receiver_terminate(option::unwrap(move p))
receiver_terminate(option::unwrap(p))
}
//unsafe { error!("recv_drop: %?",
// if self.buffer == none {
@ -873,14 +873,14 @@ impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> {
fn unwrap() -> *Packet<T> {
let mut p = None;
p <-> self.p;
option::unwrap(move p)
option::unwrap(p)
}
fn reuse_buffer() -> BufferResource<Tbuffer> {
//error!("recv reuse_buffer");
let mut tmp = None;
tmp <-> self.buffer;
option::unwrap(move tmp)
option::unwrap(tmp)
}
}
@ -933,14 +933,14 @@ pub fn spawn_service<T: Owned, Tb: Owned>(
// This is some nasty gymnastics required to safely move the pipe
// into a new task.
let server = ~mut Some(move server);
do task::spawn |move service, move server| {
let server = ~mut Some(server);
do task::spawn || {
let mut server_ = None;
server_ <-> *server;
service(option::unwrap(move server_))
service(option::unwrap(server_))
}
move client
client
}
/** Like `spawn_service_recv`, but for protocols that start in the
@ -957,14 +957,14 @@ pub fn spawn_service_recv<T: Owned, Tb: Owned>(
// This is some nasty gymnastics required to safely move the pipe
// into a new task.
let server = ~mut Some(move server);
do task::spawn |move service, move server| {
let server = ~mut Some(server);
do task::spawn || {
let mut server_ = None;
server_ <-> *server;
service(option::unwrap(move server_))
service(option::unwrap(server_))
}
move client
client
}
// Streams - Make pipes a little easier in general.
@ -1041,7 +1041,7 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
let mut endp = None;
endp <-> self.endp;
self.endp = Some(
streamp::client::data(unwrap(move endp), move x))
streamp::client::data(unwrap(endp), x))
}
}
@ -1050,9 +1050,9 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
fn try_send(x: T) -> bool {
let mut endp = None;
endp <-> self.endp;
match move streamp::client::try_data(unwrap(move endp), move x) {
Some(move next) => {
self.endp = Some(move next);
match streamp::client::try_data(unwrap(endp), x) {
Some(next) => {
self.endp = Some(next);
true
}
None => false
@ -1064,18 +1064,18 @@ impl<T: Owned> GenericPort<T> for Port<T> {
fn recv() -> T {
let mut endp = None;
endp <-> self.endp;
let streamp::data(x, endp) = pipes::recv(unwrap(move endp));
self.endp = Some(move endp);
move x
let streamp::data(x, endp) = pipes::recv(unwrap(endp));
self.endp = Some(endp);
x
}
fn try_recv() -> Option<T> {
let mut endp = None;
endp <-> self.endp;
match move pipes::try_recv(unwrap(move endp)) {
Some(streamp::data(move x, move endp)) => {
self.endp = Some(move endp);
Some(move x)
match pipes::try_recv(unwrap(endp)) {
Some(streamp::data(x, endp)) => {
self.endp = Some(endp);
Some(x)
}
None => None
}
@ -1122,13 +1122,13 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{
impl<T: Owned> PortSet<T> {
fn add(port: pipes::Port<T>) {
self.ports.push(move port)
self.ports.push(port)
}
fn chan() -> Chan<T> {
let (po, ch) = stream();
self.add(move po);
move ch
self.add(po);
ch
}
}
@ -1142,9 +1142,9 @@ impl<T: Owned> GenericPort<T> for PortSet<T> {
ports <-> self.ports;
while result.is_none() && ports.len() > 0 {
let i = wait_many(ports);
match move ports[i].try_recv() {
Some(move m) => {
result = Some(move m);
match ports[i].try_recv() {
Some(m) => {
result = Some(m);
}
None => {
// Remove this port.
@ -1153,7 +1153,7 @@ impl<T: Owned> GenericPort<T> for PortSet<T> {
}
}
ports <-> self.ports;
move result
result
}
fn recv() -> T {
@ -1178,29 +1178,29 @@ pub type SharedChan<T> = private::Exclusive<Chan<T>>;
impl<T: Owned> GenericChan<T> for SharedChan<T> {
fn send(x: T) {
let mut xx = Some(move x);
let mut xx = Some(x);
do self.with_imm |chan| {
let mut x = None;
x <-> xx;
chan.send(option::unwrap(move x))
chan.send(option::unwrap(x))
}
}
}
impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
fn try_send(x: T) -> bool {
let mut xx = Some(move x);
let mut xx = Some(x);
do self.with_imm |chan| {
let mut x = None;
x <-> xx;
chan.try_send(option::unwrap(move x))
chan.try_send(option::unwrap(x))
}
}
}
/// Converts a `chan` into a `shared_chan`.
pub fn SharedChan<T:Owned>(c: Chan<T>) -> SharedChan<T> {
private::exclusive(move c)
private::exclusive(c)
}
/// Receive a message from one of two endpoints.
@ -1267,24 +1267,24 @@ impl<T: Owned> ChanOne<T> {
* closed.
*/
pub fn recv_one<T: Owned>(port: PortOne<T>) -> T {
let oneshot::send(message) = recv(move port);
move message
let oneshot::send(message) = recv(port);
message
}
/// Receive a message from a oneshot pipe unless the connection was closed.
pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> {
let message = try_recv(move port);
let message = try_recv(port);
if message.is_none() { None }
else {
let oneshot::send(message) = option::unwrap(move message);
Some(move message)
let oneshot::send(message) = option::unwrap(message);
Some(message)
}
}
/// Send a message on a oneshot pipe, failing if the connection was closed.
pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
oneshot::client::send(move chan, move data);
oneshot::client::send(chan, data);
}
/**
@ -1293,7 +1293,7 @@ pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) {
*/
pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T)
-> bool {
oneshot::client::try_send(move chan, move data).is_some()
oneshot::client::try_send(chan, data).is_some()
}
pub mod rt {
@ -1301,7 +1301,7 @@ pub mod rt {
// These are used to hide the option constructors from the
// compiler because their names are changing
pub fn make_some<T>(val: T) -> Option<T> { Some(move val) }
pub fn make_some<T>(val: T) -> Option<T> { Some(val) }
pub fn make_none<T>() -> Option<T> { None }
}
@ -1318,7 +1318,7 @@ pub mod test {
c1.send(~"abc");
match (move p1, move p2).select() {
match (p1, p2).select() {
Right(_) => fail!(),
_ => ()
}
@ -1330,9 +1330,9 @@ pub mod test {
pub fn test_oneshot() {
let (c, p) = oneshot::init();
oneshot::client::send(move c, ());
oneshot::client::send(c, ());
recv_one(move p)
recv_one(p)
}
#[test]
@ -1341,7 +1341,7 @@ pub mod test {
{
// Destroy the channel
let _chan = move chan;
let _chan = chan;
}
assert !port.peek();

View File

@ -145,11 +145,11 @@ struct ArcDestruct<T> {
cast::reinterpret_cast(&data.unwrapper);
let (message, response) = option::swap_unwrap(p);
// Send 'ready' and wait for a response.
pipes::send_one(move message, ());
pipes::send_one(message, ());
// Unkillable wait. Message guaranteed to come.
if pipes::recv_one(move response) {
if pipes::recv_one(response) {
// Other task got the data.
cast::forget(move data);
cast::forget(data);
} else {
// Other task was killed. drop glue takes over.
}
@ -157,7 +157,7 @@ struct ArcDestruct<T> {
// drop glue takes over.
}
} else {
cast::forget(move data);
cast::forget(data);
}
}
}
@ -182,13 +182,13 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>)
// tried to wake us whether they should hand-off the data to
// us.
if task::failing() {
pipes::send_one(move response, false);
pipes::send_one(response, false);
// Either this swap_unwrap or the one below (at "Got
// here") ought to run.
cast::forget(option::swap_unwrap(&mut self.ptr));
} else {
assert self.ptr.is_none();
pipes::send_one(move response, true);
pipes::send_one(response, true);
}
}
}
@ -198,8 +198,8 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>)
let ptr: ~ArcData<T> = cast::reinterpret_cast(&rc.data);
let (p1,c1) = pipes::oneshot(); // ()
let (p2,c2) = pipes::oneshot(); // bool
let server: UnwrapProto = ~mut Some((move c1,move p2));
let serverp: int = cast::transmute(move server);
let server: UnwrapProto = ~mut Some((c1,p2));
let serverp: int = cast::transmute(server);
// Try to put our server end in the unwrapper slot.
if compare_and_swap(&mut ptr.unwrapper, 0, serverp) {
// Got in. Step 0: Tell destructor not to run. We are now it.
@ -210,15 +210,15 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>)
if new_count == 0 {
// We were the last owner. Can unwrap immediately.
// Also we have to free the server endpoints.
let _server: UnwrapProto = cast::transmute(move serverp);
let _server: UnwrapProto = cast::transmute(serverp);
option::swap_unwrap(&mut ptr.data)
// drop glue takes over.
} else {
// The *next* person who sees the refcount hit 0 will wake us.
let end_result =
DeathThroes { ptr: Some(move ptr),
response: Some(move c2) };
let mut p1 = Some(move p1); // argh
DeathThroes { ptr: Some(ptr),
response: Some(c2) };
let mut p1 = Some(p1); // argh
do task::rekillable {
pipes::recv_one(option::swap_unwrap(&mut p1));
}
@ -230,9 +230,9 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>)
}
} else {
// Somebody else was trying to unwrap. Avoid guaranteed deadlock.
cast::forget(move ptr);
cast::forget(ptr);
// Also we have to free the (rejected) server endpoints.
let _server: UnwrapProto = cast::transmute(move serverp);
let _server: UnwrapProto = cast::transmute(serverp);
fail!(~"Another task is already unwrapping this ARC!");
}
}
@ -248,9 +248,9 @@ pub type SharedMutableState<T> = ArcDestruct<T>;
pub unsafe fn shared_mutable_state<T: Owned>(data: T) ->
SharedMutableState<T> {
let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) };
let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) };
unsafe {
let ptr = cast::transmute(move data);
let ptr = cast::transmute(data);
ArcDestruct(ptr)
}
}
@ -263,7 +263,7 @@ pub unsafe fn get_shared_mutable_state<T: Owned>(
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
assert ptr.count > 0;
let r = cast::transmute(option::get_ref(&ptr.data));
cast::forget(move ptr);
cast::forget(ptr);
return r;
}
}
@ -275,7 +275,7 @@ pub unsafe fn get_shared_immutable_state<T: Owned>(
assert ptr.count > 0;
// Cast us back into the correct region
let r = cast::transmute_region(option::get_ref(&ptr.data));
cast::forget(move ptr);
cast::forget(ptr);
return r;
}
}
@ -286,7 +286,7 @@ pub unsafe fn clone_shared_mutable_state<T: Owned>(rc: &SharedMutableState<T>)
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
let new_count = rusti::atomic_xadd(&mut ptr.count, 1) + 1;
assert new_count >= 2;
cast::forget(move ptr);
cast::forget(ptr);
}
ArcDestruct((*rc).data)
}
@ -355,9 +355,9 @@ pub struct Exclusive<T> { x: SharedMutableState<ExData<T>> }
pub fn exclusive<T:Owned >(user_data: T) -> Exclusive<T> {
let data = ExData {
lock: LittleLock(), mut failed: false, mut data: move user_data
lock: LittleLock(), mut failed: false, mut data: user_data
};
Exclusive { x: unsafe { shared_mutable_state(move data) } }
Exclusive { x: unsafe { shared_mutable_state(data) } }
}
impl<T: Owned> Clone for Exclusive<T> {
@ -386,7 +386,7 @@ impl<T: Owned> Exclusive<T> {
(*rec).failed = true;
let result = f(&mut (*rec).data);
(*rec).failed = false;
move result
result
}
}
}
@ -401,10 +401,10 @@ impl<T: Owned> Exclusive<T> {
// FIXME(#3724) make this a by-move method on the exclusive
pub fn unwrap_exclusive<T: Owned>(arc: Exclusive<T>) -> T {
let Exclusive { x: x } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let ExData { data: data, _ } = move inner;
move data
let Exclusive { x: x } = arc;
let inner = unsafe { unwrap_shared_mutable_state(x) };
let ExData { data: data, _ } = inner;
data
}
#[cfg(test)]
@ -430,9 +430,9 @@ pub mod tests {
for uint::range(0, num_tasks) |_i| {
let total = total.clone();
let (port, chan) = pipes::stream();
futures.push(move port);
futures.push(port);
do task::spawn |move total, move chan| {
do task::spawn || {
for uint::range(0, count) |_i| {
do total.with |count| {
**count += 1;
@ -455,7 +455,7 @@ pub mod tests {
// accesses will also fail.
let x = exclusive(1);
let x2 = x.clone();
do task::try |move x2| {
do task::try || {
do x2.with |one| {
assert *one == 2;
}
@ -468,31 +468,31 @@ pub mod tests {
#[test]
pub fn exclusive_unwrap_basic() {
let x = exclusive(~~"hello");
assert unwrap_exclusive(move x) == ~~"hello";
assert unwrap_exclusive(x) == ~~"hello";
}
#[test]
pub fn exclusive_unwrap_contended() {
let x = exclusive(~~"hello");
let x2 = ~mut Some(x.clone());
do task::spawn |move x2| {
do task::spawn || {
let x2 = option::swap_unwrap(x2);
do x2.with |_hello| { }
task::yield();
}
assert unwrap_exclusive(move x) == ~~"hello";
assert unwrap_exclusive(x) == ~~"hello";
// Now try the same thing, but with the child task blocking.
let x = exclusive(~~"hello");
let x2 = ~mut Some(x.clone());
let mut res = None;
do task::task().future_result(|+r| res = Some(move r)).spawn
|move x2| {
do task::task().future_result(|+r| res = Some(r)).spawn
|| {
let x2 = option::swap_unwrap(x2);
assert unwrap_exclusive(move x2) == ~~"hello";
assert unwrap_exclusive(x2) == ~~"hello";
}
// Have to get rid of our reference before blocking.
{ let _x = move x; } // FIXME(#3161) util::ignore doesn't work here
{ let _x = x; } // FIXME(#3161) util::ignore doesn't work here
let res = option::swap_unwrap(&mut res);
res.recv();
}
@ -502,12 +502,12 @@ pub mod tests {
let x = exclusive(~~"hello");
let x2 = ~mut Some(x.clone());
let mut res = None;
do task::task().future_result(|+r| res = Some(move r)).spawn
|move x2| {
do task::task().future_result(|+r| res = Some(r)).spawn
|| {
let x2 = option::swap_unwrap(x2);
assert unwrap_exclusive(move x2) == ~~"hello";
assert unwrap_exclusive(x2) == ~~"hello";
}
assert unwrap_exclusive(move x) == ~~"hello";
assert unwrap_exclusive(x) == ~~"hello";
let res = option::swap_unwrap(&mut res);
res.recv();
}
@ -526,7 +526,7 @@ pub mod tests {
for 10.times { task::yield(); } // try to let the unwrapper go
fail!(); // punt it awake from its deadlock
}
let _z = unwrap_exclusive(move x);
let _z = unwrap_exclusive(x);
do x2.with |_hello| { }
};
assert result.is_err();

View File

@ -273,7 +273,7 @@ impl Rng {
s = s + str::from_char(self.gen_char_from(charset));
i += 1u;
}
move s
s
}
/// Return a random byte string of the specified length
@ -339,14 +339,14 @@ impl Rng {
r.push(item.item);
}
}
move r
r
}
/// Shuffle a vec
fn shuffle<T:Copy>(values: &[T]) -> ~[T] {
let mut m = vec::from_slice(values);
self.shuffle_mut(m);
move m
m
}
/// Shuffle a mutable vec in place

View File

@ -42,7 +42,7 @@ pub struct MovePtrAdaptor<V> {
inner: V
}
pub fn MovePtrAdaptor<V: TyVisitor MovePtr>(v: V) -> MovePtrAdaptor<V> {
MovePtrAdaptor { inner: move v }
MovePtrAdaptor { inner: v }
}
impl<V: TyVisitor MovePtr> MovePtrAdaptor<V> {

View File

@ -200,8 +200,8 @@ impl ReprVisitor {
fn visit_ptr_inner(ptr: *c_void, inner: *TyDesc) -> bool {
unsafe {
let mut u = ReprVisitor(ptr, self.writer);
let v = reflect::MovePtrAdaptor(move u);
visit_tydesc(inner, (move v) as @TyVisitor);
let v = reflect::MovePtrAdaptor(u);
visit_tydesc(inner, (v) as @TyVisitor);
true
}
}
@ -569,8 +569,8 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
let ptr = ptr::to_unsafe_ptr(object) as *c_void;
let tydesc = intrinsic::get_tydesc::<T>();
let mut u = ReprVisitor(ptr, writer);
let v = reflect::MovePtrAdaptor(move u);
visit_tydesc(tydesc, (move v) as @TyVisitor)
let v = reflect::MovePtrAdaptor(u);
visit_tydesc(tydesc, (v) as @TyVisitor)
}
}

View File

@ -125,9 +125,9 @@ pub pure fn to_either<T: Copy, U: Copy>(res: &Result<U, T>)
#[inline(always)]
pub pure fn chain<T, U, V>(res: Result<T, V>, op: fn(T)
-> Result<U, V>) -> Result<U, V> {
match move res {
Ok(move t) => op(move t),
Err(move e) => Err(move e)
match res {
Ok(t) => op(t),
Err(e) => Err(e)
}
}
@ -144,9 +144,9 @@ pub pure fn chain_err<T, U, V>(
res: Result<T, V>,
op: fn(t: V) -> Result<T, U>)
-> Result<T, U> {
match move res {
Ok(move t) => Ok(move t),
Err(move v) => op(move v)
match res {
Ok(t) => Ok(t),
Err(v) => op(v)
}
}
@ -309,7 +309,7 @@ pub fn map_vec<T,U:Copy,V:Copy>(
Err(copy u) => return Err(u)
}
}
return Ok(move vs);
return Ok(vs);
}
#[inline(always)]
@ -349,7 +349,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
}
i += 1u;
}
return Ok(move vs);
return Ok(vs);
}
/**
@ -377,8 +377,8 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
/// Unwraps a result, assuming it is an `ok(T)`
#[inline(always)]
pub pure fn unwrap<T, U>(res: Result<T, U>) -> T {
match move res {
Ok(move t) => move t,
match res {
Ok(t) => t,
Err(_) => fail!(~"unwrap called on an err result")
}
}
@ -386,8 +386,8 @@ pub pure fn unwrap<T, U>(res: Result<T, U>) -> T {
/// Unwraps a result, assuming it is an `err(U)`
#[inline(always)]
pub pure fn unwrap_err<T, U>(res: Result<T, U>) -> U {
match move res {
Err(move u) => move u,
match res {
Err(u) => u,
Ok(_) => fail!(~"unwrap called on an ok result")
}
}

View File

@ -258,7 +258,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
fn ProgRes(r: ProgRepr) -> ProgRes {
ProgRes {
r: move r
r: r
}
}
@ -344,11 +344,11 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
let ch_clone = ch.clone();
do task::spawn_sched(task::SingleThreaded) {
let errput = readclose(pipe_err.in);
ch.send((2, move errput));
ch.send((2, errput));
};
do task::spawn_sched(task::SingleThreaded) {
let output = readclose(pipe_out.in);
ch_clone.send((1, move output));
ch_clone.send((1, output));
};
let status = run::waitpid(pid);
let mut errs = ~"";
@ -358,10 +358,10 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
let stream = p.recv();
match stream {
(1, copy s) => {
outs = move s;
outs = s;
}
(2, copy s) => {
errs = move s;
errs = s;
}
(n, _) => {
fail!(fmt!("program_output received an unexpected file \
@ -371,8 +371,8 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
count -= 1;
};
return ProgramOutput {status: status,
out: move outs,
err: move errs};
out: outs,
err: errs};
}
}

View File

@ -216,7 +216,7 @@ pub mod tests {
assert f(20) == 30;
let original_closure: Closure = cast::transmute(move f);
let original_closure: Closure = cast::transmute(f);
let actual_function_pointer = original_closure.code;
let environment = original_closure.env;
@ -226,7 +226,7 @@ pub mod tests {
env: environment
};
let new_f: fn(int) -> int = cast::transmute(move new_closure);
let new_f: fn(int) -> int = cast::transmute(new_closure);
assert new_f(20) == 30;
}
}

View File

@ -73,7 +73,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
cast::bump_box_refcount(map);
map
} else {
let map = cast::transmute(move map_ptr);
let map = cast::transmute(map_ptr);
cast::bump_box_refcount(map);
map
}
@ -119,7 +119,7 @@ unsafe fn local_get_helper<T: Durable>(
// overwriting the local_data_box we need to give an extra reference.
// We must also give an extra reference when not removing.
let (index, data_ptr) = *result;
let data: @T = cast::transmute(move data_ptr);
let data: @T = cast::transmute(data_ptr);
cast::bump_box_refcount(data);
if do_pop {
(*map).set_elt(index, None);
@ -182,6 +182,6 @@ pub unsafe fn local_modify<T: Durable>(
// Could be more efficient by doing the lookup work, but this is easy.
let newdata = modify_fn(local_pop(task, key));
if newdata.is_some() {
local_set(task, key, option::unwrap(move newdata));
local_set(task, key, option::unwrap(newdata));
}
}

View File

@ -203,7 +203,7 @@ pub struct TaskBuilder {
pub fn task() -> TaskBuilder {
TaskBuilder {
opts: default_task_opts(),
gen_body: |body| move body, // Identity function
gen_body: |body| body, // Identity function
can_not_copy: None,
mut consumed: false,
}
@ -315,7 +315,7 @@ impl TaskBuilder {
// Construct the future and give it to the caller.
let (notify_pipe_po, notify_pipe_ch) = stream::<TaskResult>();
blk(move notify_pipe_po);
blk(notify_pipe_po);
// Reconfigure self to use a notify channel.
TaskBuilder {
@ -336,7 +336,7 @@ impl TaskBuilder {
opts: TaskOpts {
linked: self.opts.linked,
supervised: self.opts.supervised,
notify_chan: move notify_chan,
notify_chan: notify_chan,
sched: SchedOpts { mode: mode, foreign_stack_size: None}
},
can_not_copy: None,
@ -366,11 +366,7 @@ impl TaskBuilder {
notify_chan: notify_chan,
sched: self.opts.sched
},
// tjc: I think this is the line that gets miscompiled
// w/ last-use off, if we leave out the move prev_gen_body?
// that makes no sense, though...
gen_body: |move prev_gen_body,
body| { wrapper(prev_gen_body(move body)) },
gen_body: |body| { wrapper(prev_gen_body(body)) },
can_not_copy: None,
.. self.consume()
}
@ -397,12 +393,12 @@ impl TaskBuilder {
notify_chan: notify_chan,
sched: x.opts.sched
};
spawn::spawn_raw(move opts, (x.gen_body)(move f));
spawn::spawn_raw(opts, (x.gen_body)(f));
}
/// Runs a task, while transfering ownership of one argument to the child.
fn spawn_with<A: Owned>(arg: A, f: fn~(v: A)) {
let arg = ~mut Some(move arg);
do self.spawn |move arg, move f| {
let arg = ~mut Some(arg);
do self.spawn || {
f(option::swap_unwrap(arg))
}
}
@ -425,12 +421,12 @@ impl TaskBuilder {
let mut result = None;
let fr_task_builder = self.future_result(|+r| {
result = Some(move r);
result = Some(r);
});
do fr_task_builder.spawn |move f, move ch| {
do fr_task_builder.spawn || {
ch.send(f());
}
match option::unwrap(move result).recv() {
match option::unwrap(result).recv() {
Success => result::Ok(po.recv()),
Failure => result::Err(())
}
@ -471,7 +467,7 @@ pub fn spawn(f: fn~()) {
* This function is equivalent to `task().spawn(f)`.
*/
task().spawn(move f)
task().spawn(f)
}
pub fn spawn_unlinked(f: fn~()) {
@ -480,7 +476,7 @@ pub fn spawn_unlinked(f: fn~()) {
* task or the child task fails, the other will not be killed.
*/
task().unlinked().spawn(move f)
task().unlinked().spawn(f)
}
pub fn spawn_supervised(f: fn~()) {
@ -489,7 +485,7 @@ pub fn spawn_supervised(f: fn~()) {
* task or the child task fails, the other will not be killed.
*/
task().supervised().spawn(move f)
task().supervised().spawn(f)
}
pub fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) {
@ -503,7 +499,7 @@ pub fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) {
* This function is equivalent to `task().spawn_with(arg, f)`.
*/
task().spawn_with(move arg, move f)
task().spawn_with(arg, f)
}
pub fn spawn_sched(mode: SchedMode, f: fn~()) {
@ -519,7 +515,7 @@ pub fn spawn_sched(mode: SchedMode, f: fn~()) {
* greater than zero.
*/
task().sched_mode(mode).spawn(move f)
task().sched_mode(mode).spawn(f)
}
pub fn try<T:Owned>(f: fn~() -> T) -> Result<T,()> {
@ -530,7 +526,7 @@ pub fn try<T:Owned>(f: fn~() -> T) -> Result<T,()> {
* This is equivalent to task().supervised().try.
*/
task().supervised().try(move f)
task().supervised().try(f)
}
@ -719,12 +715,12 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
let mut opts = default_task_opts();
opts.linked = true;
opts.supervised = true;
move opts
opts
};
let b0 = task();
let b1 = TaskBuilder {
opts: move opts,
opts: opts,
can_not_copy: None,
.. b0
};
@ -739,12 +735,12 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
let mut opts = default_task_opts();
opts.linked = true;
opts.supervised = true;
move opts
opts
};
let b0 = task();
let b1 = TaskBuilder {
opts: move opts,
opts: opts,
can_not_copy: None,
.. b0
};
@ -843,7 +839,7 @@ fn test_add_wrapper() {
let ch = Wrapper { f: Some(ch) };
let b1 = do b0.add_wrapper |body| {
let ch = Wrapper { f: Some(ch.f.swap_unwrap()) };
fn~(move body) {
fn~() {
let ch = ch.f.swap_unwrap();
body();
ch.send(());
@ -857,15 +853,15 @@ fn test_add_wrapper() {
#[ignore(cfg(windows))]
fn test_future_result() {
let mut result = None;
do task().future_result(|+r| { result = Some(move r); }).spawn { }
assert option::unwrap(move result).recv() == Success;
do task().future_result(|+r| { result = Some(r); }).spawn { }
assert option::unwrap(result).recv() == Success;
result = None;
do task().future_result(|+r|
{ result = Some(move r); }).unlinked().spawn {
{ result = Some(r); }).unlinked().spawn {
fail!();
}
assert option::unwrap(move result).recv() == Failure;
assert option::unwrap(result).recv() == Failure;
}
#[test] #[should_fail] #[ignore(cfg(windows))]
@ -1024,7 +1020,7 @@ fn avoid_copying_the_body(spawnfn: fn(v: fn~())) {
let x = ~1;
let x_in_parent = ptr::addr_of(&(*x)) as uint;
do spawnfn |move x| {
do spawnfn || {
let x_in_child = ptr::addr_of(&(*x)) as uint;
ch.send(x_in_child);
}
@ -1041,7 +1037,7 @@ fn test_avoid_copying_the_body_spawn() {
#[test]
fn test_avoid_copying_the_body_task_spawn() {
do avoid_copying_the_body |f| {
do task().spawn |move f| {
do task().spawn || {
f();
}
}
@ -1050,7 +1046,7 @@ fn test_avoid_copying_the_body_task_spawn() {
#[test]
fn test_avoid_copying_the_body_try() {
do avoid_copying_the_body |f| {
do try |move f| {
do try || {
f()
};
}
@ -1059,7 +1055,7 @@ fn test_avoid_copying_the_body_try() {
#[test]
fn test_avoid_copying_the_body_unlinked() {
do avoid_copying_the_body |f| {
do spawn_unlinked |move f| {
do spawn_unlinked || {
f();
}
}
@ -1096,12 +1092,12 @@ fn test_unkillable() {
unsafe {
do unkillable {
let p = ~0;
let pp: *uint = cast::transmute(move p);
let pp: *uint = cast::transmute(p);
// If we are killed here then the box will leak
po.recv();
let _p: ~int = cast::transmute(move pp);
let _p: ~int = cast::transmute(pp);
}
}
@ -1116,7 +1112,7 @@ fn test_unkillable_nested() {
let (po, ch) = pipes::stream();
// We want to do this after failing
do spawn_unlinked |move ch| {
do spawn_unlinked || {
for iter::repeat(10) { yield() }
ch.send(());
}
@ -1132,12 +1128,12 @@ fn test_unkillable_nested() {
do unkillable {
do unkillable {} // Here's the difference from the previous test.
let p = ~0;
let pp: *uint = cast::transmute(move p);
let pp: *uint = cast::transmute(p);
// If we are killed here then the box will leak
po.recv();
let _p: ~int = cast::transmute(move pp);
let _p: ~int = cast::transmute(pp);
}
}
@ -1181,7 +1177,7 @@ fn test_child_doesnt_ref_parent() {
fn test_sched_thread_per_core() {
let (port, chan) = pipes::stream();
do spawn_sched(ThreadPerCore) |move chan| {
do spawn_sched(ThreadPerCore) || {
unsafe {
let cores = rt::rust_num_threads();
let reported_threads = rt::rust_sched_threads();
@ -1197,7 +1193,7 @@ fn test_sched_thread_per_core() {
fn test_spawn_thread_on_demand() {
let (port, chan) = pipes::stream();
do spawn_sched(ManualThreads(2)) |move chan| {
do spawn_sched(ManualThreads(2)) || {
unsafe {
let max_threads = rt::rust_sched_threads();
assert(max_threads as int == 2);
@ -1206,7 +1202,7 @@ fn test_spawn_thread_on_demand() {
let (port2, chan2) = pipes::stream();
do spawn_sched(CurrentScheduler) |move chan2| {
do spawn_sched(CurrentScheduler) || {
chan2.send(());
}

View File

@ -93,7 +93,7 @@ use uint;
use util;
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 } )
)
type TaskSet = LinearSet<*rust_task>;
@ -195,10 +195,10 @@ fn each_ancestor(list: &mut AncestorList,
if coalesce_this.is_some() {
// Needed coalesce. Our next ancestor becomes our old
// ancestor's next ancestor. ("next = old_next->next;")
*list = move option::unwrap(move coalesce_this);
*list = option::unwrap(coalesce_this);
} else {
// No coalesce; restore from tmp. ("next = old_next;")
*list = move tmp_list;
*list = tmp_list;
}
return early_break;
}
@ -279,7 +279,7 @@ fn each_ancestor(list: &mut AncestorList,
// Swap the list out here; the caller replaces us with it.
let rest = util::replace(&mut nobe.ancestors,
AncestorList(None));
(Some(move rest), need_unwind)
(Some(rest), need_unwind)
} else {
(None, need_unwind)
}
@ -292,8 +292,8 @@ fn each_ancestor(list: &mut AncestorList,
// If this trips, more likely the problem is 'blk' failed inside.
let tmp_arc = option::swap_unwrap(&mut *parent_group);
let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) };
*parent_group = move Some(move tmp_arc);
move result
*parent_group = Some(tmp_arc);
result
}
}
}
@ -337,15 +337,15 @@ struct TCB {
fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
is_main: bool, notifier: Option<AutoNotify>) -> TCB {
let notifier = move notifier;
let notifier = notifier;
notifier.iter(|x| { x.failed = false; });
TCB {
me: me,
tasks: move tasks,
ancestors: move ancestors,
tasks: tasks,
ancestors: ancestors,
is_main: is_main,
notifier: move notifier
notifier: notifier
}
}
@ -360,7 +360,7 @@ struct AutoNotify {
fn AutoNotify(chan: Chan<TaskResult>) -> AutoNotify {
AutoNotify {
notify_chan: move chan,
notify_chan: chan,
failed: true // Un-set above when taskgroup successfully made.
}
}
@ -370,10 +370,10 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
let newstate = util::replace(&mut *state, None);
// If 'None', the group was failing. Can't enlist.
if newstate.is_some() {
let group = option::unwrap(move newstate);
let group = option::unwrap(newstate);
taskset_insert(if is_member { &mut group.members }
else { &mut group.descendants }, me);
*state = Some(move group);
*state = Some(group);
true
} else {
false
@ -386,10 +386,10 @@ fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
let newstate = util::replace(&mut *state, None);
// If 'None', already failing and we've already gotten a kill signal.
if newstate.is_some() {
let group = option::unwrap(move newstate);
let group = option::unwrap(newstate);
taskset_remove(if is_member { &mut group.members }
else { &mut group.descendants }, me);
*state = Some(move group);
*state = Some(group);
}
}
@ -410,7 +410,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
// That's ok; only one task needs to do the dirty work. (Might also
// see 'None' if Somebody already failed and we got a kill signal.)
if newstate.is_some() {
let group = option::unwrap(move newstate);
let group = option::unwrap(newstate);
for taskset_each(&group.members) |sibling| {
// Skip self - killing ourself won't do much good.
if sibling != me {
@ -457,7 +457,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
}));
// Main task/group has no ancestors, no notifier, etc.
let group =
@TCB(spawner, move tasks, AncestorList(None), true, None);
@TCB(spawner, tasks, AncestorList(None), true, None);
local_set(spawner, taskgroup_key!(), group);
group
}
@ -472,7 +472,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
// Child's ancestors are spawner's ancestors.
let a = share_ancestors(&mut spawner_group.ancestors);
// Propagate main-ness.
(move g, move a, spawner_group.is_main)
(g, a, spawner_group.is_main)
} else {
// Child is in a separate group from spawner.
let g = private::exclusive(Some(TaskGroupData {
@ -504,7 +504,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
// Child has no ancestors.
AncestorList(None)
};
(move g, move a, false)
(g, a, false)
};
}
@ -515,10 +515,10 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
// None { ancestor_list(None) }
let tmp = util::replace(&mut **ancestors, None);
if tmp.is_some() {
let ancestor_arc = option::unwrap(move tmp);
let ancestor_arc = option::unwrap(tmp);
let result = ancestor_arc.clone();
**ancestors = move Some(move ancestor_arc);
AncestorList(Some(move result))
**ancestors = Some(ancestor_arc);
AncestorList(Some(result))
} else {
AncestorList(None)
}
@ -530,7 +530,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
gen_child_taskgroup(opts.linked, opts.supervised);
unsafe {
let child_data = ~mut Some((move child_tg, move ancestors, move f));
let child_data = ~mut Some((child_tg, ancestors, f));
// Being killed with the unsafe task/closure pointers would leak them.
do unkillable {
// Agh. Get move-mode items into the closure. FIXME (#2829)
@ -548,8 +548,8 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
Some(option::swap_unwrap(&mut opts.notify_chan))
};
let child_wrapper = make_child_wrapper(new_task, move child_tg,
move ancestors, is_main, move notify_chan, move f);
let child_wrapper = make_child_wrapper(new_task, child_tg,
ancestors, is_main, notify_chan, f);
let closure = cast::transmute(&child_wrapper);
@ -557,7 +557,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
// closure. (Reordering them wouldn't help - then getting killed
// between them would leak.)
rt::start_task(new_task, closure);
cast::forget(move child_wrapper);
cast::forget(child_wrapper);
}
}
@ -571,8 +571,8 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
ancestors: AncestorList, is_main: bool,
notify_chan: Option<Chan<TaskResult>>,
f: fn~()) -> fn~() {
let child_data = ~mut Some((move child_arc, move ancestors));
return fn~(move notify_chan, move child_data, move f) {
let child_data = ~mut Some((child_arc, ancestors));
return fn~() {
// Agh. Get move-mode items into the closure. FIXME (#2829)
let mut (child_arc, ancestors) = option::swap_unwrap(child_data);
// Child task runs this code.
@ -584,14 +584,14 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
let notifier = match notify_chan {
Some(ref notify_chan_value) => {
let moved_ncv = move_it!(*notify_chan_value);
Some(AutoNotify(move moved_ncv))
Some(AutoNotify(moved_ncv))
}
_ => None
};
if enlist_many(child, &child_arc, &mut ancestors) {
let group = @TCB(child, move child_arc, move ancestors,
is_main, move notifier);
let group = @TCB(child, child_arc, ancestors,
is_main, notifier);
unsafe {
local_set(child, taskgroup_key!(), group);
}
@ -694,7 +694,7 @@ fn test_spawn_raw_unsupervise() {
notify_chan: None,
.. default_task_opts()
};
do spawn_raw(move opts) {
do spawn_raw(opts) {
fail!();
}
}
@ -708,7 +708,7 @@ fn test_spawn_raw_notify_success() {
notify_chan: Some(notify_ch),
.. default_task_opts()
};
do spawn_raw(move opts) {
do spawn_raw(opts) {
}
assert notify_po.recv() == Success;
}
@ -724,7 +724,7 @@ fn test_spawn_raw_notify_failure() {
notify_chan: Some(notify_ch),
.. default_task_opts()
};
do spawn_raw(move opts) {
do spawn_raw(opts) {
fail!();
}
assert notify_po.recv() == Failure;

View File

@ -87,7 +87,7 @@ impl<A: ToStr> ToStr for ~[A] {
}
}
str::push_char(&mut acc, ']');
move acc
acc
}
}
}

View File

@ -19,7 +19,7 @@ use prelude::*;
/// The identity function.
#[inline(always)]
pub pure fn id<T>(x: T) -> T { move x }
pub pure fn id<T>(x: T) -> T { x }
/// Ignores a value.
#[inline(always)]
@ -37,10 +37,10 @@ pub fn with<T: Copy, R>(
// we wouldn't need to copy...
let old_value = *ptr;
*ptr = move new_value;
*ptr = new_value;
let result = op();
*ptr = move old_value;
return move result;
*ptr = old_value;
return result;
}
/**
@ -58,9 +58,9 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
*/
#[inline(always)]
pub fn replace<T>(dest: &mut T, src: T) -> T {
let mut tmp = move src;
let mut tmp = src;
swap(dest, &mut tmp);
move tmp
tmp
}
/// A non-copyable dummy type.
@ -109,7 +109,7 @@ mod tests {
let x = ~[(5, false)];
//FIXME #3387 assert x.eq(id(copy x));
let y = copy x;
assert x.eq(&id(move y));
assert x.eq(&id(y));
}
#[test]
pub fn test_swap() {

View File

@ -614,7 +614,7 @@ unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
(**repr).unboxed.fill += sys::nonzero_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);
}
#[inline(never)]

View File

@ -156,7 +156,7 @@ pub mod jit {
code: entry,
env: ptr::null()
};
let func: fn(++argv: ~[~str]) = cast::transmute(move closure);
let func: fn(++argv: ~[~str]) = cast::transmute(closure);
func(~[/*bad*/copy sess.opts.binary]);
}
@ -559,11 +559,11 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
let {name: opt_name, vers: opt_vers,
cmh_items: cmh_items} = provided_link_metas(sess, c);
let name = crate_meta_name(sess, output, move opt_name);
let vers = crate_meta_vers(sess, move opt_vers);
let name = crate_meta_name(sess, output, opt_name);
let vers = crate_meta_vers(sess, opt_vers);
let dep_hashes = cstore::get_dep_hashes(sess.cstore);
let extras_hash =
crate_meta_extras_hash(symbol_hasher, move cmh_items,
crate_meta_extras_hash(symbol_hasher, cmh_items,
dep_hashes);
return {name: name, vers: vers, extras_hash: extras_hash};

View File

@ -172,7 +172,7 @@ pub fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T {
let end = std::time::precise_time_s();
io::stdout().write_str(fmt!("time: %3.3f s\t%s\n",
end - start, what));
move rv
rv
}
pub enum compile_upto {
@ -257,7 +257,7 @@ pub fn compile_upto(sess: Session, cfg: ast::crate_cfg,
let (llmod, link_meta) = {
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
region_map, rp_set, move lang_items, crate);
region_map, rp_set, lang_items, crate);
let (method_map, vtable_map) =
time(time_passes, ~"typechecking", ||

View File

@ -1481,7 +1481,7 @@ pub fn struct_element_types(struct_ty: TypeRef) -> ~[TypeRef] {
llvm::LLVMGetStructElementTypes(
struct_ty, ptr::to_mut_unsafe_ptr(&mut buf[0]));
}
return move buf;
return buf;
}
}

View File

@ -752,10 +752,10 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
def_id: did
};
vec::push(&mut result, move provided_trait_method_info);
vec::push(&mut result, provided_trait_method_info);
}
return move result;
return result;
}
/// Returns the supertraits of the given trait.
@ -766,7 +766,7 @@ pub fn get_supertraits(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
for reader::tagged_docs(item_doc, tag_impl_trait) |trait_doc| {
results.push(doc_type(trait_doc, tcx, cdata));
}
return dvec::unwrap(move results);
return dvec::unwrap(results);
}
// If the item in question is a trait, returns its set of methods and
@ -847,7 +847,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
}
}
return Some(dvec::unwrap(move static_impl_methods));
return Some(dvec::unwrap(static_impl_methods));
}
pub fn get_item_attrs(cdata: cmd,

View File

@ -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,

View File

@ -228,7 +228,7 @@ fn get_metadata_section(os: os,
csz - vlen);
do vec::raw::buf_as_slice(cvbuf1, csz-vlen) |bytes| {
let inflated = flate::inflate_bytes(bytes);
found = move Some(@(move inflated));
found = Some(@(inflated));
}
if found != None {
return found;

View File

@ -1140,7 +1140,7 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
let ids = val_dsr.read_to_vec(|| {
xcx.tr_id(val_dsr.read_int())
});
let dvec = @dvec::from_vec(move ids);
let dvec = @dvec::from_vec(ids);
dcx.maps.last_use_map.insert(id, dvec);
} else if tag == (c::tag_table_method_map as uint) {
dcx.maps.method_map.insert(

View File

@ -632,7 +632,7 @@ fn check_loans_in_fn(fk: visit::fn_kind,
_ => {} // Ignore this argument.
}
}
*self.fn_args = @move fn_args;
*self.fn_args = @fn_args;
}
}

View File

@ -376,8 +376,8 @@ impl GatherLoanCtxt {
Some(_) => {
match loan::loan(self.bccx, cmt, scope_r, loan_kind) {
Err(ref e) => { self.bccx.report((*e)); }
Ok(move loans) => {
self.add_loans(cmt, loan_kind, scope_r, move loans);
Ok(loans) => {
self.add_loans(cmt, loan_kind, scope_r, loans);
}
}
}
@ -540,7 +540,7 @@ impl GatherLoanCtxt {
}
};
self.add_loans_to_scope_id(scope_id, move loans);
self.add_loans_to_scope_id(scope_id, loans);
if loan_kind.is_freeze() && !cmt.mutbl.is_immutable() {
self.bccx.stats.loaned_paths_imm += 1;
@ -566,7 +566,7 @@ impl GatherLoanCtxt {
req_loans.push_all(loans);
}
None => {
let dvec = @dvec::from_vec(move loans);
let dvec = @dvec::from_vec(loans);
let req_loan_map = self.req_maps.req_loan_map;
req_loan_map.insert(scope_id, dvec);
}

View File

@ -420,7 +420,7 @@ pub fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T,
let old_save_and_restore_t = *save_and_restore_t;
let u = f();
*save_and_restore_t = old_save_and_restore_t;
move u
u
}
pub fn save_and_restore_managed<T:Copy,U>(save_and_restore_t: @mut T,
@ -428,7 +428,7 @@ pub fn save_and_restore_managed<T:Copy,U>(save_and_restore_t: @mut T,
let old_save_and_restore_t = *save_and_restore_t;
let u = f();
*save_and_restore_t = old_save_and_restore_t;
move u
u
}
impl LoanKind {

View File

@ -1520,7 +1520,7 @@ impl Liveness {
self.cont_ln.insert(loop_node_id, cont_ln);
let r = f();
self.loop_scope.pop();
move r
r
}
}

View File

@ -797,7 +797,7 @@ pub fn Resolver(session: Session,
intr: session.intr()
};
move self
self
}
/// The main resolver class.
@ -3255,7 +3255,7 @@ pub impl Resolver {
self.add_exports_for_module(&mut exports2, module_);
match copy module_.def_id {
Some(def_id) => {
self.export_map2.insert(def_id.node, move exports2);
self.export_map2.insert(def_id.node, exports2);
debug!("(computing exports) writing exports for %d (some)",
def_id.node);
}

View File

@ -559,7 +559,7 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
Some(fp) => reordered_patterns.push(fp.pat)
}
}
Some(dvec::unwrap(move reordered_patterns))
Some(dvec::unwrap(reordered_patterns))
} else {
None
}
@ -815,7 +815,7 @@ pub fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] {
_ => {}
}
}
return dvec::unwrap(move found);
return dvec::unwrap(found);
}
pub fn extract_variant_args(bcx: block,
@ -1657,7 +1657,7 @@ pub fn trans_match_inner(scope_cx: block,
arm_cxs.push(bcx);
}
bcx = controlflow::join_blocks(scope_cx, dvec::unwrap(move arm_cxs));
bcx = controlflow::join_blocks(scope_cx, dvec::unwrap(arm_cxs));
return bcx;
fn mk_fail(bcx: block, sp: span, +msg: ~str,

View File

@ -1174,7 +1174,7 @@ pub fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
});
let bcx = mk_block(llbb,
parent,
move kind,
kind,
is_lpad,
opt_node_info,
cx);

View File

@ -274,11 +274,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
if words > 4 {
all_mem(cls);
let cls = cls;
return move cls;
return cls;
}
classify(ty, cls, 0, 0);
fixup(ty, cls);
return move cls;
return cls;
}
fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef {

View File

@ -593,7 +593,7 @@ pub fn block_(llbb: BasicBlockRef, parent: Option<block>, -kind: block_kind,
terminated: false,
unreachable: false,
parent: parent,
kind: move kind,
kind: kind,
is_lpad: is_lpad,
node_info: node_info,
fcx: fcx
@ -607,7 +607,7 @@ pub enum block = @block_;
pub fn mk_block(llbb: BasicBlockRef, parent: Option<block>, -kind: block_kind,
is_lpad: bool, node_info: Option<node_info>, fcx: fn_ctxt)
-> block {
block(@block_(llbb, parent, move kind, is_lpad, node_info, fcx))
block(@block_(llbb, parent, kind, is_lpad, node_info, fcx))
}
// First two args are retptr, env

View File

@ -152,7 +152,7 @@ enum debug_metadata {
fn cast_safely<T: Copy, U>(val: T) -> U {
unsafe {
let val2 = val;
return cast::transmute(move val2);
return cast::transmute(val2);
}
}

View File

@ -320,7 +320,7 @@ pub pure fn get(t: t) -> t_box {
unsafe {
let t2 = cast::reinterpret_cast::<t, t_box>(&t);
let t3 = t2;
cast::forget(move t2);
cast::forget(t2);
t3
}
}
@ -830,7 +830,7 @@ pub fn mk_ctxt(s: session::Session,
inferred_modes: HashMap(),
adjustments: HashMap(),
normalized_cache: new_ty_hash(),
lang_items: move lang_items,
lang_items: lang_items,
legacy_boxed_traits: HashMap(),
provided_methods: HashMap(),
provided_method_sources: HashMap(),
@ -909,10 +909,10 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
}
}
let t = @{sty: move st, id: cx.next_id, flags: flags, o_def_id: o_def_id};
let t = @{sty: st, id: cx.next_id, flags: flags, o_def_id: o_def_id};
let key = intern_key {sty: to_unsafe_ptr(&t.sty), o_def_id: o_def_id};
cx.interner.insert(move key, t);
cx.interner.insert(key, t);
cx.next_id += 1u;
unsafe { cast::reinterpret_cast(&t) }
@ -1178,7 +1178,7 @@ pub fn fold_sig(sig: &FnSig, fldop: fn(t) -> t) -> FnSig {
};
FnSig {
inputs: move args,
inputs: args,
output: fldop(sig.output)
}
}
@ -3110,7 +3110,7 @@ pub fn expr_kind(tcx: ctxt,
ast::def_local(*) |
ast::def_self(*) => LvalueExpr,
move def => {
def => {
tcx.sess.span_bug(expr.span, fmt!(
"Uncategorized def for expr %?: %?",
expr.id, def));
@ -3617,7 +3617,7 @@ pub fn trait_supertraits(cx: ctxt,
}
// Unwrap and return the result.
return @dvec::unwrap(move result);
return @dvec::unwrap(result);
}
pub fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {

View File

@ -139,7 +139,7 @@ pub fn lookup(
let mme = lcx.do_lookup(self_ty);
debug!("method lookup for %s yielded %?",
expr_repr(fcx.tcx(), expr), mme);
return move mme;
return mme;
}
pub struct LookupContext {
@ -204,26 +204,26 @@ pub impl LookupContext {
check::DontDerefArgs => {
match self.search_for_autoderefd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(mme); }
Some(mme) => { return Some(mme); }
None => {}
}
match self.search_for_autoptrd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(move mme); }
Some(mme) => { return Some(mme); }
None => {}
}
}
check::DoDerefArgs => {
match self.search_for_autoptrd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(move mme); }
Some(mme) => { return Some(mme); }
None => {}
}
match self.search_for_autoderefd_method(self_ty,
autoderefs) {
Some(move mme) => { return Some(mme); }
Some(mme) => { return Some(mme); }
None => {}
}
}
@ -457,7 +457,7 @@ pub impl LookupContext {
self.create_rcvr_ty_and_substs_for_method(
method.self_ty,
rcvr_ty,
move init_substs,
init_substs,
TransformTypeNormally);
let cand = Candidate {
@ -525,12 +525,12 @@ pub impl LookupContext {
let (rcvr_ty, rcvr_substs) =
self.create_rcvr_ty_and_substs_for_method(method.self_ty,
self_ty,
move rcvr_substs,
rcvr_substs,
TransformTypeForObject);
self.inherent_candidates.push(Candidate {
rcvr_ty: rcvr_ty,
rcvr_substs: move rcvr_substs,
rcvr_substs: rcvr_substs,
explicit_self: method.self_ty,
num_method_tps: method.tps.len(),
self_mode: get_mode_from_self_type(method.self_ty),
@ -585,7 +585,7 @@ pub impl LookupContext {
self.create_rcvr_ty_and_substs_for_method(
method_self_ty,
self_ty,
move rcvr_substs,
rcvr_substs,
TransformTypeNormally);
let origin = if trait_did == did {
method_self(trait_did, index)
@ -595,7 +595,7 @@ pub impl LookupContext {
};
self.inherent_candidates.push(Candidate {
rcvr_ty: rcvr_ty,
rcvr_substs: move rcvr_substs,
rcvr_substs: rcvr_substs,
explicit_self: method_self_ty,
num_method_tps: method_num_tps,
self_mode: get_mode_from_self_type(method_self_ty),
@ -648,12 +648,12 @@ pub impl LookupContext {
self.create_rcvr_ty_and_substs_for_method(
method.self_type,
impl_ty,
move impl_substs,
impl_substs,
TransformTypeNormally);
candidates.push(Candidate {
rcvr_ty: impl_ty,
rcvr_substs: move impl_substs,
rcvr_substs: impl_substs,
explicit_self: method.self_type,
num_method_tps: method.n_tps,
self_mode: get_mode_from_self_type(method.self_type),
@ -693,7 +693,7 @@ pub impl LookupContext {
candidates.push(Candidate {
rcvr_ty: impl_ty,
rcvr_substs: move impl_substs,
rcvr_substs: impl_substs,
explicit_self: provided_method_info.method_info.self_type,
num_method_tps: provided_method_info.method_info.n_tps,
self_mode: get_mode_from_self_type(
@ -722,10 +722,10 @@ pub impl LookupContext {
match self_decl {
sty_static | sty_value | sty_by_ref |
sty_box(_) | sty_uniq(_) => {
move self_substs
self_substs
}
sty_region(_) if self_substs.self_r.is_some() => {
move self_substs
self_substs
}
sty_region(_) => {
substs {
@ -761,7 +761,7 @@ pub impl LookupContext {
self.consider_reborrow(self_ty, autoderefs);
match self.search_for_method(self_ty) {
None => None,
Some(move mme) => {
Some(mme) => {
debug!("(searching for autoderef'd method) writing \
adjustment (%u) to %d",
autoderefs,
@ -945,7 +945,7 @@ pub impl LookupContext {
let autoref_ty = mk_autoref_ty(*mutbl, region);
match self.search_for_method(autoref_ty) {
None => {}
Some(move mme) => {
Some(mme) => {
self.fcx.write_adjustment(
self.self_expr.id,
@ty::AutoAdjustment {
@ -977,8 +977,8 @@ pub impl LookupContext {
debug!("searching inherent candidates");
match self.consider_candidates(self_ty, &self.inherent_candidates) {
None => {}
Some(move mme) => {
return Some(move mme);
Some(mme) => {
return Some(mme);
}
}
@ -987,8 +987,8 @@ pub impl LookupContext {
None => {
return None;
}
Some(move mme) => {
return Some(move mme);
Some(mme) => {
return Some(mme);
}
}
}

View File

@ -870,7 +870,7 @@ pub impl FnCtxt {
self.region_lb = lb;
let v = f();
self.region_lb = old_region_lb;
move v
v
}
fn region_var_if_parameterized(@mut self,

View File

@ -553,7 +553,7 @@ pub impl CoherenceChecker {
UniversalQuantificationResult {
monotype: monotype,
type_variables: move type_parameters,
type_variables: type_parameters,
bounds: polytype.bounds
}
}

View File

@ -320,7 +320,7 @@ pub fn ensure_supertraits(ccx: @mut CrateCtxt,
instantiated.push(InstantiatedTraitRef { def_id: did, tpt: tpt });
}
tcx.supertraits.insert(local_def(id),
@dvec::unwrap(move instantiated));
@dvec::unwrap(instantiated));
}
/**

View File

@ -121,9 +121,9 @@ pub struct CombineFields {
pub fn expected_found<C:Combine,T>(
self: &C, +a: T, +b: T) -> ty::expected_found<T> {
if self.a_is_expected() {
ty::expected_found {expected: move a, found: move b}
ty::expected_found {expected: a, found: b}
} else {
ty::expected_found {expected: move b, found: move a}
ty::expected_found {expected: b, found: a}
}
}

View File

@ -186,7 +186,7 @@ pub impl Glb: Combine {
new_vars, a_isr, a_vars, b_vars,
r));
debug!("sig1 = %s", sig1.inf_str(self.infcx));
return Ok(move sig1);
return Ok(sig1);
fn generalize_region(self: &Glb,
snapshot: uint,

View File

@ -144,7 +144,7 @@ pub impl Lub: Combine {
&sig0,
|r, _in_fn| generalize_region(&self, snapshot, new_vars,
a_isr, r));
return Ok(move sig1);
return Ok(sig1);
fn generalize_region(self: &Lub,
snapshot: uint,

View File

@ -13,8 +13,8 @@
macro_rules! if_ok(
($inp: expr) => (
match $inp {
Ok(move v) => { move v }
Err(move e) => { return Err(e); }
Ok(v) => { v }
Err(e) => { return Err(e); }
}
)
);

View File

@ -599,7 +599,7 @@ impl @mut InferCtxt {
self.ty_var_bindings.bindings.truncate(0);
self.int_var_bindings.bindings.truncate(0);
self.region_vars.commit();
move r
r
}
}
@ -613,7 +613,7 @@ impl @mut InferCtxt {
Ok(_) => (),
Err(_) => self.rollback_to(&snapshot)
}
move r
r
}
}
@ -624,7 +624,7 @@ impl @mut InferCtxt {
let snapshot = self.start_snapshot();
let r = self.try(f);
self.rollback_to(&snapshot);
move r
r
}
}
}

View File

@ -899,7 +899,7 @@ pub impl RegionVarBindings {
// replace the NoValue entry with ErrorValue.
let mut values = self.values.take();
values[*rid] = ErrorValue;
self.values.put_back(move values);
self.values.put_back(values);
re_static
}
@ -999,9 +999,9 @@ pub impl RegionVarBindings {
None => {}
Some((ref r1, ref r2)) => {
result_set =
consider_adding_edge(move result_set, &r, r1, r2);
consider_adding_edge(result_set, &r, r1, r2);
result_set =
consider_adding_edge(move result_set, &r, r2, r1);
consider_adding_edge(result_set, &r, r2, r1);
}
}
@ -1018,13 +1018,13 @@ pub impl RegionVarBindings {
r1: &Region,
r2: &Region) -> ~[Region]
{
let mut result_set = move result_set;
let mut result_set = result_set;
if *r == *r1 { // Clearly, this is potentially inefficient.
if !result_set.contains(r2) {
result_set.push(*r2);
}
}
return move result_set;
return result_set;
}
}
@ -1254,8 +1254,8 @@ impl RegionVarBindings {
}
let mut graph = Graph {
nodes: move nodes,
edges: move edges
nodes: nodes,
edges: edges
};
for uint::range(0, num_edges) |edge_idx| {
@ -1273,7 +1273,7 @@ impl RegionVarBindings {
}
}
return (move graph);
return (graph);
fn insert_edge(+graph: &mut Graph,
node_id: RegionVid,

View File

@ -69,7 +69,7 @@ fn setup_env(test_name: &str, source_string: &str) -> Env {
cfg, parse_sess);
let tcx = ty::mk_ctxt(sess, dm, amap, freevars, region_map,
region_paramd_items, move lang_items, crate);
region_paramd_items, lang_items, crate);
let infcx = infer::new_infer_ctxt(tcx);
@ -192,7 +192,7 @@ impl Env {
onceness: ast::Many,
region: ty::re_static,
bounds: @~[]},
sig: FnSig {inputs: move inputs,
sig: FnSig {inputs: inputs,
output: output_ty}
})
}

View File

@ -326,7 +326,7 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) {
let (p, ch) = stream();
let ch = SharedChan(ch);
let ch_capture = ch.clone();
match do task::try |move f| {
match do task::try || {
let ch = ch_capture.clone();
let ch_capture = ch.clone();
// The 'diagnostics emitter'. Every error, warning, etc. should
@ -375,7 +375,7 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) {
pub fn main() {
let args = os::args();
do monitor |move args, demitter| {
do monitor |demitter| {
run_compiler(&args, demitter);
}
}

View File

@ -27,7 +27,7 @@ pub fn indent<R>(op: fn() -> R) -> R {
debug!(">>");
let r = op();
debug!("<< (Result = %?)", r);
move r
r
}
pub struct _indenter {

View File

@ -91,7 +91,7 @@ fn run<T>(owner: SrvOwner<T>, source: ~str, parse: Parser) -> T {
let res = owner(srv_.clone());
srv_.ch.send(Exit);
move res
res
}
fn act(po: &Port<Msg>, source: ~str, parse: Parser) {
@ -120,10 +120,10 @@ pub fn exec<T:Owned>(
f: fn~(ctxt: Ctxt) -> T
) -> T {
let (po, ch) = stream();
let msg = HandleRequest(fn~(move f, ctxt: Ctxt) {
let msg = HandleRequest(fn~(ctxt: Ctxt) {
ch.send(f(ctxt))
});
srv.ch.send(move msg);
srv.ch.send(msg);
po.recv()
}

View File

@ -115,7 +115,7 @@ fn parse_item_attrs<T:Owned>(
srv: astsrv::Srv,
id: doc::AstId,
parse_attrs: fn~(a: ~[ast::attribute]) -> T) -> T {
do astsrv::exec(srv) |move parse_attrs, ctxt| {
do astsrv::exec(srv) |ctxt| {
let attrs = match ctxt.ast_map.get(&id) {
ast_map::node_item(item, _) => copy item.attrs,
ast_map::node_foreign_item(item, _, _) => copy item.attrs,

View File

@ -133,7 +133,7 @@ pub fn parse_config_(
result::Ok(matches) => {
if matches.free.len() == 1 {
let input_crate = Path(vec::head(matches.free));
config_from_opts(&input_crate, &matches, move program_output)
config_from_opts(&input_crate, &matches, program_output)
} else if matches.free.is_empty() {
result::Err(~"no crates specified")
} else {
@ -191,11 +191,11 @@ fn config_from_opts(
}
}
};
let program_output = Cell(move program_output);
let program_output = Cell(program_output);
let result = do result::chain(result) |config| {
let pandoc_cmd = getopts::opt_maybe_str(matches, opt_pandoc_cmd());
let pandoc_cmd = maybe_find_pandoc(
&config, pandoc_cmd, move program_output.take());
&config, pandoc_cmd, program_output.take());
do result::chain(pandoc_cmd) |pandoc_cmd| {
result::Ok(Config {
pandoc_cmd: pandoc_cmd,
@ -268,7 +268,7 @@ fn should_find_pandoc() {
status: 0, out: ~"pandoc 1.8.2.1", err: ~""
}
};
let result = maybe_find_pandoc(&config, None, move mock_program_output);
let result = maybe_find_pandoc(&config, None, mock_program_output);
assert result == result::Ok(Some(~"pandoc"));
}
@ -284,7 +284,7 @@ fn should_error_with_no_pandoc() {
status: 1, out: ~"", err: ~""
}
};
let result = maybe_find_pandoc(&config, None, move mock_program_output);
let result = maybe_find_pandoc(&config, None, mock_program_output);
assert result == result::Err(~"couldn't find pandoc");
}

View File

@ -87,25 +87,25 @@ fn mk_fold<T>(
fold_struct: FoldStruct<T>
) -> Fold<T> {
Fold {
ctxt: move ctxt,
fold_doc: move fold_doc,
fold_crate: move fold_crate,
fold_item: move fold_item,
fold_mod: move fold_mod,
fold_nmod: move fold_nmod,
fold_fn: move fold_fn,
fold_const: move fold_const,
fold_enum: move fold_enum,
fold_trait: move fold_trait,
fold_impl: move fold_impl,
fold_type: move fold_type,
fold_struct: move fold_struct
ctxt: ctxt,
fold_doc: fold_doc,
fold_crate: fold_crate,
fold_item: fold_item,
fold_mod: fold_mod,
fold_nmod: fold_nmod,
fold_fn: fold_fn,
fold_const: fold_const,
fold_enum: fold_enum,
fold_trait: fold_trait,
fold_impl: fold_impl,
fold_type: fold_type,
fold_struct: fold_struct
}
}
pub fn default_any_fold<T: Clone>(ctxt: T) -> Fold<T> {
mk_fold(
move ctxt,
ctxt,
|f, d| default_seq_fold_doc(f, d),
|f, d| default_seq_fold_crate(f, d),
|f, d| default_seq_fold_item(f, d),
@ -123,7 +123,7 @@ pub fn default_any_fold<T: Clone>(ctxt: T) -> Fold<T> {
pub fn default_seq_fold<T: Clone>(ctxt: T) -> Fold<T> {
mk_fold(
move ctxt,
ctxt,
|f, d| default_seq_fold_doc(f, d),
|f, d| default_seq_fold_crate(f, d),
|f, d| default_seq_fold_item(f, d),
@ -141,7 +141,7 @@ pub fn default_seq_fold<T: Clone>(ctxt: T) -> Fold<T> {
pub fn default_par_fold<T: Clone>(ctxt: T) -> Fold<T> {
mk_fold(
move ctxt,
ctxt,
|f, d| default_seq_fold_doc(f, d),
|f, d| default_seq_fold_crate(f, d),
|f, d| default_seq_fold_item(f, d),

View File

@ -74,7 +74,7 @@ fn run(
~"mods last", mods_last
).f)(srv, copy doc);
write_markdown(sorted_doc, move writer_factory);
write_markdown(sorted_doc, writer_factory);
return doc;
}
@ -148,7 +148,7 @@ fn should_request_new_writer_for_each_page() {
let (srv, doc) = test::create_doc_srv(~"mod a { }");
// Split the document up into pages
let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc);
write_markdown(doc, move writer_factory);
write_markdown(doc, writer_factory);
// We expect two pages to have been written
for iter::repeat(2) {
po.recv();
@ -180,7 +180,7 @@ fn should_write_title_for_each_page() {
let (srv, doc) = test::create_doc_srv(
~"#[link(name = \"core\")]; mod a { }");
let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc);
write_markdown(doc, move writer_factory);
write_markdown(doc, writer_factory);
for iter::repeat(2) {
let (page, markdown) = po.recv();
match page {
@ -894,7 +894,7 @@ mod test {
doc: doc::Doc
) -> ~str {
let (writer_factory, po) = markdown_writer::future_writer_factory();
write_markdown(doc, move writer_factory);
write_markdown(doc, writer_factory);
return po.recv().second();
}
@ -903,7 +903,7 @@ mod test {
doc: doc::Doc
) -> ~str {
let (writer_factory, po) = markdown_writer::future_writer_factory();
let pass = mk_pass(move writer_factory);
let pass = mk_pass(writer_factory);
(pass.f)(srv, doc);
return po.recv().second();
}

View File

@ -129,12 +129,12 @@ fn pandoc_writer(
os::close(pipe_in.out);
let (stdout_po, stdout_ch) = pipes::stream();
do task::spawn_sched(task::SingleThreaded) |move stdout_ch| {
do task::spawn_sched(task::SingleThreaded) || {
stdout_ch.send(readclose(pipe_out.in));
}
let (stderr_po, stderr_ch) = pipes::stream();
do task::spawn_sched(task::SingleThreaded) |move stderr_ch| {
do task::spawn_sched(task::SingleThreaded) || {
stderr_ch.send(readclose(pipe_err.in));
}
let stdout = stdout_po.recv();
@ -169,7 +169,7 @@ fn readclose(fd: libc::c_int) -> ~str {
fn generic_writer(process: fn~(markdown: ~str)) -> Writer {
let (po, ch) = stream::<WriteInstr>();
do task::spawn |move process, move setup_ch| {
do task::spawn || {
let mut markdown = ~"";
let mut keep_going = true;
while keep_going {
@ -178,7 +178,7 @@ fn generic_writer(process: fn~(markdown: ~str)) -> Writer {
Done => keep_going = false
}
}
process(move markdown);
process(markdown);
};
fn~(instr: WriteInstr) {
ch.send(instr);
@ -298,24 +298,24 @@ pub fn future_writer_factory(
let writer_factory = fn~(page: doc::Page) -> Writer {
let (writer_po, writer_ch) = pipes::stream();
let markdown_ch = markdown_ch.clone();
do task::spawn |move writer_ch| {
do task::spawn || {
let (writer, future) = future_writer();
writer_ch.send(move writer);
writer_ch.send(writer);
let s = future.get();
markdown_ch.send((copy page, s));
}
writer_po.recv()
};
(move writer_factory, markdown_po)
(writer_factory, markdown_po)
}
fn future_writer() -> (Writer, future::Future<~str>) {
let (port, chan) = pipes::stream();
let writer = fn~(move chan, instr: WriteInstr) {
let writer = fn~(instr: WriteInstr) {
chan.send(copy instr);
};
let future = do future::from_fn |move port| {
let future = do future::from_fn || {
let mut res = ~"";
loop {
match port.recv() {
@ -325,5 +325,5 @@ fn future_writer() -> (Writer, future::Future<~str>) {
}
res
};
(move writer, move future)
(writer, future)
}

View File

@ -71,7 +71,7 @@ fn make_doc_from_pages(page_port: &PagePort) -> doc::Doc {
loop {
let val = page_port.recv();
if val.is_some() {
pages += ~[option::unwrap(move val)];
pages += ~[option::unwrap(val)];
} else {
break;
}

View File

@ -54,7 +54,7 @@ fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
fold_item: fold_item,
fold_mod: fold_mod,
fold_nmod: fold_nmod,
.. fold::default_any_fold(move ctxt)
.. fold::default_any_fold(ctxt)
};
(fold.fold_doc)(&fold, doc)
}

View File

@ -149,5 +149,5 @@ fn time<T>(what: ~str, f: fn() -> T) -> T {
let rv = f();
let end = std::time::precise_time_s();
info!("time: %3.3f s %s", end - start, what);
move rv
rv
}

View File

@ -42,7 +42,7 @@ fn run(
) -> doc::Doc {
let fold = Fold {
fold_mod: fold_mod,
.. fold::default_any_fold(move lteq)
.. fold::default_any_fold(lteq)
};
(fold.fold_doc)(&fold, doc)
}

View File

@ -42,14 +42,14 @@ fn run(
op: Op
) -> doc::Doc {
let op = NominalOp {
op: move op
op: op
};
let fold = Fold {
fold_item: fold_item,
fold_enum: fold_enum,
fold_trait: fold_trait,
fold_impl: fold_impl,
.. fold::default_any_fold(move op)
.. fold::default_any_fold(op)
};
(fold.fold_doc)(&fold, doc)
}

View File

@ -81,7 +81,7 @@ struct ARC<T> { x: SharedMutableState<T> }
/// Create an atomically reference counted wrapper.
pub fn ARC<T: Const Owned>(data: T) -> ARC<T> {
ARC { x: unsafe { shared_mutable_state(move data) } }
ARC { x: unsafe { shared_mutable_state(data) } }
}
/**
@ -113,8 +113,8 @@ pub fn clone<T: Const Owned>(rc: &ARC<T>) -> ARC<T> {
* guaranteed to deadlock.
*/
pub fn unwrap<T: Const Owned>(rc: ARC<T>) -> T {
let ARC { x: x } = move rc;
unsafe { unwrap_shared_mutable_state(move x) }
let ARC { x: x } = rc;
unsafe { unwrap_shared_mutable_state(x) }
}
impl<T: Const Owned> Clone for ARC<T> {
@ -134,7 +134,7 @@ struct MutexARC<T> { x: SharedMutableState<MutexARCInner<T>> }
/// Create a mutex-protected ARC with the supplied data.
pub fn MutexARC<T: Owned>(user_data: T) -> MutexARC<T> {
mutex_arc_with_condvars(move user_data, 1)
mutex_arc_with_condvars(user_data, 1)
}
/**
* Create a mutex-protected ARC with the supplied data and a specified number
@ -144,8 +144,8 @@ pub fn mutex_arc_with_condvars<T: Owned>(user_data: T,
num_condvars: uint) -> MutexARC<T> {
let data =
MutexARCInner { lock: mutex_with_condvars(num_condvars),
failed: false, data: move user_data };
MutexARC { x: unsafe { shared_mutable_state(move data) } }
failed: false, data: user_data };
MutexARC { x: unsafe { shared_mutable_state(data) } }
}
impl<T: Owned> Clone for MutexARC<T> {
@ -220,13 +220,13 @@ impl<T: Owned> &MutexARC<T> {
*/
// FIXME(#3724) make this a by-move method on the arc
pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T {
let MutexARC { x: x } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let MutexARCInner { failed: failed, data: data, _ } = move inner;
let MutexARC { x: x } = arc;
let inner = unsafe { unwrap_shared_mutable_state(x) };
let MutexARCInner { failed: failed, data: data, _ } = inner;
if failed {
fail!(~"Can't unwrap poisoned MutexARC - another task failed inside!")
}
move data
data
}
// Common code for {mutex.access,rwlock.write}{,_cond}.
@ -284,7 +284,7 @@ struct RWARC<T> {
/// Create a reader/writer ARC with the supplied data.
pub fn RWARC<T: Const Owned>(user_data: T) -> RWARC<T> {
rw_arc_with_condvars(move user_data, 1)
rw_arc_with_condvars(user_data, 1)
}
/**
* Create a reader/writer ARC with the supplied data and a specified number
@ -296,8 +296,8 @@ pub fn rw_arc_with_condvars<T: Const Owned>(
{
let data =
RWARCInner { lock: rwlock_with_condvars(num_condvars),
failed: false, data: move user_data };
RWARC { x: unsafe { shared_mutable_state(move data) }, cant_nest: () }
failed: false, data: user_data };
RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () }
}
impl<T: Const Owned> RWARC<T> {
@ -386,7 +386,7 @@ impl<T: Const Owned> &RWARC<T> {
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
check_poison(false, (*state).failed);
blk(RWWriteMode((&mut (*state).data,
move write_mode,
write_mode,
PoisonOnFail(&mut (*state).failed))))
}
}
@ -396,9 +396,9 @@ impl<T: Const Owned> &RWARC<T> {
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
// The rwlock should assert that the token belongs to us for us.
let state = unsafe { get_shared_immutable_state(&self.x) };
let RWWriteMode((data, t, _poison)) = move token;
let RWWriteMode((data, t, _poison)) = token;
// Let readers in
let new_token = (&state.lock).downgrade(move t);
let new_token = (&state.lock).downgrade(t);
// Whatever region the input reference had, it will be safe to use
// the same region for the output reference. (The only 'unsafe' part
// of this cast is removing the mutability.)
@ -406,7 +406,7 @@ impl<T: Const Owned> &RWARC<T> {
// Downgrade ensured the token belonged to us. Just a sanity check.
assert ptr::ref_eq(&state.data, new_data);
// Produce new token
RWReadMode((new_data, move new_token))
RWReadMode((new_data, new_token))
}
}
@ -419,13 +419,13 @@ impl<T: Const Owned> &RWARC<T> {
*/
// FIXME(#3724) make this a by-move method on the arc
pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T {
let RWARC { x: x, _ } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
let RWARCInner { failed: failed, data: data, _ } = move inner;
let RWARC { x: x, _ } = arc;
let inner = unsafe { unwrap_shared_mutable_state(x) };
let RWARCInner { failed: failed, data: data, _ } = inner;
if failed {
fail!(~"Can't unwrap poisoned RWARC - another task failed inside!")
}
move data
data
}
// Borrowck rightly complains about immutably aliasing the rwlock in order to
@ -509,7 +509,7 @@ mod tests {
let (p, c) = pipes::stream();
do task::spawn() |move c| {
do task::spawn() || {
let p = pipes::PortSet();
c.send(p.chan());
@ -532,8 +532,8 @@ mod tests {
let arc = ~MutexARC(false);
let arc2 = ~arc.clone();
let (p,c) = pipes::oneshot();
let (c,p) = (~mut Some(move c), ~mut Some(move p));
do task::spawn |move arc2, move p| {
let (c,p) = (~mut Some(c), ~mut Some(p));
do task::spawn || {
// wait until parent gets in
pipes::recv_one(option::swap_unwrap(p));
do arc2.access_cond |state, cond| {
@ -555,7 +555,7 @@ mod tests {
let arc2 = ~arc.clone();
let (p, c) = pipes::stream();
do task::spawn_unlinked |move arc2, move p| {
do task::spawn_unlinked || {
let _ = p.recv();
do arc2.access_cond |one, cond| {
cond.signal();
@ -574,7 +574,7 @@ mod tests {
pub fn test_mutex_arc_poison() {
let arc = ~MutexARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.access |one| {
assert *one == 2;
}
@ -588,21 +588,21 @@ mod tests {
let arc = MutexARC(1);
let arc2 = ~(&arc).clone();
let (p, c) = pipes::stream();
do task::spawn |move c, move arc2| {
do task::spawn || {
do arc2.access |one| {
c.send(());
assert *one == 2;
}
}
let _ = p.recv();
let one = unwrap_mutex_arc(move arc);
let one = unwrap_mutex_arc(arc);
assert one == 1;
}
#[test] #[should_fail] #[ignore(cfg(windows))]
pub fn test_rw_arc_poison_wr() {
let arc = ~RWARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.write |one| {
assert *one == 2;
}
@ -615,7 +615,7 @@ mod tests {
pub fn test_rw_arc_poison_ww() {
let arc = ~RWARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.write |one| {
assert *one == 2;
}
@ -628,7 +628,7 @@ mod tests {
pub fn test_rw_arc_poison_dw() {
let arc = ~RWARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.write_downgrade |write_mode| {
do (&write_mode).write |one| {
assert *one == 2;
@ -643,7 +643,7 @@ mod tests {
pub fn test_rw_arc_no_poison_rr() {
let arc = ~RWARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.read |one| {
assert *one == 2;
}
@ -656,7 +656,7 @@ mod tests {
pub fn test_rw_arc_no_poison_rw() {
let arc = ~RWARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.read |one| {
assert *one == 2;
}
@ -669,9 +669,9 @@ mod tests {
pub fn test_rw_arc_no_poison_dr() {
let arc = ~RWARC(1);
let arc2 = ~arc.clone();
do task::try |move arc2| {
do task::try || {
do arc2.write_downgrade |write_mode| {
let read_mode = arc2.downgrade(move write_mode);
let read_mode = arc2.downgrade(write_mode);
do (&read_mode).read |one| {
assert *one == 2;
}
@ -687,7 +687,7 @@ mod tests {
let arc2 = ~arc.clone();
let (p,c) = pipes::stream();
do task::spawn |move arc2, move c| {
do task::spawn || {
do arc2.write |num| {
for 10.times {
let tmp = *num;
@ -703,8 +703,8 @@ mod tests {
let mut children = ~[];
for 5.times {
let arc3 = ~arc.clone();
do task::task().future_result(|+r| children.push(move r)).spawn
|move arc3| {
do task::task().future_result(|+r| children.push(r)).spawn
|| {
do arc3.read |num| {
assert *num >= 0;
}
@ -732,9 +732,9 @@ mod tests {
let mut reader_convos = ~[];
for 10.times {
let ((rp1,rc1),(rp2,rc2)) = (pipes::stream(),pipes::stream());
reader_convos.push((move rc1, move rp2));
reader_convos.push((rc1, rp2));
let arcn = ~arc.clone();
do task::spawn |move rp1, move rc2, move arcn| {
do task::spawn || {
rp1.recv(); // wait for downgrader to give go-ahead
do arcn.read |state| {
assert *state == 31337;
@ -746,7 +746,7 @@ mod tests {
// Writer task
let arc2 = ~arc.clone();
let ((wp1,wc1),(wp2,wc2)) = (pipes::stream(),pipes::stream());
do task::spawn |move arc2, move wc2, move wp1| {
do task::spawn || {
wp1.recv();
do arc2.write_cond |state, cond| {
assert *state == 0;
@ -779,7 +779,7 @@ mod tests {
}
}
}
let read_mode = arc.downgrade(move write_mode);
let read_mode = arc.downgrade(write_mode);
do (&read_mode).read |state| {
// complete handshake with other readers
for vec::each(reader_convos) |x| {

View File

@ -108,7 +108,7 @@ struct BigBitv {
}
fn BigBitv(storage: ~[uint]) -> BigBitv {
BigBitv {storage: move storage}
BigBitv {storage: storage}
}
/**
@ -232,9 +232,9 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv {
if nbits % uint_bits == 0 {0} else {1};
let elem = if init {!0} else {0};
let s = from_elem(nelems, elem);
Big(~BigBitv(move s))
Big(~BigBitv(s))
};
Bitv {rep: move rep, nbits: nbits}
Bitv {rep: rep, nbits: nbits}
}
priv impl Bitv {
@ -519,7 +519,7 @@ impl Clone for Bitv {
let mut st = from_elem(self.nbits / uint_bits + 1, 0);
let len = st.len();
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: move st})}
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: st})}
}
}
}
@ -555,7 +555,7 @@ pub fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv {
for uint::range(0, len) |i| {
bitv.set(i, f(i));
}
move bitv
bitv
}
const uint_bits: uint = 32u + (1u << 32u >> 27u);

View File

@ -21,7 +21,7 @@ pub struct Cell<T> {
/// Creates a new full cell with the given value.
pub fn Cell<T>(value: T) -> Cell<T> {
Cell { value: Some(move value) }
Cell { value: Some(value) }
}
pub pure fn empty_cell<T>() -> Cell<T> {
@ -37,7 +37,7 @@ impl<T> Cell<T> {
let mut value = None;
value <-> self.value;
return option::unwrap(move value);
return option::unwrap(value);
}
/// Returns the value, failing if the cell is full.
@ -45,7 +45,7 @@ impl<T> Cell<T> {
if !self.is_empty() {
fail!(~"attempt to put a value back into a full cell");
}
self.value = Some(move value);
self.value = Some(value);
}
/// Returns true if the cell is empty and false if the cell is full.
@ -57,8 +57,8 @@ impl<T> Cell<T> {
fn with_ref<R>(op: fn(v: &T) -> R) -> R {
let v = self.take();
let r = op(&v);
self.put_back(move v);
move r
self.put_back(v);
r
}
}
@ -69,7 +69,7 @@ fn test_basic() {
let value = value_cell.take();
assert value == ~10;
assert value_cell.is_empty();
value_cell.put_back(move value);
value_cell.put_back(value);
assert !value_cell.is_empty();
}

View File

@ -27,13 +27,13 @@ pub struct DuplexStream<T, U> {
impl<T: Owned, U: Owned> GenericChan<T> for DuplexStream<T, U> {
fn send(x: T) {
self.chan.send(move x)
self.chan.send(x)
}
}
impl<T: Owned, U: Owned> GenericSmartChan<T> for DuplexStream<T, U> {
fn try_send(x: T) -> bool {
self.chan.try_send(move x)
self.chan.try_send(x)
}
}
@ -66,12 +66,12 @@ pub fn DuplexStream<T: Owned, U: Owned>()
let (p1, c2) = pipes::stream();
let (p2, c1) = pipes::stream();
(DuplexStream {
chan: move c1,
port: move p1
chan: c1,
port: p1
},
DuplexStream {
chan: move c2,
port: move p2
chan: c2,
port: p2
})
}

View File

@ -41,7 +41,7 @@ pub fn create<T: Copy>() -> Deque<T> {
*/
fn grow<T: Copy>(nelts: uint, lo: uint, elts: ~[Cell<T>])
-> ~[Cell<T>] {
let mut elts = move elts;
let mut elts = elts;
assert (nelts == vec::len(elts));
let mut rv = ~[];
@ -54,10 +54,10 @@ pub fn create<T: Copy>() -> Deque<T> {
i += 1u;
}
move rv
rv
}
fn get<T: Copy>(elts: &DVec<Cell<T>>, i: uint) -> T {
match (*elts).get_elt(i) { Some(move t) => t, _ => fail!() }
match (*elts).get_elt(i) { Some(t) => t, _ => fail!() }
}
struct Repr<T> {
@ -75,7 +75,7 @@ pub fn create<T: Copy>() -> Deque<T> {
self.lo = self.elts.len() - 1u;
} else { self.lo -= 1u; }
if self.lo == self.hi {
self.elts.swap(|v| grow(self.nelts, oldlo, move v));
self.elts.swap(|v| grow(self.nelts, oldlo, v));
self.lo = self.elts.len() - 1u;
self.hi = self.nelts;
}
@ -84,7 +84,7 @@ pub fn create<T: Copy>() -> Deque<T> {
}
fn add_back(t: T) {
if self.lo == self.hi && self.nelts != 0u {
self.elts.swap(|v| grow(self.nelts, self.lo, move v));
self.elts.swap(|v| grow(self.nelts, self.lo, v));
self.lo = 0u;
self.hi = self.nelts;
}

View File

@ -259,7 +259,7 @@ pub mod reader {
r_doc
}
fn push_doc<T>(d: Doc, f: fn() -> T) -> T{
fn push_doc<T>(d: Doc, f: fn() -> T) -> T {
let old_parent = self.parent;
let old_pos = self.pos;
self.parent = d;
@ -267,7 +267,7 @@ pub mod reader {
let r = f();
self.parent = old_parent;
self.pos = old_pos;
move r
r
}
fn _next_uint(exp_tag: EbmlEncoderTag) -> uint {

View File

@ -28,7 +28,7 @@ This example sends boxed integers across tasks using serialization.
~~~
let (port, chan) = serial::pipe_stream();
do task::spawn |move chan| {
do task::spawn || {
for int::range(0, 10) |i| {
chan.send(@i)
}
@ -114,8 +114,8 @@ pub mod serial {
let unflat: DeserializingUnflattener<DefaultDecoder, T> =
DeserializingUnflattener::new(
deserialize_buffer::<DefaultDecoder, T>);
let byte_port = ReaderBytePort::new(move reader);
FlatPort::new(move unflat, move byte_port)
let byte_port = ReaderBytePort::new(reader);
FlatPort::new(unflat, byte_port)
}
/// Create a `FlatChan` from a `Writer`
@ -124,8 +124,8 @@ pub mod serial {
let flat: SerializingFlattener<DefaultEncoder, T> =
SerializingFlattener::new(
serialize_value::<DefaultEncoder, T>);
let byte_chan = WriterByteChan::new(move writer);
FlatChan::new(move flat, move byte_chan)
let byte_chan = WriterByteChan::new(writer);
FlatChan::new(flat, byte_chan)
}
/// Create a `FlatPort` from a `Port<~[u8]>`
@ -135,8 +135,8 @@ pub mod serial {
let unflat: DeserializingUnflattener<DefaultDecoder, T> =
DeserializingUnflattener::new(
deserialize_buffer::<DefaultDecoder, T>);
let byte_port = PipeBytePort::new(move port);
FlatPort::new(move unflat, move byte_port)
let byte_port = PipeBytePort::new(port);
FlatPort::new(unflat, byte_port)
}
/// Create a `FlatChan` from a `Chan<~[u8]>`
@ -146,8 +146,8 @@ pub mod serial {
let flat: SerializingFlattener<DefaultEncoder, T> =
SerializingFlattener::new(
serialize_value::<DefaultEncoder, T>);
let byte_chan = PipeByteChan::new(move chan);
FlatChan::new(move flat, move byte_chan)
let byte_chan = PipeByteChan::new(chan);
FlatChan::new(flat, byte_chan)
}
/// Create a pair of `FlatChan` and `FlatPort`, backed by pipes
@ -155,7 +155,7 @@ pub mod serial {
Decodable<DefaultDecoder>>(
) -> (PipePort<T>, PipeChan<T>) {
let (port, chan) = pipes::stream();
return (pipe_port(move port), pipe_chan(move chan));
return (pipe_port(port), pipe_chan(chan));
}
}
@ -193,8 +193,8 @@ pub mod pod {
reader: R
) -> ReaderPort<T, R> {
let unflat: PodUnflattener<T> = PodUnflattener::new();
let byte_port = ReaderBytePort::new(move reader);
FlatPort::new(move unflat, move byte_port)
let byte_port = ReaderBytePort::new(reader);
FlatPort::new(unflat, byte_port)
}
/// Create a `FlatChan` from a `Writer`
@ -202,28 +202,28 @@ pub mod pod {
writer: W
) -> WriterChan<T, W> {
let flat: PodFlattener<T> = PodFlattener::new();
let byte_chan = WriterByteChan::new(move writer);
FlatChan::new(move flat, move byte_chan)
let byte_chan = WriterByteChan::new(writer);
FlatChan::new(flat, byte_chan)
}
/// Create a `FlatPort` from a `Port<~[u8]>`
pub fn pipe_port<T: Copy Owned>(port: Port<~[u8]>) -> PipePort<T> {
let unflat: PodUnflattener<T> = PodUnflattener::new();
let byte_port = PipeBytePort::new(move port);
FlatPort::new(move unflat, move byte_port)
let byte_port = PipeBytePort::new(port);
FlatPort::new(unflat, byte_port)
}
/// Create a `FlatChan` from a `Chan<~[u8]>`
pub fn pipe_chan<T: Copy Owned>(chan: Chan<~[u8]>) -> PipeChan<T> {
let flat: PodFlattener<T> = PodFlattener::new();
let byte_chan = PipeByteChan::new(move chan);
FlatChan::new(move flat, move byte_chan)
let byte_chan = PipeByteChan::new(chan);
FlatChan::new(flat, byte_chan)
}
/// Create a pair of `FlatChan` and `FlatPort`, backed by pipes
pub fn pipe_stream<T: Copy Owned>() -> (PipePort<T>, PipeChan<T>) {
let (port, chan) = pipes::stream();
return (pipe_port(move port), pipe_chan(move chan));
return (pipe_port(port), pipe_chan(chan));
}
}
@ -261,13 +261,13 @@ const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
fn recv() -> T {
match self.try_recv() {
Some(move val) => move val,
Some(val) => val,
None => fail!(~"port is closed")
}
}
fn try_recv() -> Option<T> {
let command = match self.byte_port.try_recv(CONTINUE.len()) {
Some(move c) => move c,
Some(c) => c,
None => {
warn!("flatpipe: broken pipe");
return None;
@ -288,8 +288,8 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
let msg_len = msg_len as uint;
match self.byte_port.try_recv(msg_len) {
Some(move bytes) => {
Some(self.unflattener.unflatten(move bytes))
Some(bytes) => {
Some(self.unflattener.unflatten(bytes))
}
None => {
warn!("flatpipe: broken pipe");
@ -306,20 +306,20 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
impl<T,F:Flattener<T>,C:ByteChan> GenericChan<T> for FlatChan<T, F, C> {
fn send(val: T) {
self.byte_chan.send(CONTINUE.to_vec());
let bytes = self.flattener.flatten(move val);
let bytes = self.flattener.flatten(val);
let len = bytes.len() as u64;
do io::u64_to_be_bytes(len, size_of::<u64>()) |len_bytes| {
self.byte_chan.send(len_bytes.to_vec());
}
self.byte_chan.send(move bytes);
self.byte_chan.send(bytes);
}
}
pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P> {
static fn new(u: U, p: P) -> FlatPort<T, U, P> {
FlatPort {
unflattener: move u,
byte_port: move p
unflattener: u,
byte_port: p
}
}
}
@ -327,8 +327,8 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P> {
pub impl<T,F:Flattener<T>,C:ByteChan> FlatChan<T, F, C> {
static fn new(f: F, c: C) -> FlatChan<T, F, C> {
FlatChan {
flattener: move f,
byte_chan: move c
flattener: f,
byte_chan: c
}
}
}
@ -426,7 +426,7 @@ pub mod flatteners {
static fn new(deserialize_buffer: DeserializeBuffer<T>
) -> DeserializingUnflattener<D, T> {
DeserializingUnflattener {
deserialize_buffer: move deserialize_buffer
deserialize_buffer: deserialize_buffer
}
}
}
@ -437,7 +437,7 @@ pub mod flatteners {
static fn new(serialize_value: SerializeValue<T>
) -> SerializingFlattener<S, T> {
SerializingFlattener {
serialize_value: move serialize_value
serialize_value: serialize_value
}
}
}
@ -450,7 +450,7 @@ pub mod flatteners {
pub fn deserialize_buffer<D: Decoder FromReader,
T: Decodable<D>>(buf: &[u8]) -> T {
let buf = vec::from_slice(buf);
let buf_reader = @BufReader::new(move buf);
let buf_reader = @BufReader::new(buf);
let reader = buf_reader as @Reader;
let deser: D = FromReader::from_reader(reader);
Decodable::decode(&deser)
@ -462,8 +462,8 @@ pub mod flatteners {
let writer = bytes_writer as @Writer;
let ser = FromWriter::from_writer(writer);
val.encode(&ser);
let bytes = bytes_writer.bytes.check_out(|bytes| move bytes);
return move bytes;
let bytes = bytes_writer.bytes.check_out(|bytes| bytes);
return bytes;
}
pub trait FromReader {
@ -477,8 +477,8 @@ pub mod flatteners {
impl FromReader for json::Decoder {
static fn from_reader(r: Reader) -> json::Decoder {
match json::from_reader(r) {
Ok(move json) => {
json::Decoder(move json)
Ok(json) => {
json::Decoder(json)
}
Err(e) => fail!(fmt!("flatpipe: can't parse json: %?", e))
}
@ -487,7 +487,7 @@ pub mod flatteners {
impl FromWriter for json::Encoder {
static fn from_writer(w: Writer) -> json::Encoder {
json::Encoder(move w)
json::Encoder(w)
}
}
@ -495,13 +495,13 @@ pub mod flatteners {
static fn from_reader(r: Reader) -> ebml::reader::Decoder {
let buf = @r.read_whole_stream();
let doc = ebml::reader::Doc(buf);
ebml::reader::Decoder(move doc)
ebml::reader::Decoder(doc)
}
}
impl FromWriter for ebml::writer::Encoder {
static fn from_writer(w: Writer) -> ebml::writer::Encoder {
ebml::writer::Encoder(move w)
ebml::writer::Encoder(w)
}
}
@ -537,7 +537,7 @@ pub mod bytepipes {
}
if left == 0 {
return Some(move bytes);
return Some(bytes);
} else {
warn!("flatpipe: dropped %? broken bytes", left);
return None;
@ -554,7 +554,7 @@ pub mod bytepipes {
pub impl<R: Reader> ReaderBytePort<R> {
static fn new(r: R) -> ReaderBytePort<R> {
ReaderBytePort {
reader: move r
reader: r
}
}
}
@ -562,7 +562,7 @@ pub mod bytepipes {
pub impl<W: Writer> WriterByteChan<W> {
static fn new(w: W) -> WriterByteChan<W> {
WriterByteChan {
writer: move w
writer: w
}
}
}
@ -587,17 +587,17 @@ pub mod bytepipes {
let mut bytes = ::core::util::replace(&mut self.buf, ~[]);
assert count > bytes.len();
match self.try_recv(count - bytes.len()) {
Some(move rest) => {
Some(rest) => {
bytes.push_all(rest);
return Some(move bytes);
return Some(bytes);
}
None => return None
}
} else if self.buf.is_empty() {
match self.port.try_recv() {
Some(move buf) => {
Some(buf) => {
assert !buf.is_empty();
self.buf = move buf;
self.buf = buf;
return self.try_recv(count);
}
None => return None
@ -610,14 +610,14 @@ pub mod bytepipes {
pub impl PipeByteChan: ByteChan {
fn send(&self, val: ~[u8]) {
self.chan.send(move val)
self.chan.send(val)
}
}
pub impl PipeBytePort {
static fn new(p: Port<~[u8]>) -> PipeBytePort {
PipeBytePort {
port: move p,
port: p,
buf: ~[]
}
}
@ -626,7 +626,7 @@ pub mod bytepipes {
pub impl PipeByteChan {
static fn new(c: Chan<~[u8]>) -> PipeByteChan {
PipeByteChan {
chan: move c
chan: c
}
}
}
@ -661,14 +661,14 @@ mod test {
#[test]
fn test_serializing_memory_stream() {
let writer = BytesWriter();
let chan = serial::writer_chan(move writer);
let chan = serial::writer_chan(writer);
chan.send(10);
let bytes = chan.byte_chan.writer.bytes.get();
let reader = BufReader::new(move bytes);
let port = serial::reader_port(move reader);
let reader = BufReader::new(bytes);
let port = serial::reader_port(reader);
let res: int = port.recv();
assert res == 10i;
@ -678,7 +678,7 @@ mod test {
fn test_serializing_pipes() {
let (port, chan) = serial::pipe_stream();
do task::spawn |move chan| {
do task::spawn || {
for int::range(0, 10) |i| {
chan.send(i)
}
@ -693,7 +693,7 @@ mod test {
fn test_serializing_boxes() {
let (port, chan) = serial::pipe_stream();
do task::spawn |move chan| {
do task::spawn || {
for int::range(0, 10) |i| {
chan.send(@i)
}
@ -707,14 +707,14 @@ mod test {
#[test]
fn test_pod_memory_stream() {
let writer = BytesWriter();
let chan = pod::writer_chan(move writer);
let chan = pod::writer_chan(writer);
chan.send(10);
let bytes = chan.byte_chan.writer.bytes.get();
let reader = BufReader::new(move bytes);
let port = pod::reader_port(move reader);
let reader = BufReader::new(bytes);
let port = pod::reader_port(reader);
let res: int = port.recv();
assert res == 10;
@ -724,7 +724,7 @@ mod test {
fn test_pod_pipes() {
let (port, chan) = pod::pipe_stream();
do task::spawn |move chan| {
do task::spawn || {
for int::range(0, 10) |i| {
chan.send(i)
}
@ -741,11 +741,11 @@ mod test {
fn test_pod_tcp_stream() {
fn reader_port(buf: TcpSocketBuf
) -> pod::ReaderPort<int, TcpSocketBuf> {
pod::reader_port(move buf)
pod::reader_port(buf)
}
fn writer_chan(buf: TcpSocketBuf
) -> pod::WriterChan<int, TcpSocketBuf> {
pod::writer_chan(move buf)
pod::writer_chan(buf)
}
test_some_tcp_stream(reader_port, writer_chan, 9666);
}
@ -755,11 +755,11 @@ mod test {
fn test_serializing_tcp_stream() {
fn reader_port(buf: TcpSocketBuf
) -> serial::ReaderPort<int, TcpSocketBuf> {
serial::reader_port(move buf)
serial::reader_port(buf)
}
fn writer_chan(buf: TcpSocketBuf
) -> serial::WriterChan<int, TcpSocketBuf> {
serial::writer_chan(move buf)
serial::writer_chan(buf)
}
test_some_tcp_stream(reader_port, writer_chan, 9667);
}
@ -790,27 +790,25 @@ mod test {
let addr0 = ip::v4::parse_addr("127.0.0.1");
let begin_connect_chan = Cell(move begin_connect_chan);
let accept_chan = Cell(move accept_chan);
let begin_connect_chan = Cell(begin_connect_chan);
let accept_chan = Cell(accept_chan);
// The server task
let addr = copy addr0;
do task::spawn |move begin_connect_chan,
move accept_chan| {
do task::spawn || {
let iotask = &uv::global_loop::get();
let begin_connect_chan = begin_connect_chan.take();
let accept_chan = accept_chan.take();
let listen_res = do tcp::listen(
copy addr, port, 128, iotask,
|move begin_connect_chan, _kill_ch| {
copy addr, port, 128, iotask, |_kill_ch| {
// Tell the sender to initiate the connection
debug!("listening");
begin_connect_chan.send(())
}) |move accept_chan, new_conn, kill_ch| {
}) |new_conn, kill_ch| {
// Incoming connection. Send it to the receiver task to accept
let (res_port, res_chan) = pipes::stream();
accept_chan.send((move new_conn, move res_chan));
accept_chan.send((new_conn, res_chan));
// Wait until the connection is accepted
res_port.recv();
@ -823,8 +821,7 @@ mod test {
// Client task
let addr = copy addr0;
do task::spawn |move begin_connect_port,
move writer_chan| {
do task::spawn || {
// Wait for the server to start listening
begin_connect_port.recv();
@ -833,11 +830,11 @@ mod test {
let iotask = &uv::global_loop::get();
let connect_result = tcp::connect(copy addr, port, iotask);
assert connect_result.is_ok();
let sock = result::unwrap(move connect_result);
let socket_buf: tcp::TcpSocketBuf = tcp::socket_buf(move sock);
let sock = result::unwrap(connect_result);
let socket_buf: tcp::TcpSocketBuf = tcp::socket_buf(sock);
// TcpSocketBuf is a Writer!
let chan = writer_chan(move socket_buf);
let chan = writer_chan(socket_buf);
for int::range(0, 10) |i| {
debug!("sending %?", i);
@ -846,9 +843,7 @@ mod test {
}
// Reciever task
do task::spawn |move accept_port, move finish_chan,
move reader_port| {
do task::spawn || {
// Wait for a connection
let (conn, res_chan) = accept_port.recv();
@ -856,13 +851,13 @@ mod test {
let accept_result = tcp::accept(conn);
debug!("accepted");
assert accept_result.is_ok();
let sock = result::unwrap(move accept_result);
let sock = result::unwrap(accept_result);
res_chan.send(());
let socket_buf: tcp::TcpSocketBuf = tcp::socket_buf(move sock);
let socket_buf: tcp::TcpSocketBuf = tcp::socket_buf(sock);
// TcpSocketBuf is a Reader!
let port = reader_port(move socket_buf);
let port = reader_port(socket_buf);
for int::range(0, 10) |i| {
let j = port.recv();
@ -897,22 +892,22 @@ mod test {
fn reader_port_loader(bytes: ~[u8]
) -> pod::ReaderPort<int, BufReader> {
let reader = BufReader::new(move bytes);
pod::reader_port(move reader)
let reader = BufReader::new(bytes);
pod::reader_port(reader)
}
fn pipe_port_loader(bytes: ~[u8]
) -> pod::PipePort<int> {
let (port, chan) = pipes::stream();
if !bytes.is_empty() {
chan.send(move bytes);
chan.send(bytes);
}
pod::pipe_port(move port)
pod::pipe_port(port)
}
fn test_try_recv_none1<P: BytePort>(loader: PortLoader<P>) {
let bytes = ~[];
let port = loader(move bytes);
let port = loader(bytes);
let res: Option<int> = port.try_recv();
assert res.is_none();
}
@ -929,7 +924,7 @@ mod test {
fn test_try_recv_none2<P: BytePort>(loader: PortLoader<P>) {
// The control word in the protocol is interrupted
let bytes = ~[0];
let port = loader(move bytes);
let port = loader(bytes);
let res: Option<int> = port.try_recv();
assert res.is_none();
}
@ -947,7 +942,7 @@ mod test {
const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
// The control word is followed by garbage
let bytes = CONTINUE.to_vec() + ~[0];
let port = loader(move bytes);
let port = loader(bytes);
let res: Option<int> = port.try_recv();
assert res.is_none();
}
@ -962,7 +957,7 @@ mod test {
}
fn test_try_recv_none4<P: BytePort>(+loader: PortLoader<P>) {
assert do task::try |move loader| {
assert do task::try || {
const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
// The control word is followed by a valid length,
// then undeserializable garbage
@ -972,7 +967,7 @@ mod test {
};
let bytes = CONTINUE.to_vec() + len_bytes + ~[0, 0, 0, 0];
let port = loader(move bytes);
let port = loader(bytes);
let _res: Option<int> = port.try_recv();
}.is_err();

View File

@ -55,7 +55,7 @@ pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, k: K) -> Option<V> {
Node(@ref kk, @copy v, left, right) => {
if k == *kk {
Some(v)
} else if k < *kk { find(left, move k) } else { find(right, move k) }
} else if k < *kk { find(left, k) } else { find(right, k) }
}
}
}

View File

@ -71,10 +71,10 @@ impl<A> Future<A> {
let mut state = Evaluating;
self.state <-> state;
match move state {
match state {
Forced(_) | Evaluating => fail!(~"Logic error."),
Pending(move f) => {
self.state = Forced(move f());
Pending(f) => {
self.state = Forced(f());
self.get_ref()
}
}
@ -90,7 +90,7 @@ pub fn from_value<A>(val: A) -> Future<A> {
* not block.
*/
Future {state: Forced(move val)}
Future {state: Forced(val)}
}
pub fn from_port<A:Owned>(port: PortOne<A>) ->
@ -102,13 +102,13 @@ pub fn from_port<A:Owned>(port: PortOne<A>) ->
* waiting for the result to be received on the port.
*/
let port = ~mut Some(move port);
do from_fn |move port| {
let port = ~mut Some(port);
do from_fn || {
let mut port_ = None;
port_ <-> *port;
let port = option::unwrap(move port_);
match recv(move port) {
oneshot::send(move data) => move data
let port = option::unwrap(port_);
match recv(port) {
oneshot::send(data) => data
}
}
}
@ -122,7 +122,7 @@ pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> {
* function. It is not spawned into another task.
*/
Future {state: Pending(move f)}
Future {state: Pending(f)}
}
pub fn spawn<A:Owned>(blk: fn~() -> A) -> Future<A> {
@ -135,13 +135,13 @@ pub fn spawn<A:Owned>(blk: fn~() -> A) -> Future<A> {
let (chan, port) = oneshot::init();
let chan = ~mut Some(move chan);
do task::spawn |move blk, move chan| {
let chan = ~mut Some(chan);
do task::spawn || {
let chan = option::swap_unwrap(&mut *chan);
send_one(move chan, blk());
send_one(chan, blk());
}
return from_port(move port);
return from_port(port);
}
#[allow(non_implicitly_copyable_typarams)]
@ -162,8 +162,8 @@ pub mod test {
#[test]
pub fn test_from_port() {
let (ch, po) = oneshot::init();
send_one(move ch, ~"whale");
let f = from_port(move po);
send_one(ch, ~"whale");
let f = from_port(po);
assert f.get() == ~"whale";
}
@ -203,7 +203,7 @@ pub mod test {
pub fn test_sendable_future() {
let expected = ~"schlorf";
let f = do spawn |copy expected| { copy expected };
do task::spawn |move f, move expected| {
do task::spawn || {
let actual = f.get();
assert actual == expected;
}

View File

@ -35,7 +35,7 @@
* fn do_work(in: &str, out: Option<~str>) {
* io::println(in);
* io::println(match out {
* Some(move x) => x,
* Some(x) => x,
* None => ~"No Output"
* });
* }
@ -339,7 +339,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
i += 1;
}
return Ok(Matches {opts: vec::from_slice(opts),
vals: move vals,
vals: vals,
free: free});
}
}
@ -1178,7 +1178,7 @@ mod tests {
let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
let opts = ~[optopt(~"e"), optopt(~"encrypt")];
let matches = &match getopts(args, opts) {
result::Ok(move m) => m,
result::Ok(m) => m,
result::Err(_) => fail!()
};
assert opts_present(matches, ~[~"e"]);
@ -1199,7 +1199,7 @@ mod tests {
let args = ~[~"-Lfoo", ~"-M."];
let opts = ~[optmulti(~"L"), optmulti(~"M")];
let matches = &match getopts(args, opts) {
result::Ok(move m) => m,
result::Ok(m) => m,
result::Err(_) => fail!()
};
assert opts_present(matches, ~[~"L"]);

View File

@ -20,7 +20,7 @@ pub struct BufReader {
pub impl BufReader {
static pub fn new(v: ~[u8]) -> BufReader {
BufReader {
buf: move v,
buf: v,
pos: 0
}
}
@ -38,7 +38,7 @@ pub impl BufReader {
// FIXME #4429: This isn't correct if f fails
self.pos = bytes_reader.pos;
return move res;
return res;
}
}

View File

@ -388,18 +388,18 @@ pub fn Parser(rdr: io::Reader) -> Parser {
pub impl Parser {
fn parse() -> Result<Json, Error> {
match move self.parse_value() {
Ok(move value) => {
match self.parse_value() {
Ok(value) => {
// Skip trailing whitespaces.
self.parse_whitespace();
// Make sure there is no trailing characters.
if self.eof() {
Ok(move value)
Ok(value)
} else {
self.error(~"trailing characters")
}
}
Err(move e) => Err(e)
Err(e) => Err(e)
}
}
}
@ -438,9 +438,9 @@ priv impl Parser {
'f' => self.parse_ident(~"alse", Boolean(false)),
'0' .. '9' | '-' => self.parse_number(),
'"' =>
match move self.parse_str() {
Ok(move s) => Ok(String(s)),
Err(move e) => Err(e),
match self.parse_str() {
Ok(s) => Ok(String(s)),
Err(e) => Err(e),
},
'[' => self.parse_list(),
'{' => self.parse_object(),
@ -455,7 +455,7 @@ priv impl Parser {
fn parse_ident(ident: &str, value: Json) -> Result<Json, Error> {
if str::all(ident, |c| c == self.next_char()) {
self.bump();
Ok(move value)
Ok(value)
} else {
self.error(~"invalid syntax")
}
@ -662,13 +662,13 @@ priv impl Parser {
if self.ch == ']' {
self.bump();
return Ok(List(move values));
return Ok(List(values));
}
loop {
match move self.parse_value() {
Ok(move v) => values.push(move v),
Err(move e) => return Err(e)
match self.parse_value() {
Ok(v) => values.push(v),
Err(e) => return Err(e)
}
self.parse_whitespace();
@ -678,7 +678,7 @@ priv impl Parser {
match self.ch {
',' => self.bump(),
']' => { self.bump(); return Ok(List(move values)); }
']' => { self.bump(); return Ok(List(values)); }
_ => return self.error(~"expected `,` or `]`")
}
};
@ -692,7 +692,7 @@ priv impl Parser {
if self.ch == '}' {
self.bump();
return Ok(Object(move values));
return Ok(Object(values));
}
while !self.eof() {
@ -702,9 +702,9 @@ priv impl Parser {
return self.error(~"key must be a string");
}
let key = match move self.parse_str() {
Ok(move key) => key,
Err(move e) => return Err(e)
let key = match self.parse_str() {
Ok(key) => key,
Err(e) => return Err(e)
};
self.parse_whitespace();
@ -715,15 +715,15 @@ priv impl Parser {
}
self.bump();
match move self.parse_value() {
Ok(move value) => { values.insert(key, move value); }
Err(move e) => return Err(e)
match self.parse_value() {
Ok(value) => { values.insert(key, value); }
Err(e) => return Err(e)
}
self.parse_whitespace();
match self.ch {
',' => self.bump(),
'}' => { self.bump(); return Ok(Object(move values)); }
'}' => { self.bump(); return Ok(Object(values)); }
_ => {
if self.eof() { break; }
return self.error(~"expected `,` or `}`");
@ -753,7 +753,7 @@ pub struct Decoder {
}
pub fn Decoder(json: Json) -> Decoder {
Decoder { json: move json, stack: ~[] }
Decoder { json: json, stack: ~[] }
}
priv impl Decoder {
@ -868,7 +868,7 @@ pub impl Decoder: serialize::Decoder {
};
let res = f(len);
self.pop();
move res
res
}
fn read_managed_vec<T>(&self, f: fn(uint) -> T) -> T {
@ -879,7 +879,7 @@ pub impl Decoder: serialize::Decoder {
};
let res = f(len);
self.pop();
move res
res
}
fn read_vec_elt<T>(&self, idx: uint, f: fn() -> T) -> T {
@ -897,14 +897,14 @@ pub impl Decoder: serialize::Decoder {
debug!("read_rec()");
let value = f();
self.pop();
move value
value
}
fn read_struct<T>(&self, _name: &str, _len: uint, f: fn() -> T) -> T {
debug!("read_struct()");
let value = f();
self.pop();
move value
value
}
fn read_field<T>(&self, name: &str, idx: uint, f: fn() -> T) -> T {
@ -934,7 +934,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_tup(len=%u)", len);
let value = f();
self.pop();
move value
value
}
fn read_tup_elt<T>(&self, idx: uint, f: fn() -> T) -> T {
@ -1219,11 +1219,11 @@ mod tests {
for items.each |item| {
match *item {
(copy key, copy value) => { d.insert(key, move value); },
(copy key, copy value) => { d.insert(key, value); },
}
};
Object(move d)
Object(d)
}
#[test]

View File

@ -181,7 +181,7 @@ pub mod v4 {
*/
pub fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) {
result::Ok(move addr) => move addr,
result::Ok(addr) => addr,
result::Err(ref err_data) => fail!(err_data.err_msg)
}
}
@ -276,7 +276,7 @@ pub mod v6 {
*/
pub fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) {
result::Ok(move addr) => move addr,
result::Ok(addr) => addr,
result::Err(copy err_data) => fail!(err_data.err_msg)
}
}
@ -331,7 +331,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
result::Err(GetAddrUnknownError));
break;
};
out_vec.push(move new_ip_addr);
out_vec.push(new_ip_addr);
let next_addr = ll::get_next_addrinfo(curr_addr);
if next_addr == ptr::null::<addrinfo>() as *addrinfo {
@ -345,7 +345,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
}
log(debug, fmt!("successful process addrinfo result, len: %?",
vec::len(out_vec)));
output_ch.send(result::Ok(move out_vec));
output_ch.send(result::Ok(out_vec));
}
else {
log(debug, ~"addrinfo pointer is NULL");
@ -427,7 +427,7 @@ mod test {
}
// note really sure how to realiably test/assert
// this.. mostly just wanting to see it work, atm.
let results = result::unwrap(move ga_result);
let results = result::unwrap(ga_result);
log(debug, fmt!("test_get_addr: Number of results for %s: %?",
localhost_name, vec::len(results)));
for vec::each(results) |r| {

View File

@ -177,7 +177,7 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
// we can send into the interact cb to be handled in libuv..
debug!("stream_handle_ptr outside interact %?",
stream_handle_ptr);
do iotask::interact(iotask) |move input_ip, loop_ptr| {
do iotask::interact(iotask) |loop_ptr| {
unsafe {
debug!("in interact cb for tcp client connect..");
debug!("stream_handle_ptr in interact %?",
@ -629,10 +629,10 @@ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
new_connect_cb: fn~(TcpNewConnection,
SharedChan<Option<TcpErrData>>))
-> result::Result<(), TcpListenErrData> {
do listen_common(move host_ip, port, backlog, iotask,
move on_establish_cb)
do listen_common(host_ip, port, backlog, iotask,
on_establish_cb)
// on_connect_cb
|move new_connect_cb, handle| {
|handle| {
unsafe {
let server_data_ptr = uv::ll::get_data_for_uv_handle(handle)
as *TcpListenFcData;
@ -659,7 +659,7 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
server_stream_ptr: server_stream_ptr,
stream_closed_ch: stream_closed_ch,
kill_ch: kill_ch.clone(),
on_connect_cb: move on_connect_cb,
on_connect_cb: on_connect_cb,
iotask: iotask.clone(),
ipv6: match &host_ip {
&ip::Ipv4(_) => { false }
@ -678,7 +678,7 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
// tcp::connect (because the iotask::interact cb isn't
// nested within a core::comm::listen block)
let loc_ip = copy(host_ip);
do iotask::interact(iotask) |move loc_ip, loop_ptr| {
do iotask::interact(iotask) |loop_ptr| {
unsafe {
match uv::ll::tcp_init(loop_ptr, server_stream_ptr) {
0i32 => {
@ -815,7 +815,7 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
*/
pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
TcpSocketBuf(@TcpBufferedSocketData {
sock: move sock, mut buf: ~[], buf_off: 0
sock: sock, mut buf: ~[], buf_off: 0
})
}
@ -851,12 +851,12 @@ impl TcpSocket {
let addr = uv::ll::ip6_addr("", 0);
uv::ll::tcp_getpeername6(self.socket_data.stream_handle_ptr,
ptr::addr_of(&addr));
ip::Ipv6(move addr)
ip::Ipv6(addr)
} else {
let addr = uv::ll::ip4_addr("", 0);
uv::ll::tcp_getpeername(self.socket_data.stream_handle_ptr,
ptr::addr_of(&addr));
ip::Ipv4(move addr)
ip::Ipv4(addr)
}
}
}
@ -1047,7 +1047,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint)
Some(result::get(&rs_result).recv())
};
log(debug, ~"tcp::read after recv_timeout");
match move read_result {
match read_result {
None => {
log(debug, ~"tcp::read: timed out..");
let err_data = TcpErrData {
@ -1057,7 +1057,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint)
read_stop_common_impl(socket_data);
result::Err(err_data)
}
Some(move data_result) => {
Some(data_result) => {
log(debug, ~"tcp::read got data");
read_stop_common_impl(socket_data);
data_result
@ -1091,7 +1091,7 @@ fn read_stop_common_impl(socket_data: *TcpSocketData) ->
}
}
match stop_po.recv() {
Some(move err_data) => Err(err_data),
Some(err_data) => Err(err_data),
None => Ok(())
}
}
@ -1183,7 +1183,7 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData,
// aftermath, so we don't have to sit here blocking.
match result_po.recv() {
TcpWriteSuccess => Ok(()),
TcpWriteError(move err_data) => Err(err_data)
TcpWriteError(err_data) => Err(err_data)
}
}
}
@ -1613,10 +1613,10 @@ pub mod test {
debug!("server started, firing up client..");
let server_ip_addr = ip::v4::parse_addr(server_ip);
let iotask = uv::global_loop::get();
let connect_result = connect(move server_ip_addr, server_port,
let connect_result = connect(server_ip_addr, server_port,
&iotask);
let sock = result::unwrap(move connect_result);
let sock = result::unwrap(connect_result);
debug!("testing peer address");
// This is what we are actually testing!
@ -1784,11 +1784,11 @@ pub mod test {
// client
debug!("server started, firing up client..");
let server_addr = ip::v4::parse_addr(server_ip);
let conn_result = connect(move server_addr, server_port, hl_loop);
let conn_result = connect(server_addr, server_port, hl_loop);
if result::is_err(&conn_result) {
assert false;
}
let sock_buf = @socket_buf(result::unwrap(move conn_result));
let sock_buf = @socket_buf(result::unwrap(conn_result));
buf_write(sock_buf, expected_req);
let buf_reader = sock_buf as Reader;
@ -1819,7 +1819,7 @@ pub mod test {
let (server_po, server_ch) = stream::<~str>();
let server_ch = SharedChan(server_ch);
let server_ip_addr = ip::v4::parse_addr(server_ip);
let listen_result = listen(move server_ip_addr, server_port, 128,
let listen_result = listen(server_ip_addr, server_port, 128,
iotask,
// on_establish_cb -- called when listener is set up
|kill_ch| {
@ -1849,15 +1849,15 @@ pub mod test {
else {
debug!("SERVER/WORKER: send on cont ch");
cont_ch.send(());
let sock = result::unwrap(move accept_result);
let sock = result::unwrap(accept_result);
let peer_addr = sock.get_peer_addr();
debug!("SERVER: successfully accepted \
connection from %s:%u",
ip::format_addr(&peer_addr),
ip::get_port(&peer_addr));
let received_req_bytes = read(&sock, 0u);
match move received_req_bytes {
result::Ok(move data) => {
match received_req_bytes {
result::Ok(data) => {
debug!("SERVER: got REQ str::from_bytes..");
debug!("SERVER: REQ data len: %?",
vec::len(data));
@ -1868,7 +1868,7 @@ pub mod test {
debug!("SERVER: after write.. die");
kill_ch.send(None);
}
result::Err(move err_data) => {
result::Err(err_data) => {
debug!("SERVER: error recvd: %s %s",
err_data.err_name, err_data.err_msg);
kill_ch.send(Some(err_data));
@ -1904,7 +1904,7 @@ pub mod test {
fn run_tcp_test_server_fail(server_ip: &str, server_port: uint,
iotask: &IoTask) -> TcpListenErrData {
let server_ip_addr = ip::v4::parse_addr(server_ip);
let listen_result = listen(move server_ip_addr, server_port, 128,
let listen_result = listen(server_ip_addr, server_port, 128,
iotask,
// on_establish_cb -- called when listener is set up
|kill_ch| {
@ -1929,7 +1929,7 @@ pub mod test {
let server_ip_addr = ip::v4::parse_addr(server_ip);
debug!("CLIENT: starting..");
let connect_result = connect(move server_ip_addr, server_port,
let connect_result = connect(server_ip_addr, server_port,
iotask);
if result::is_err(&connect_result) {
debug!("CLIENT: failed to connect");
@ -1937,7 +1937,7 @@ pub mod test {
Err(err_data)
}
else {
let sock = result::unwrap(move connect_result);
let sock = result::unwrap(connect_result);
let resp_bytes = str::to_bytes(resp);
tcp_write_single(&sock, resp_bytes);
let read_result = sock.read(0u);

View File

@ -253,7 +253,7 @@ pub fn decode_form_urlencoded(s: &[u8]) -> LinearMap<~str, ~[~str]> {
'&' | ';' => {
if key != ~"" && value != ~"" {
let mut values = match m.pop(&key) {
Some(move values) => values,
Some(values) => values,
None => ~[],
};
@ -287,7 +287,7 @@ pub fn decode_form_urlencoded(s: &[u8]) -> LinearMap<~str, ~[~str]> {
if key != ~"" && value != ~"" {
let mut values = match m.pop(&key) {
Some(move values) => values,
Some(values) => values,
None => ~[],
};
@ -671,7 +671,7 @@ pub pure fn from_str(rawurl: &str) -> Result<Url, ~str> {
impl FromStr for Url {
static pure fn from_str(s: &str) -> Option<Url> {
match from_str(s) {
Ok(move url) => Some(url),
Ok(url) => Some(url),
Err(_) => None
}
}

View File

@ -132,7 +132,7 @@ pub mod chained {
entry.next = new_chains[idx];
new_chains[idx] = Some(entry);
}
self.chains = move new_chains;
self.chains = new_chains;
}
pure fn each_entry(blk: fn(@Entry<K,V>) -> bool) {
@ -321,7 +321,7 @@ pub mod chained {
if opt_v.is_none() {
fail!(fmt!("Key not found in table: %?", k));
}
option::unwrap(move opt_v)
option::unwrap(opt_v)
}
}

View File

@ -69,7 +69,7 @@ pub pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T {
error!("smallintmap::get(): key not present");
fail!();
}
Some(move v) => return v
Some(v) => return v
}
}

View File

@ -58,7 +58,7 @@ fn map_slices<A: Copy Owned, B: Copy Owned>(
do vec::as_imm_buf(xs) |p, _len| {
let f = f();
let base = base;
let f = do future_spawn() |move f| {
let f = do future_spawn() || {
unsafe {
let len = end - base;
let slice = (ptr::offset(p, base),
@ -72,7 +72,7 @@ fn map_slices<A: Copy Owned, B: Copy Owned>(
f(base, slice)
}
};
futures.push(move f);
futures.push(f);
};
base += items_per_task;
}

View File

@ -139,27 +139,27 @@ impl <T: Ord> PriorityQueue<T> {
priv fn siftup(&mut self, start: uint, mut pos: uint) {
unsafe {
let new = move *addr_of(&self.data[pos]);
let new = *addr_of(&self.data[pos]);
while pos > start {
let parent = (pos - 1) >> 1;
if new > self.data[parent] {
let mut x = rusti::init();
x <-> self.data[parent];
rusti::move_val_init(&mut self.data[pos], move x);
rusti::move_val_init(&mut self.data[pos], x);
pos = parent;
loop
}
break
}
rusti::move_val_init(&mut self.data[pos], move new);
rusti::move_val_init(&mut self.data[pos], new);
}
}
priv fn siftdown_range(&mut self, mut pos: uint, end: uint) {
unsafe {
let start = pos;
let new = move *addr_of(&self.data[pos]);
let new = *addr_of(&self.data[pos]);
let mut child = 2 * pos + 1;
while child < end {
@ -169,12 +169,12 @@ impl <T: Ord> PriorityQueue<T> {
}
let mut x = rusti::init();
x <-> self.data[child];
rusti::move_val_init(&mut self.data[pos], move x);
rusti::move_val_init(&mut self.data[pos], x);
pos = child;
child = 2 * pos + 1;
}
rusti::move_val_init(&mut self.data[pos], move new);
rusti::move_val_init(&mut self.data[pos], new);
self.siftup(start, pos);
}
}

View File

@ -71,7 +71,7 @@ fn complete_key(_v: @CompletionCb) {}
/// Bind to the main completion callback
pub unsafe fn complete(cb: CompletionCb) {
unsafe {
task::local_data::local_data_set(complete_key, @(move cb));
task::local_data::local_data_set(complete_key, @(cb));
extern fn callback(line: *c_char, completions: *()) {
unsafe {

View File

@ -848,11 +848,11 @@ pub mod node {
offset += 1u;
i += 1u;
}
cast::forget(move local_buf);
cast::forget(local_buf);
}
}
}
return cast::transmute(move buf);
return cast::transmute(buf);
}
}

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