提交 5912b144 编写于 作者: L Luqman Aden 提交者: Luqman Aden

libcore: Get rid of `move`.

上级 78f3e0da
......@@ -229,12 +229,12 @@ pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) {
(**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);
}
/**
......
......@@ -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 reinterpret_cast<T, U>(src: &T) -> U {
* 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 reinterpret_cast<T, U>(src: &T) -> U {
#[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 fn test_transmute() {
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);
}
}
......
......@@ -493,7 +493,7 @@ fn pop_tail(@mut self) -> Option<T> {
v[index] = *data;
}
}
move v
v
}
}
......
......@@ -67,18 +67,18 @@ pub struct 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 @@ fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B {
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 @@ fn reserve(count: uint) {
*/
#[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 @@ fn swap(f: &fn(v: ~[A]) -> ~[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 @@ fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut 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 @@ fn unshift(t: 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 @@ fn unshift(t: 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 @@ fn reverse() {
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 @@ fn push_all(ts: &[const 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 @@ fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
v.push(ts[i]);
i += 1u;
}
move v
v
}
}
......@@ -265,7 +265,7 @@ fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
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 @@ fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
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 @@ fn set_elt(idx: uint, a: 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 @@ fn rev_each(f: fn(v: &A) -> bool) {
for vec::rev_each(v) |e| {
if !f(e) { break; }
}
move v
v
}
}
......@@ -353,7 +353,7 @@ fn rev_eachi(f: fn(uint, v: &A) -> bool) {
for vec::rev_eachi(v) |i, e| {
if !f(i, e) { break; }
}
move v
v
}
}
}
......
......@@ -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 fn partition<T, U>(eithers: ~[Either<T, U>])
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 fn partition<T, U>(eithers: ~[Either<T, U>])
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")
}
}
......
......@@ -510,7 +510,7 @@ pub struct Conv {
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 struct Conv {
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 struct Conv {
}
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 struct Conv {
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 struct Conv {
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 struct Conv {
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 struct Conv {
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) {
......
......@@ -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
}
}
}
......
......@@ -183,7 +183,7 @@ fn SipState(key0: u64, key1: u64) -> SipState {
mut ntail : 0u,
};
(&state).reset();
move state
state
}
......@@ -352,7 +352,7 @@ fn result_str() -> ~str {
for vec::each(r) |b| {
s += uint::to_str_radix(*b as uint, 16u);
}
move s
s
}
#[inline(always)]
......@@ -447,7 +447,7 @@ fn to_hex_str(r: &[u8 * 8]) -> ~str {
for vec::each(*r) |b| {
s += uint::to_str_radix(*b as uint, 16u);
}
move s
s
}
while t < 64 {
......
......@@ -178,7 +178,7 @@ fn read_bytes(&self,len: uint) -> ~[u8] {
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 @@ fn chars_from_bytes<T: Reader>(bytes: &~[u8], chars: &mut ~[char])
bytes = vec::slice(bytes, offset, bytes.len());
}
}
move chars
chars
}
fn read_char(&self) -> char {
......@@ -273,7 +273,7 @@ fn read_c_str(&self) -> ~str {
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 @@ fn write(&self, v: &[const u8]) {
self.pos += v_len;
move bytes
bytes
}
}
fn seek(&self, offset: int, whence: SeekStyle) {
......@@ -1035,7 +1035,7 @@ fn get_type(&self) -> WriterType { File }
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 @@ fn get_type(&self) -> WriterType { File }
}
assert str::is_utf8(v);
unsafe { move ::cast::transmute(move v) }
unsafe { ::cast::transmute(v) }
}
// Utility functions
......@@ -1126,7 +1126,7 @@ fn finalize(&self) {
pub fn Res<t: Copy>(arg: Arg<t>) -> Res<t>{
Res {
arg: move arg
arg: arg
}
}
......
......@@ -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> {
......
......@@ -25,7 +25,7 @@ mod inst {
unsafe {
do self.swap |v| {
v.each(f);
move v
v
}
}
}
......
......@@ -154,11 +154,11 @@ pub trait Buildable<A> {
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 trait Buildable<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 trait Buildable<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")
}
}
......
......@@ -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> {
......
......@@ -33,8 +33,8 @@
}
// 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 enum 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 enum 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 enum 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 enum Option<T> {
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 enum Option<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 R(i: @mut int) -> R {
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;
}
......
......@@ -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 @@ fn make_rand_name() -> ~str {
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 @@ fn test_getenv_big() {
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 @@ fn test_env_getenv() {
// 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 @@ fn test_env_setenv() {
assert !vec::contains(e, &(copy n, ~"VALUE"));
e = env();
assert vec::contains(e, &(move n, ~"VALUE"));
assert vec::contains(e, &(n, ~"VALUE"));
}
#[test]
......
......@@ -245,7 +245,7 @@ fn stat(&self) -> Option<libc::stat> {
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 @@ fn lstat(&self) -> Option<libc::stat> {
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 @@ impl GenericPath for WindowsPath {
}
}
}
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
}
......
......@@ -101,7 +101,7 @@
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 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool {
*/
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 @@ struct DropState {
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 @@ struct DropState {
}
}
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 @@ fn finalize(&self) {
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 @@ fn reuse_buffer() -> BufferResource<Tbuffer> {
//error!("send reuse_buffer");
let mut tmp = None;
tmp <-> self.buffer;
option::unwrap(move tmp)
option::unwrap(tmp)
}
}
......@@ -860,7 +860,7 @@ fn finalize(&self) {
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 @@ fn send(x: 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 @@ fn try_recv() -> Option<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 @@ fn try_recv() -> Option<T> {
}
}
ports <-> self.ports;
move result
result
}
fn recv() -> T {
......@@ -1178,29 +1178,29 @@ impl<T: Owned> Peekable<T> for PortSet<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 @@ fn try_send(self, data: T) -> bool { try_send_one(self, data) }
* 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 fn test_select2() {
c1.send(~"abc");
match (move p1, move p2).select() {
match (p1, p2).select() {
Right(_) => fail!(),
_ => ()
}
......@@ -1330,9 +1330,9 @@ pub fn test_select2() {
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 @@ fn test_peek_terminated() {
{
// Destroy the channel
let _chan = move chan;
let _chan = chan;
}
assert !port.peek();
......
......@@ -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 @@ struct DeathThroes<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 @@ struct DeathThroes<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 @@ struct DeathThroes<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 @@ struct DeathThroes<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 @@ struct DeathThroes<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 @@ unsafe fn with<U>(f: fn(x: &mut T) -> U) -> U {
(*rec).failed = true;
let result = f(&mut (*rec).data);
(*rec).failed = false;
move result
result
}
}
}
......@@ -401,10 +401,10 @@ unsafe fn with_imm<U>(f: fn(x: &T) -> U) -> U {
// 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 fn exclusive_arc() {
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 fn exclusive_poison() {
// 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 fn exclusive_poison() {
#[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 fn exclusive_unwrap_conflict() {
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 fn exclusive_unwrap_deadlock() {
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();
......
......@@ -273,7 +273,7 @@ fn gen_str(len: uint) -> ~str {
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 @@ fn weighted_vec<T:Copy>(v: &[Weighted<T>]) -> ~[T] {
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
......
......@@ -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> {
......
......@@ -200,8 +200,8 @@ fn visit_inner(inner: *TyDesc) -> bool {
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)
}
}
......
......@@ -125,9 +125,9 @@ pub enum Result<T, U> {
#[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 enum Result<T, U> {
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 fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[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")
}
}
......
......@@ -258,7 +258,7 @@ struct ProgRes {
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};
}
}
......
......@@ -216,7 +216,7 @@ pub fn synthesize_closure() {
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 fn synthesize_closure() {
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;
}
}
......
......@@ -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));
}
}
......@@ -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 @@ fn future_result(blk: fn(v: Port<TaskResult>)) -> 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 @@ fn sched_mode(mode: SchedMode) -> 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 @@ fn add_wrapper(wrapper: fn@(v: fn~()) -> fn~()) -> 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 @@ fn spawn(f: fn~()) {
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 @@ fn try<T: Owned>(f: fn~() -> T) -> Result<T,()> {
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_unlinked_sup_fail_down() {
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_unlinked_sup_fail_down() {
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 child_no(x: uint) -> fn~() {
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(());
}
......
......@@ -93,7 +93,7 @@
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 coalesce(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 iterate(ancestors: &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 with_parent_tg<U>(parent_group: &mut Option<TaskGroupArc>,
// 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 share_ancestors(ancestors: &mut AncestorList) -> AncestorList {
// 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 @@ fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc,
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 @@ fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc,
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;
......
......@@ -87,7 +87,7 @@ impl<A: ToStr> ToStr for ~[A] {
}
}
str::push_char(&mut acc, ']');
move acc
acc
}
}
}
......
......@@ -19,7 +19,7 @@
/// 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 @@ pub fn identity_crisis() {
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() {
......
......@@ -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)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册