libstd: Get rid of move.

This commit is contained in:
Luqman Aden 2013-02-15 02:30:30 -05:00 committed by Luqman Aden
parent 9727008ed0
commit 4cf51c2531
31 changed files with 357 additions and 363 deletions

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 |f, expected| {
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);
}
}

View file

@ -265,7 +265,7 @@ pub fn sha1() -> Sha1 {
computed: false,
work_buf: @mut vec::from_elem(work_buf_len, 0u32)
};
let mut sh = (move st) as Sha1;
let mut sh = (st) as Sha1;
sh.reset();
return sh;
}

View file

@ -59,7 +59,7 @@ pub pure fn merge_sort<T: Copy>(v: &[const T], le: Le<T>) -> ~[T] {
}
rs.push_all(vec::slice(a, a_ix, a_len));
rs.push_all(vec::slice(b, b_ix, b_len));
move rs
rs
}
}
@ -241,7 +241,7 @@ fn binarysort<T: Copy Ord>(array: &mut [T], start: uint) {
let mut n = start-left;
copy_vec(array, left+1, array, left, n);
array[left] = move pivot;
array[left] = pivot;
start += 1;
}
}
@ -816,7 +816,7 @@ mod test_qsort {
do quick_sort(names) |x, y| { int::le(*x, *y) };
let immut_names = move names;
let immut_names = names;
let pairs = vec::zip_slice(expected, immut_names);
for vec::each(pairs) |p| {
@ -1022,14 +1022,14 @@ mod big_tests {
let res = do vec::from_fn(num) |i| {
arr[i % size]
};
move res
res
}
fn makeRange(n: uint) -> ~[uint] {
let one = do vec::from_fn(n) |i| { i };
let mut two = copy one;
vec::reverse(two);
vec::append(move two, one)
vec::append(two, one)
}
fn tabulate_unique(lo: uint, hi: uint) {
@ -1048,7 +1048,7 @@ mod big_tests {
let arr = do vec::from_fn(n) |_i| {
rng.gen_float()
};
let mut arr = move arr;
let mut arr = arr;
tim_sort(arr); // *sort
isSorted(arr);
@ -1089,7 +1089,7 @@ mod big_tests {
let mut arr = if n > 4 {
let part = vec::view(arr, 0, 4);
multiplyVec(part, n)
} else { move arr };
} else { arr };
tim_sort(arr); // ~sort
isSorted(arr);
@ -1120,7 +1120,7 @@ mod big_tests {
let arr = do vec::from_fn(n) |_i| {
@rng.gen_float()
};
let mut arr = move arr;
let mut arr = arr;
tim_sort(arr); // *sort
isSorted(arr);
@ -1161,7 +1161,7 @@ mod big_tests {
let mut arr = if n > 4 {
let part = vec::view(arr, 0, 4);
multiplyVec(part, n)
} else { move arr };
} else { arr };
tim_sort(arr); // ~sort
isSorted(arr);

View file

@ -40,7 +40,7 @@ struct Waitqueue { head: pipes::Port<SignalEnd>,
fn new_waitqueue() -> Waitqueue {
let (block_head, block_tail) = pipes::stream();
Waitqueue { head: move block_head, tail: move block_tail }
Waitqueue { head: block_head, tail: block_tail }
}
// Signals one live task from the queue.
@ -86,7 +86,7 @@ enum Sem<Q> = Exclusive<SemInner<Q>>;
#[doc(hidden)]
fn new_sem<Q: Owned>(count: int, q: Q) -> Sem<Q> {
Sem(exclusive(SemInner {
mut count: count, waiters: new_waitqueue(), blocked: move q }))
mut count: count, waiters: new_waitqueue(), blocked: q }))
}
#[doc(hidden)]
fn new_sem_and_signal(count: int, num_condvars: uint)
@ -109,9 +109,9 @@ impl<Q: Owned> &Sem<Q> {
// Create waiter nobe.
let (WaitEnd, SignalEnd) = pipes::oneshot();
// Tell outer scope we need to block.
waiter_nobe = Some(move WaitEnd);
waiter_nobe = Some(WaitEnd);
// Enqueue ourself.
state.waiters.tail.send(move SignalEnd);
state.waiters.tail.send(SignalEnd);
}
}
}
@ -119,7 +119,7 @@ impl<Q: Owned> &Sem<Q> {
/* for 1000.times { task::yield(); } */
// Need to wait outside the exclusive.
if waiter_nobe.is_some() {
let _ = pipes::recv_one(option::unwrap(move waiter_nobe));
let _ = pipes::recv_one(option::unwrap(waiter_nobe));
}
}
fn release() {
@ -215,8 +215,8 @@ impl &Condvar {
fn wait_on(condvar_id: uint) {
// Create waiter nobe.
let (WaitEnd, SignalEnd) = pipes::oneshot();
let mut WaitEnd = Some(move WaitEnd);
let mut SignalEnd = Some(move SignalEnd);
let mut WaitEnd = Some(WaitEnd);
let mut SignalEnd = Some(SignalEnd);
let mut reacquire = None;
let mut out_of_bounds = None;
unsafe {
@ -231,7 +231,7 @@ impl &Condvar {
}
// Enqueue ourself to be woken up by a signaller.
let SignalEnd = option::swap_unwrap(&mut SignalEnd);
state.blocked[condvar_id].tail.send(move SignalEnd);
state.blocked[condvar_id].tail.send(SignalEnd);
} else {
out_of_bounds = Some(vec::len(state.blocked));
}
@ -737,7 +737,7 @@ mod tests {
pub fn test_sem_as_mutex() {
let s = ~semaphore(1);
let s2 = ~s.clone();
do task::spawn |move s2| {
do task::spawn || {
do s2.access {
for 5.times { task::yield(); }
}
@ -752,7 +752,7 @@ mod tests {
let (p,c) = pipes::stream();
let s = ~semaphore(0);
let s2 = ~s.clone();
do task::spawn |move s2, move c| {
do task::spawn || {
s2.acquire();
c.send(());
}
@ -764,7 +764,7 @@ mod tests {
let (p,c) = pipes::stream();
let s = ~semaphore(0);
let s2 = ~s.clone();
do task::spawn |move s2, move p| {
do task::spawn || {
for 5.times { task::yield(); }
s2.release();
let _ = p.recv();
@ -780,7 +780,7 @@ mod tests {
let s2 = ~s.clone();
let (p1,c1) = pipes::stream();
let (p2,c2) = pipes::stream();
do task::spawn |move s2, move c1, move p2| {
do task::spawn || {
do s2.access {
let _ = p2.recv();
c1.send(());
@ -799,10 +799,10 @@ mod tests {
let s = ~semaphore(1);
let s2 = ~s.clone();
let (p,c) = pipes::stream();
let child_data = ~mut Some((move s2, move c));
let child_data = ~mut Some((s2, c));
do s.access {
let (s2,c) = option::swap_unwrap(child_data);
do task::spawn |move c, move s2| {
do task::spawn || {
c.send(());
do s2.access { }
c.send(());
@ -825,7 +825,7 @@ mod tests {
let m2 = ~m.clone();
let mut sharedstate = ~0;
let ptr = ptr::addr_of(&(*sharedstate));
do task::spawn |move m2, move c| {
do task::spawn || {
let sharedstate: &mut int =
unsafe { cast::reinterpret_cast(&ptr) };
access_shared(sharedstate, m2, 10);
@ -854,7 +854,7 @@ mod tests {
// Child wakes up parent
do m.lock_cond |cond| {
let m2 = ~m.clone();
do task::spawn |move m2| {
do task::spawn || {
do m2.lock_cond |cond| {
let woken = cond.signal();
assert woken;
@ -865,7 +865,7 @@ mod tests {
// Parent wakes up child
let (port,chan) = pipes::stream();
let m3 = ~m.clone();
do task::spawn |move chan, move m3| {
do task::spawn || {
do m3.lock_cond |cond| {
chan.send(());
cond.wait();
@ -887,8 +887,8 @@ mod tests {
for num_waiters.times {
let mi = ~m.clone();
let (port, chan) = pipes::stream();
ports.push(move port);
do task::spawn |move chan, move mi| {
ports.push(port);
do task::spawn || {
do mi.lock_cond |cond| {
chan.send(());
cond.wait();
@ -918,7 +918,7 @@ mod tests {
pub fn test_mutex_cond_no_waiter() {
let m = ~Mutex();
let m2 = ~m.clone();
do task::try |move m| {
do task::try || {
do m.lock_cond |_x| { }
};
do m2.lock_cond |cond| {
@ -931,7 +931,7 @@ mod tests {
let m = ~Mutex();
let m2 = ~m.clone();
let result: result::Result<(),()> = do task::try |move m2| {
let result: result::Result<(),()> = do task::try || {
do m2.lock {
fail!();
}
@ -947,9 +947,9 @@ mod tests {
let m = ~Mutex();
let m2 = ~m.clone();
let result: result::Result<(),()> = do task::try |move m2| {
let result: result::Result<(),()> = do task::try || {
let (p,c) = pipes::stream();
do task::spawn |move p| { // linked
do task::spawn || { // linked
let _ = p.recv(); // wait for sibling to get in the mutex
task::yield();
fail!();
@ -972,19 +972,19 @@ mod tests {
let m2 = ~m.clone();
let (p,c) = pipes::stream();
let result: result::Result<(),()> = do task::try |move c, move m2| {
let result: result::Result<(),()> = do task::try || {
let mut sibling_convos = ~[];
for 2.times {
let (p,c) = pipes::stream();
let c = ~mut Some(move c);
sibling_convos.push(move p);
let c = ~mut Some(c);
sibling_convos.push(p);
let mi = ~m2.clone();
// spawn sibling task
do task::spawn |move mi, move c| { // linked
do task::spawn || { // linked
do mi.lock_cond |cond| {
let c = option::swap_unwrap(c);
c.send(()); // tell sibling to go ahead
let _z = SendOnFailure(move c);
let _z = SendOnFailure(c);
cond.wait(); // block forever
}
}
@ -993,7 +993,7 @@ mod tests {
let _ = p.recv(); // wait for sibling to get in the mutex
}
do m2.lock { }
c.send(move sibling_convos); // let parent wait on all children
c.send(sibling_convos); // let parent wait on all children
fail!();
};
assert result.is_err();
@ -1015,7 +1015,7 @@ mod tests {
fn SendOnFailure(c: pipes::Chan<()>) -> SendOnFailure {
SendOnFailure {
c: move c
c: c
}
}
}
@ -1025,7 +1025,7 @@ mod tests {
let m = ~Mutex();
do m.lock_cond |cond| {
let m2 = ~m.clone();
do task::spawn |move m2| {
do task::spawn || {
do m2.lock_cond |cond| {
cond.signal_on(0);
}
@ -1039,7 +1039,7 @@ mod tests {
let m = ~mutex_with_condvars(2);
let m2 = ~m.clone();
let (p,c) = pipes::stream();
do task::spawn |move m2, move c| {
do task::spawn || {
do m2.lock_cond |cond| {
c.send(());
cond.wait_on(1);
@ -1088,7 +1088,7 @@ mod tests {
},
DowngradeRead =>
do x.write_downgrade |mode| {
let mode = x.downgrade(move mode);
let mode = x.downgrade(mode);
(&mode).read(blk);
},
}
@ -1103,7 +1103,7 @@ mod tests {
let x2 = ~x.clone();
let mut sharedstate = ~0;
let ptr = ptr::addr_of(&(*sharedstate));
do task::spawn |move c, move x2| {
do task::spawn || {
let sharedstate: &mut int =
unsafe { cast::reinterpret_cast(&ptr) };
access_shared(sharedstate, x2, mode1, 10);
@ -1148,7 +1148,7 @@ mod tests {
let x2 = ~x.clone();
let (p1,c1) = pipes::stream();
let (p2,c2) = pipes::stream();
do task::spawn |move c1, move x2, move p2| {
do task::spawn || {
if !make_mode2_go_first {
let _ = p2.recv(); // parent sends to us once it locks, or ...
}
@ -1185,10 +1185,10 @@ mod tests {
// Tests that downgrade can unlock the lock in both modes
let x = ~RWlock();
do lock_rwlock_in_mode(x, Downgrade) { }
test_rwlock_handshake(move x, Read, Read, false);
test_rwlock_handshake(x, Read, Read, false);
let y = ~RWlock();
do lock_rwlock_in_mode(y, DowngradeRead) { }
test_rwlock_exclusion(move y, Write, Write);
test_rwlock_exclusion(y, Write, Write);
}
#[test]
pub fn test_rwlock_read_recursive() {
@ -1203,7 +1203,7 @@ mod tests {
// Child wakes up parent
do x.write_cond |cond| {
let x2 = ~x.clone();
do task::spawn |move x2| {
do task::spawn || {
do x2.write_cond |cond| {
let woken = cond.signal();
assert woken;
@ -1214,7 +1214,7 @@ mod tests {
// Parent wakes up child
let (port,chan) = pipes::stream();
let x3 = ~x.clone();
do task::spawn |move x3, move chan| {
do task::spawn || {
do x3.write_cond |cond| {
chan.send(());
cond.wait();
@ -1250,8 +1250,8 @@ mod tests {
for num_waiters.times {
let xi = ~x.clone();
let (port, chan) = pipes::stream();
ports.push(move port);
do task::spawn |move chan, move xi| {
ports.push(port);
do task::spawn || {
do lock_cond(xi, dg1) |cond| {
chan.send(());
cond.wait();
@ -1286,7 +1286,7 @@ mod tests {
let x = ~RWlock();
let x2 = ~x.clone();
let result: result::Result<(),()> = do task::try |move x2| {
let result: result::Result<(),()> = do task::try || {
do lock_rwlock_in_mode(x2, mode1) {
fail!();
}
@ -1332,7 +1332,7 @@ mod tests {
let x = ~RWlock();
let y = ~RWlock();
do x.write_downgrade |xwrite| {
let mut xopt = Some(move xwrite);
let mut xopt = Some(xwrite);
do y.write_downgrade |_ywrite| {
y.downgrade(option::swap_unwrap(&mut xopt));
error!("oops, y.downgrade(x) should have failed!");

View file

@ -50,11 +50,11 @@ pub impl<T> TaskPool<T> {
let (port, chan) = pipes::stream::<Msg<T>>();
let init_fn = init_fn_factory();
let task_body: ~fn() = |move port, move init_fn| {
let task_body: ~fn() = || {
let local_data = init_fn(i);
loop {
match port.recv() {
Execute(move f) => f(&local_data),
Execute(f) => f(&local_data),
Quit => break
}
}
@ -64,23 +64,23 @@ pub impl<T> TaskPool<T> {
match opt_sched_mode {
None => {
// Run on this scheduler.
task::spawn(move task_body);
task::spawn(task_body);
}
Some(sched_mode) => {
task::task().sched_mode(sched_mode).spawn(move task_body);
task::task().sched_mode(sched_mode).spawn(task_body);
}
}
move chan
chan
};
return TaskPool { channels: move channels, next_index: 0 };
return TaskPool { channels: channels, next_index: 0 };
}
/// Executes the function `f` on a task in the pool. The function
/// receives a reference to the local data returned by the `init_fn`.
fn execute(&self, f: ~fn(&T)) {
self.channels[self.next_index].send(Execute(move f));
self.channels[self.next_index].send(Execute(f));
self.next_index += 1;
if self.next_index == self.channels.len() { self.next_index = 0; }
}
@ -90,9 +90,9 @@ pub impl<T> TaskPool<T> {
fn test_task_pool() {
let f: ~fn() -> ~fn(uint) -> uint = || {
let g: ~fn(uint) -> uint = |i| i;
move g
g
};
let pool = TaskPool::new(4, Some(SingleThreaded), move f);
let pool = TaskPool::new(4, Some(SingleThreaded), f);
for 8.times {
pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i)));
}

View file

@ -120,8 +120,8 @@ pub struct TestDescAndFn {
pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) {
let opts =
match parse_opts(args) {
either::Left(move o) => o,
either::Right(move m) => fail!(m)
either::Left(o) => o,
either::Right(m) => fail!(m)
};
if !run_tests_console(&opts, tests) { fail!(~"Some tests failed"); }
}
@ -173,8 +173,8 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
getopts::optopt(~"logfile")];
let matches =
match getopts::getopts(args_, opts) {
Ok(move m) => m,
Err(move f) => return either::Right(getopts::fail_str(f))
Ok(m) => m,
Err(f) => return either::Right(getopts::fail_str(f))
};
let filter =
@ -260,7 +260,7 @@ pub fn run_tests_console(opts: &TestOpts,
st.failed += 1;
write_failed(st.out, st.use_color);
st.out.write_line(~"");
st.failures.push(move test);
st.failures.push(test);
}
TrIgnored => {
st.ignored += 1;
@ -410,7 +410,7 @@ fn should_sort_failures_before_printing_them() {
mut failed: 0u,
mut ignored: 0u,
mut benchmarked: 0u,
mut failures: ~[move test_b, move test_a]
mut failures: ~[test_b, test_a]
};
print_failures(st);
@ -486,7 +486,7 @@ fn run_tests(opts: &TestOpts,
callback(TeWait(copy b.desc));
run_test(!opts.run_benchmarks, b, ch.clone());
let (test, result) = p.recv();
callback(TeResult(move test, result));
callback(TeResult(test, result));
}
}
@ -514,7 +514,7 @@ pub fn filter_tests(
// Remove tests that don't match the test filter
filtered = if opts.filter.is_none() {
move filtered
filtered
} else {
let filter_str =
match opts.filter {
@ -534,7 +534,7 @@ pub fn filter_tests(
// Maybe pull out the ignored test and unignore them
filtered = if !opts.run_ignored {
move filtered
filtered
} else {
fn filter(test: TestDescAndFn) -> Option<TestDescAndFn> {
if test.desc.ignore {
@ -556,7 +556,7 @@ pub fn filter_tests(
}
sort::quick_sort(filtered, lteq);
move filtered
filtered
}
struct TestFuture {
@ -582,9 +582,9 @@ pub fn run_test(force_ignore: bool,
do task::spawn {
let mut result_future = None; // task::future_result(builder);
task::task().unlinked().future_result(|+r| {
result_future = Some(move r);
result_future = Some(r);
}).spawn(testfn_cell.take());
let task_result = option::unwrap(move result_future).recv();
let task_result = option::unwrap(result_future).recv();
let test_result = calc_result(&desc,
task_result == task::Success);
monitor_ch.send((desc, test_result));
@ -965,9 +965,9 @@ mod tests {
},
testfn: DynTestFn(copy testfn),
};
tests.push(move test);
tests.push(test);
}
move tests
tests
};
let filtered = filter_tests(&opts, tests);
@ -980,7 +980,7 @@ mod tests {
~"test::parse_ignored_flag",
~"test::sort_tests"];
let pairs = vec::zip(expected, move filtered);
let pairs = vec::zip(expected, filtered);
for vec::each(pairs) |p| {
match *p {

View file

@ -170,7 +170,7 @@ pub fn at_utc(clock: Timespec) -> Tm {
let mut Timespec { sec, nsec } = clock;
let mut tm = empty_tm();
rustrt::rust_gmtime(sec, nsec, tm);
move tm
tm
}
}
@ -185,7 +185,7 @@ pub fn at(clock: Timespec) -> Tm {
let mut Timespec { sec, nsec } = clock;
let mut tm = empty_tm();
rustrt::rust_localtime(sec, nsec, tm);
move tm
tm
}
}
@ -205,7 +205,7 @@ pub pure fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
pub pure fn strftime(format: &str, tm: &Tm) -> ~str {
// unsafe only because do_strftime is annoying to make pure
// (it does IO with a str_reader)
move unsafe { do_strftime(format, tm) }
unsafe { do_strftime(format, tm) }
}
impl Tm {
@ -240,7 +240,7 @@ impl Tm {
/// Formats the time according to the format string.
pure fn strftime(&self, format: &str) -> ~str {
move strftime(format, self)
strftime(format, self)
}
/**
@ -689,7 +689,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
'%' => {
match parse_type(s, pos, rdr.read_char(), &mut tm) {
Ok(next) => pos = next,
Err(move e) => { result = Err(move e); break; }
Err(e) => { result = Err(e); break; }
}
},
c => {
@ -714,7 +714,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
tm_zone: copy tm.tm_zone,
tm_nsec: tm.tm_nsec,
})
} else { move result }
} else { result }
}
}
@ -882,7 +882,7 @@ priv fn do_strftime(format: &str, tm: &Tm) -> ~str {
}
}
move buf
buf
}
#[cfg(test)]

View file

@ -98,7 +98,7 @@ fn get_monitor_task_gl() -> IoTask {
fn spawn_loop() -> IoTask {
let builder = do task().add_wrapper |task_body| {
fn~(move task_body) {
fn~() {
// The I/O loop task also needs to be weak so it doesn't keep
// the runtime alive
unsafe {
@ -116,7 +116,7 @@ fn spawn_loop() -> IoTask {
}
};
let builder = builder.unlinked();
spawn_iotask(move builder)
spawn_iotask(builder)
}
#[cfg(test)]

View file

@ -78,7 +78,7 @@ pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask {
*/
pub unsafe fn interact(iotask: &IoTask,
cb: fn~(*c_void)) {
send_msg(iotask, Interaction(move cb));
send_msg(iotask, Interaction(cb));
}
/**
@ -150,7 +150,7 @@ struct IoTaskLoopData {
fn send_msg(iotask: &IoTask,
msg: IoTaskMsg) {
iotask.op_chan.send(move msg);
iotask.op_chan.send(msg);
unsafe {
ll::async_send(iotask.async_handle);
}

View file

@ -1252,7 +1252,6 @@ pub mod test {
get_data_for_uv_handle(stream as *libc::c_void)
as *request_wrapper;
let buf_base = get_base_from_buf(buf);
let buf_len = get_len_from_buf(buf);
let bytes = vec::from_buf(buf_base, nread as uint);
let read_chan = (*client_data).read_chan.clone();
let msg_from_server = str::from_bytes(bytes);

View file

@ -235,7 +235,7 @@ fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
do io::with_str_reader(s) |rdr| {
let j = result::unwrap(json::from_reader(rdr));
Decodable::decode(&json::Decoder(move j))
Decodable::decode(&json::Decoder(j))
}
}
@ -323,20 +323,20 @@ impl TPrep for @Mut<Prep> {
Decodable<json::Decoder>>(&self,
blk: ~fn(&Exec) -> T) -> Work<T> {
let mut bo = Some(move blk);
let mut bo = Some(blk);
do self.borrow_imm |p| {
let cached = do p.ctxt.db.borrow_mut |db| {
db.prepare(p.fn_name, &p.declared_inputs)
};
match move cached {
match cached {
Some((ref disc_in, ref disc_out, ref res))
if self.all_fresh("declared input",
&p.declared_inputs) &&
self.all_fresh("discovered input", disc_in) &&
self.all_fresh("discovered output", disc_out) => {
Work::new(*self, move Left(json_decode(*res)))
Work::new(*self, Left(json_decode(*res)))
}
_ => {
@ -344,16 +344,16 @@ impl TPrep for @Mut<Prep> {
let mut blk = None;
blk <-> bo;
let blk = blk.unwrap();
let chan = ~mut Some(move chan);
do task::spawn |move blk, move chan| {
let chan = ~mut Some(chan);
do task::spawn || {
let exe = Exec{discovered_inputs: LinearMap::new(),
discovered_outputs: LinearMap::new()};
let chan = option::swap_unwrap(&mut *chan);
let v = blk(&exe);
send_one(move chan, (move exe, move v));
send_one(chan, (exe, v));
}
Work::new(*self, move Right(move port))
Work::new(*self, Right(port))
}
}
}
@ -365,7 +365,7 @@ impl<T:Owned
Decodable<json::Decoder>>
Work<T> {
static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
move Work { prep: p, res: Some(move e) }
Work { prep: p, res: Some(e) }
}
}
@ -374,18 +374,18 @@ fn unwrap<T:Owned
Encodable<json::Encoder>
Decodable<json::Decoder>>(w: Work<T>) -> T {
let mut ww = move w;
let mut ww = w;
let mut s = None;
ww.res <-> s;
match move s {
match s {
None => fail!(),
Some(Left(move v)) => move v,
Some(Right(move port)) => {
Some(Left(v)) => v,
Some(Right(port)) => {
let (exe, v) = match recv(move port) {
oneshot::send(move data) => move data
let (exe, v) = match recv(port) {
oneshot::send(data) => data
};
let s = json_encode(&v);
@ -399,7 +399,7 @@ fn unwrap<T:Owned
s);
}
}
move v
v
}
}
}
@ -425,9 +425,9 @@ fn test() {
do prep.exec |_exe| {
let out = Path("foo.o");
run::run_program("gcc", [~"foo.c", ~"-o", out.to_str()]);
move out.to_str()
out.to_str()
}
};
let s = unwrap(move w);
let s = unwrap(w);
io::println(s);
}