Remove uses of binary move - <- - from tests and libraries
This commit is contained in:
parent
804c608f01
commit
11e92f37c1
@ -2,7 +2,7 @@
|
||||
|
||||
Idea: provide functions for 'exhaustive' and 'random' modification of vecs.
|
||||
|
||||
two functions, "return all edits" and "return a random edit" <--
|
||||
two functions, "return all edits" and "return a random edit" = move-
|
||||
leaning toward this model or two functions, "return the number of
|
||||
possible edits" and "return edit #n"
|
||||
|
||||
|
@ -72,7 +72,7 @@ pub fn from_vec<A>(v: ~[A]) -> DVec<A> {
|
||||
|
||||
/// Consumes the vector and returns its contents
|
||||
pub fn unwrap<A>(d: DVec<A>) -> ~[A] {
|
||||
let DVec_({data: v}) <- d;
|
||||
let DVec_({data: v}) = move d;
|
||||
move v
|
||||
}
|
||||
|
||||
@ -150,13 +150,13 @@ impl<A> DVec<A> {
|
||||
/// Overwrite the current contents
|
||||
fn set(w: ~[A]) {
|
||||
self.check_not_borrowed();
|
||||
self.data <- w;
|
||||
self.data = move w;
|
||||
}
|
||||
|
||||
/// Remove and return the last element
|
||||
fn pop() -> A {
|
||||
do self.check_out |v| {
|
||||
let mut v <- v;
|
||||
let mut v = move v;
|
||||
let result = v.pop();
|
||||
self.give_back(move v);
|
||||
move result
|
||||
@ -171,7 +171,7 @@ impl<A> DVec<A> {
|
||||
let data_ptr: *() = cast::reinterpret_cast(&data);
|
||||
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
|
||||
log(error, ~"a");
|
||||
self.data <- ~[move t];
|
||||
self.data = move ~[move t];
|
||||
self.data.push_all_move(move data);
|
||||
log(error, ~"b");
|
||||
}
|
||||
@ -235,7 +235,7 @@ impl<A: Copy> DVec<A> {
|
||||
/// Appends elements from `from_idx` to `to_idx` (exclusive)
|
||||
fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
|
||||
do self.swap |v| {
|
||||
let mut v <- v;
|
||||
let mut v = move v;
|
||||
let new_len = vec::len(v) + to_idx - from_idx;
|
||||
vec::reserve(&mut v, new_len);
|
||||
let mut i = from_idx;
|
||||
@ -260,7 +260,7 @@ impl<A: Copy> DVec<A> {
|
||||
none { v }
|
||||
Some(h) {
|
||||
let len = v.len() + h;
|
||||
let mut v <- v;
|
||||
let mut v = move v;
|
||||
vec::reserve(v, len);
|
||||
v
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ pub struct BytesWriter {
|
||||
impl BytesWriter: Writer {
|
||||
fn write(v: &[const u8]) {
|
||||
do self.bytes.swap |bytes| {
|
||||
let mut bytes <- bytes;
|
||||
let mut bytes = move bytes;
|
||||
let v_len = v.len();
|
||||
let bytes_len = bytes.len();
|
||||
|
||||
|
@ -128,7 +128,7 @@ pub pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
|
||||
pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B,
|
||||
blk: fn(&B, &A) -> B)
|
||||
-> B {
|
||||
let mut b <- b0;
|
||||
let mut b = move b0;
|
||||
for self.each |a| {
|
||||
b = blk(&b, a);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
|
||||
pub pure fn while_some<T>(x: Option<T>, blk: fn(v: T) -> Option<T>) {
|
||||
//! Applies a function zero or more times until the result is none.
|
||||
|
||||
let mut opt <- x;
|
||||
let mut opt = move x;
|
||||
while opt.is_some() {
|
||||
opt = blk(unwrap(move opt));
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ use option::unwrap;
|
||||
const SPIN_COUNT: uint = 0;
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
#[doc(hidden)]
|
||||
@ -363,7 +363,7 @@ pub fn send<T: Send, Tbuffer: Send>(p: SendPacketBuffered<T, Tbuffer>,
|
||||
let p = unsafe { &*p_ };
|
||||
assert ptr::addr_of(&(p.header)) == header;
|
||||
assert p.payload.is_none();
|
||||
p.payload <- Some(move payload);
|
||||
p.payload = move Some(move payload);
|
||||
let old_state = swap_state_rel(&mut p.header.state, Full);
|
||||
match old_state {
|
||||
Empty => {
|
||||
@ -708,7 +708,7 @@ pub fn select<T: Send, Tb: Send>(endpoints: ~[RecvPacketBuffered<T, Tb>])
|
||||
-> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>])
|
||||
{
|
||||
let ready = wait_many(endpoints.map(|p| p.header()));
|
||||
let mut remaining <- endpoints;
|
||||
let mut remaining = move endpoints;
|
||||
let port = remaining.swap_remove(ready);
|
||||
let result = try_recv(move port);
|
||||
(ready, move result, move remaining)
|
||||
|
@ -562,9 +562,9 @@ impl<T: Send> Exclusive<T> {
|
||||
|
||||
// FIXME(#3724) make this a by-move method on the exclusive
|
||||
pub fn unwrap_exclusive<T: Send>(arc: Exclusive<T>) -> T {
|
||||
let Exclusive { x: x } <- arc;
|
||||
let Exclusive { x: x } = move arc;
|
||||
let inner = unsafe { unwrap_shared_mutable_state(move x) };
|
||||
let ExData { data: data, _ } <- inner;
|
||||
let ExData { data: data, _ } = move inner;
|
||||
move data
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) {
|
||||
/// Concatenate two strings together
|
||||
#[inline(always)]
|
||||
pub pure fn append(lhs: ~str, rhs: &str) -> ~str {
|
||||
let mut v <- lhs;
|
||||
let mut v = move lhs;
|
||||
unsafe {
|
||||
push_str_no_overallocate(&mut v, rhs);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ use rt::rust_task;
|
||||
use rt::rust_closure;
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
|
||||
@ -168,10 +168,10 @@ fn each_ancestor(list: &mut AncestorList,
|
||||
if coalesce_this.is_some() {
|
||||
// Needed coalesce. Our next ancestor becomes our old
|
||||
// ancestor's next ancestor. ("next = old_next->next;")
|
||||
*list <- option::unwrap(move coalesce_this);
|
||||
*list = move option::unwrap(move coalesce_this);
|
||||
} else {
|
||||
// No coalesce; restore from tmp. ("next = old_next;")
|
||||
*list <- tmp_list;
|
||||
*list = move tmp_list;
|
||||
}
|
||||
return early_break;
|
||||
}
|
||||
@ -265,7 +265,7 @@ fn each_ancestor(list: &mut AncestorList,
|
||||
// If this trips, more likely the problem is 'blk' failed inside.
|
||||
let tmp_arc = option::swap_unwrap(parent_group);
|
||||
let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) };
|
||||
*parent_group <- Some(move tmp_arc);
|
||||
*parent_group = move Some(move tmp_arc);
|
||||
move result
|
||||
}
|
||||
}
|
||||
@ -480,7 +480,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
|
||||
if tmp.is_some() {
|
||||
let ancestor_arc = option::unwrap(move tmp);
|
||||
let result = ancestor_arc.clone();
|
||||
**ancestors <- Some(move ancestor_arc);
|
||||
**ancestors = move Some(move ancestor_arc);
|
||||
AncestorList(Some(move result))
|
||||
} else {
|
||||
AncestorList(None)
|
||||
|
@ -51,7 +51,7 @@ 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 <- src;
|
||||
let mut tmp = move src;
|
||||
swap(dest, &mut tmp);
|
||||
move tmp
|
||||
}
|
||||
|
@ -399,10 +399,10 @@ pub fn shift<T>(v: &mut ~[T]) -> T {
|
||||
let mut rr;
|
||||
{
|
||||
let vv = raw::to_ptr(vv);
|
||||
rr <- *vv;
|
||||
rr = move *vv;
|
||||
|
||||
for uint::range(1, ln) |i| {
|
||||
let r <- *ptr::offset(vv, i);
|
||||
let r = move *ptr::offset(vv, i);
|
||||
v.push(move r);
|
||||
}
|
||||
}
|
||||
@ -424,7 +424,7 @@ pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) unsafe {
|
||||
|
||||
do as_imm_buf(v) |p, ln| {
|
||||
for uint::range(0, ln) |i| {
|
||||
let x <- *ptr::offset(p, i);
|
||||
let x = move *ptr::offset(p, i);
|
||||
f(i, move x);
|
||||
}
|
||||
}
|
||||
@ -515,7 +515,7 @@ pub fn push_all_move<T>(v: &mut ~[T], rhs: ~[T]) {
|
||||
unsafe {
|
||||
do as_imm_buf(rhs) |p, len| {
|
||||
for uint::range(0, len) |i| {
|
||||
let x <- *ptr::offset(p, i);
|
||||
let x = move *ptr::offset(p, i);
|
||||
push(v, move x);
|
||||
}
|
||||
}
|
||||
@ -530,7 +530,7 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
|
||||
unsafe {
|
||||
// This loop is optimized out for non-drop types.
|
||||
for uint::range(newlen, oldlen) |i| {
|
||||
let _dropped <- *ptr::offset(p, i);
|
||||
let _dropped = move *ptr::offset(p, i);
|
||||
}
|
||||
raw::set_len(v, newlen);
|
||||
}
|
||||
@ -553,12 +553,12 @@ pub fn dedup<T: Eq>(v: &mut ~[T]) unsafe {
|
||||
// last_written < next_to_read < ln
|
||||
if *ptr::mut_offset(p, next_to_read) ==
|
||||
*ptr::mut_offset(p, last_written) {
|
||||
let _dropped <- *ptr::mut_offset(p, next_to_read);
|
||||
let _dropped = move *ptr::mut_offset(p, next_to_read);
|
||||
} else {
|
||||
last_written += 1;
|
||||
// last_written <= next_to_read < ln
|
||||
if next_to_read != last_written {
|
||||
*ptr::mut_offset(p, last_written) <-
|
||||
*ptr::mut_offset(p, last_written) = move
|
||||
*ptr::mut_offset(p, next_to_read);
|
||||
}
|
||||
}
|
||||
@ -575,7 +575,7 @@ pub fn dedup<T: Eq>(v: &mut ~[T]) unsafe {
|
||||
// Appending
|
||||
#[inline(always)]
|
||||
pub pure fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] {
|
||||
let mut v <- lhs;
|
||||
let mut v = move lhs;
|
||||
unsafe {
|
||||
v.push_all(rhs);
|
||||
}
|
||||
@ -584,7 +584,7 @@ pub pure fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] {
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
|
||||
let mut v <- lhs;
|
||||
let mut v = move lhs;
|
||||
unsafe { v.push(move x); }
|
||||
move v
|
||||
}
|
||||
@ -1052,9 +1052,9 @@ pub fn swap<T>(v: &[mut T], a: uint, b: uint) {
|
||||
|
||||
/// Reverse the order of elements in a vector, in place
|
||||
pub fn reverse<T>(v: &[mut T]) {
|
||||
let mut i: uint = 0u;
|
||||
let mut i: uint = 0;
|
||||
let ln = len::<T>(v);
|
||||
while i < ln / 2u { v[i] <-> v[ln - i - 1u]; i += 1u; }
|
||||
while i < ln / 2 { v[i] <-> v[ln - i - 1]; i += 1; }
|
||||
}
|
||||
|
||||
/// Returns a vector with the order of elements reversed
|
||||
|
@ -99,7 +99,7 @@ pub fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> {
|
||||
* guaranteed to deadlock.
|
||||
*/
|
||||
fn unwrap<T: Const Send>(rc: ARC<T>) -> T {
|
||||
let ARC { x: x } <- rc;
|
||||
let ARC { x: x } = move rc;
|
||||
unsafe { unwrap_shared_mutable_state(move x) }
|
||||
}
|
||||
|
||||
@ -192,9 +192,9 @@ impl<T: Send> &MutexARC<T> {
|
||||
*/
|
||||
// FIXME(#3724) make this a by-move method on the arc
|
||||
pub fn unwrap_mutex_arc<T: Send>(arc: MutexARC<T>) -> T {
|
||||
let MutexARC { x: x } <- arc;
|
||||
let MutexARC { x: x } = move arc;
|
||||
let inner = unsafe { unwrap_shared_mutable_state(move x) };
|
||||
let MutexARCInner { failed: failed, data: data, _ } <- inner;
|
||||
let MutexARCInner { failed: failed, data: data, _ } = move inner;
|
||||
if failed {
|
||||
fail ~"Can't unwrap poisoned MutexARC - another task failed inside!"
|
||||
}
|
||||
@ -347,7 +347,7 @@ impl<T: Const Send> &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)) <- token;
|
||||
let RWWriteMode((data, t, _poison)) = move token;
|
||||
// Let readers in
|
||||
let new_token = (&state.lock).downgrade(move t);
|
||||
// Whatever region the input reference had, it will be safe to use
|
||||
@ -370,9 +370,9 @@ impl<T: Const Send> &RWARC<T> {
|
||||
*/
|
||||
// FIXME(#3724) make this a by-move method on the arc
|
||||
pub fn unwrap_rw_arc<T: Const Send>(arc: RWARC<T>) -> T {
|
||||
let RWARC { x: x, _ } <- arc;
|
||||
let RWARC { x: x, _ } = move arc;
|
||||
let inner = unsafe { unwrap_shared_mutable_state(move x) };
|
||||
let RWARCInner { failed: failed, data: data, _ } <- inner;
|
||||
let RWARCInner { failed: failed, data: data, _ } = move inner;
|
||||
if failed {
|
||||
fail ~"Can't unwrap poisoned RWARC - another task failed inside!"
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ pub mod chained {
|
||||
entry.next = new_chains[idx];
|
||||
new_chains[idx] = Some(entry);
|
||||
}
|
||||
self.chains <- new_chains;
|
||||
self.chains = move new_chains;
|
||||
}
|
||||
|
||||
pure fn each_entry(blk: fn(@Entry<K,V>) -> bool) {
|
||||
|
@ -15,7 +15,7 @@ type Le<T> = pure fn(v1: &T, v2: &T) -> bool;
|
||||
pub fn merge_sort<T: Copy>(le: Le<T>, v: &[const T]) -> ~[T] {
|
||||
type Slice = (uint, uint);
|
||||
|
||||
return merge_sort_(le, v, (0u, len(v)));
|
||||
return merge_sort_(le, v, (0, len(v)));
|
||||
|
||||
fn merge_sort_<T: Copy>(le: Le<T>, v: &[const T], slice: Slice)
|
||||
-> ~[T] {
|
||||
@ -23,10 +23,10 @@ pub fn merge_sort<T: Copy>(le: Le<T>, v: &[const T]) -> ~[T] {
|
||||
let end = slice.second();
|
||||
|
||||
let v_len = end - begin;
|
||||
if v_len == 0u { return ~[]; }
|
||||
if v_len == 1u { return ~[v[begin]]; }
|
||||
if v_len == 0 { return ~[]; }
|
||||
if v_len == 1 { return ~[v[begin]]; }
|
||||
|
||||
let mid = v_len / 2u + begin;
|
||||
let mid = v_len / 2 + begin;
|
||||
let a = (begin, mid);
|
||||
let b = (mid, end);
|
||||
return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b));
|
||||
@ -35,14 +35,14 @@ pub fn merge_sort<T: Copy>(le: Le<T>, v: &[const T]) -> ~[T] {
|
||||
fn merge<T: Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
|
||||
let mut rs = vec::with_capacity(len(a) + len(b));
|
||||
let a_len = len(a);
|
||||
let mut a_ix = 0u;
|
||||
let mut a_ix = 0;
|
||||
let b_len = len(b);
|
||||
let mut b_ix = 0u;
|
||||
let mut b_ix = 0;
|
||||
while a_ix < a_len && b_ix < b_len {
|
||||
if le(&a[a_ix], &b[b_ix]) {
|
||||
rs.push(a[a_ix]);
|
||||
a_ix += 1u;
|
||||
} else { rs.push(b[b_ix]); b_ix += 1u; }
|
||||
a_ix += 1;
|
||||
} else { rs.push(b[b_ix]); b_ix += 1; }
|
||||
}
|
||||
rs = vec::append(rs, vec::slice(a, a_ix, a_len));
|
||||
rs = vec::append(rs, vec::slice(b, b_ix, b_len));
|
||||
@ -59,9 +59,9 @@ fn part<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
|
||||
while i < right {
|
||||
if compare_func(&arr[i], &pivot_value) {
|
||||
arr[i] <-> arr[storage_index];
|
||||
storage_index += 1u;
|
||||
storage_index += 1;
|
||||
}
|
||||
i += 1u;
|
||||
i += 1;
|
||||
}
|
||||
arr[storage_index] <-> arr[right];
|
||||
return storage_index;
|
||||
@ -70,13 +70,13 @@ fn part<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
|
||||
fn qsort<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
|
||||
right: uint) {
|
||||
if right > left {
|
||||
let pivot = (left + right) / 2u;
|
||||
let pivot = (left + right) / 2;
|
||||
let new_pivot = part::<T>(compare_func, arr, left, right, pivot);
|
||||
if new_pivot != 0u {
|
||||
if new_pivot != 0 {
|
||||
// Need to do this check before recursing due to overflow
|
||||
qsort::<T>(compare_func, arr, left, new_pivot - 1u);
|
||||
qsort::<T>(compare_func, arr, left, new_pivot - 1);
|
||||
}
|
||||
qsort::<T>(compare_func, arr, new_pivot + 1u, right);
|
||||
qsort::<T>(compare_func, arr, new_pivot + 1, right);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +87,8 @@ fn qsort<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
|
||||
* This is an unstable sort.
|
||||
*/
|
||||
pub fn quick_sort<T: Copy>(compare_func: Le<T>, arr: &[mut T]) {
|
||||
if len::<T>(arr) == 0u { return; }
|
||||
qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u);
|
||||
if len::<T>(arr) == 0 { return; }
|
||||
qsort::<T>(compare_func, arr, 0, len::<T>(arr) - 1);
|
||||
}
|
||||
|
||||
fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) {
|
||||
@ -167,11 +167,11 @@ mod test_qsort3 {
|
||||
fn check_sort(v1: &[mut int], v2: &[mut int]) {
|
||||
let len = vec::len::<int>(v1);
|
||||
quick_sort3::<int>(v1);
|
||||
let mut i = 0u;
|
||||
let mut i = 0;
|
||||
while i < len {
|
||||
log(debug, v2[i]);
|
||||
assert (v2[i] == v1[i]);
|
||||
i += 1u;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,11 +208,11 @@ mod test_qsort {
|
||||
let len = vec::len::<int>(v1);
|
||||
pure fn leual(a: &int, b: &int) -> bool { *a <= *b }
|
||||
quick_sort::<int>(leual, v1);
|
||||
let mut i = 0u;
|
||||
let mut i = 0;
|
||||
while i < len {
|
||||
log(debug, v2[i]);
|
||||
assert (v2[i] == v1[i]);
|
||||
i += 1u;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,11 +270,11 @@ mod tests {
|
||||
pub pure fn le(a: &int, b: &int) -> bool { *a <= *b }
|
||||
let f = le;
|
||||
let v3 = merge_sort::<int>(f, v1);
|
||||
let mut i = 0u;
|
||||
let mut i = 0;
|
||||
while i < len {
|
||||
log(debug, v3[i]);
|
||||
assert (v3[i] == v2[i]);
|
||||
i += 1u;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -768,7 +768,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_mutex_lock() {
|
||||
// Unsafely achieve shared state, and do the textbook
|
||||
// "load tmp <- ptr; inc tmp; store ptr <- tmp" dance.
|
||||
// "load tmp = move ptr; inc tmp; store ptr <- tmp" dance.
|
||||
let (c,p) = pipes::stream();
|
||||
let m = ~Mutex();
|
||||
let m2 = ~m.clone();
|
||||
|
@ -1,3 +1,4 @@
|
||||
// xfail-pretty
|
||||
// Microbenchmarks for various functions in core and std
|
||||
|
||||
extern mod std;
|
||||
|
@ -19,7 +19,7 @@ use io::WriterUtil;
|
||||
use pipes::{Port, Chan, SharedChan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
@ -15,7 +15,7 @@ use io::WriterUtil;
|
||||
use pipes::{Port, PortSet, Chan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
@ -41,8 +41,8 @@ fn thread_ring(i: uint,
|
||||
count: uint,
|
||||
+num_chan: pipe,
|
||||
+num_port: pipe) {
|
||||
let mut num_chan <- Some(move num_chan);
|
||||
let mut num_port <- Some(move num_port);
|
||||
let mut num_chan = move Some(move num_chan);
|
||||
let mut num_port = move Some(move num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0u, count) |j| {
|
||||
//error!("task %?, iter %?", i, j);
|
||||
|
@ -24,7 +24,7 @@ proto! ring (
|
||||
fn macros() {
|
||||
#macro[
|
||||
[#move_out[x],
|
||||
unsafe { let y <- *ptr::addr_of(&x); move y }]
|
||||
unsafe { let y = move *ptr::addr_of(&x); move y }]
|
||||
];
|
||||
}
|
||||
|
||||
@ -32,8 +32,8 @@ fn thread_ring(i: uint,
|
||||
count: uint,
|
||||
+num_chan: ring::client::num,
|
||||
+num_port: ring::server::num) {
|
||||
let mut num_chan <- Some(move num_chan);
|
||||
let mut num_port <- Some(move num_port);
|
||||
let mut num_chan = move Some(move num_chan);
|
||||
let mut num_port = move Some(move num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0, count) |j| {
|
||||
//error!("task %?, iter %?", i, j);
|
||||
|
@ -41,8 +41,8 @@ fn thread_ring(i: uint,
|
||||
count: uint,
|
||||
+num_chan: pipe,
|
||||
+num_port: pipe) {
|
||||
let mut num_chan <- Some(move num_chan);
|
||||
let mut num_port <- Some(move num_port);
|
||||
let mut num_chan = move Some(move num_chan);
|
||||
let mut num_port = move Some(move num_port);
|
||||
// Send/Receive lots of messages.
|
||||
for uint::range(0u, count) |j| {
|
||||
//error!("task %?, iter %?", i, j);
|
||||
|
@ -33,7 +33,7 @@ proto! pingpong_unbounded (
|
||||
|
||||
// This stuff should go in libcore::pipes
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { let t <- *ptr::addr_of(&($x)); move t }
|
||||
{ $x:expr } => { let t = move *ptr::addr_of(&($x)); move t }
|
||||
)
|
||||
|
||||
macro_rules! follow (
|
||||
|
@ -30,7 +30,7 @@ use cmp::Eq;
|
||||
use to_bytes::IterBytes;
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
trait word_reader {
|
||||
|
@ -4,5 +4,5 @@ fn main() {
|
||||
let mut x = @{x: 17, y: 2};
|
||||
let y = @{x: 5, y: 5};
|
||||
|
||||
force(|| x <- y );
|
||||
force(|| x = move y );
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ fn main() {
|
||||
let x = Some(~1);
|
||||
match x { //~ NOTE loan of immutable local variable granted here
|
||||
Some(ref _y) => {
|
||||
let _a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
let _a = move x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ fn main() {
|
||||
let x = Some(~1);
|
||||
match x {
|
||||
Some(ref y) => {
|
||||
let _b <- *y; //~ ERROR moving out of dereference of immutable & pointer
|
||||
let _b = move *y; //~ ERROR moving out of dereference of immutable & pointer
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn foo(x: *~int) -> ~int {
|
||||
let y <- *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
|
||||
let y = move *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
|
||||
return y;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ fn main() {
|
||||
// Create a cycle!
|
||||
match *x { //~ NOTE loan of immutable local variable granted here
|
||||
node(ref y) => {
|
||||
y.a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
y.a = move x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
empty => {}
|
||||
};
|
||||
|
@ -11,4 +11,4 @@ fn foo(i:int) -> foo {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { let x <- foo(10); let y = x; log(error, x); }
|
||||
fn main() { let x = move foo(10); let y = x; log(error, x); }
|
||||
|
@ -21,7 +21,7 @@ fn main() {
|
||||
let mut res = foo(x);
|
||||
|
||||
let mut v = ~[mut];
|
||||
v <- ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`)
|
||||
v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`)
|
||||
assert (v.len() == 2);
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,11 @@ fn main() {
|
||||
loop {
|
||||
loop {
|
||||
loop {
|
||||
x <- y; //~ ERROR use of moved variable
|
||||
// tjc: Not sure why it prints the same error twice
|
||||
x = move y; //~ ERROR use of moved variable
|
||||
//~^ NOTE move of variable occurred here
|
||||
//~^^ ERROR use of moved variable
|
||||
//~^^^ NOTE move of variable occurred here
|
||||
|
||||
copy x;
|
||||
}
|
||||
|
@ -4,8 +4,11 @@ fn main() {
|
||||
let mut x: int;
|
||||
loop {
|
||||
log(debug, y);
|
||||
while true { while true { while true { x <- y; copy x; } } }
|
||||
// tjc: not sure why it prints the same error twice
|
||||
while true { while true { while true { x = move y; copy x; } } }
|
||||
//~^ ERROR use of moved variable: `y`
|
||||
//~^^ NOTE move of variable occurred here
|
||||
//~^^^ ERROR use of moved variable: `y`
|
||||
//~^^^^ NOTE move of variable occurred here
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let x = @5;
|
||||
let y <- x; //~ NOTE move of variable occurred here
|
||||
let y = move x; //~ NOTE move of variable occurred here
|
||||
log(debug, *x); //~ ERROR use of moved variable: `x`
|
||||
copy y;
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ fn foo(i:int) -> foo {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { let x <- foo(10); let y = x; log(error, x); }
|
||||
fn main() { let x = move foo(10); let y = x; log(error, x); }
|
||||
|
@ -67,4 +67,12 @@ fn obsolete_fixed_length_vec() {
|
||||
//~^ ERROR obsolete syntax: fixed-length vector
|
||||
}
|
||||
|
||||
fn obsolete_moves() {
|
||||
let mut x = 0;
|
||||
let y <- x;
|
||||
//~^ ERROR obsolete syntax: initializer-by-move
|
||||
y <- x;
|
||||
//~^ ERROR obsolete syntax: binary move
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -6,7 +6,7 @@ struct r {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i <- ~r { b: true };
|
||||
let i = move ~r { b: true };
|
||||
let j = i;
|
||||
log(debug, i);
|
||||
}
|
@ -12,8 +12,8 @@ fn f<T>(+i: ~[T], +j: ~[T]) {
|
||||
fn main() {
|
||||
let i1 = @mut 0;
|
||||
let i2 = @mut 1;
|
||||
let r1 <- ~[~r { i: i1 }];
|
||||
let r2 <- ~[~r { i: i2 }];
|
||||
let r1 = move ~[~r { i: i1 }];
|
||||
let r2 = move ~[~r { i: i2 }];
|
||||
f(r1, r2);
|
||||
log(debug, (r2, *i1));
|
||||
log(debug, (r1, *i2));
|
||||
|
@ -9,8 +9,8 @@ struct r {
|
||||
|
||||
fn main() {
|
||||
// This can't make sense as it would copy the classes
|
||||
let i <- ~[r(0)];
|
||||
let j <- ~[r(1)];
|
||||
let i = move ~[r(0)];
|
||||
let j = move ~[r(1)];
|
||||
let k = i + j;
|
||||
log(debug, j);
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ class r {
|
||||
|
||||
fn main() {
|
||||
@0;
|
||||
let r <- r(0);
|
||||
let r = move r(0);
|
||||
}
|
@ -8,6 +8,6 @@ class r {
|
||||
|
||||
fn main() {
|
||||
@0;
|
||||
let r <- r(0);
|
||||
let r = move r(0);
|
||||
fail;
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
fn bar(x: *~int) -> ~int {
|
||||
unsafe {
|
||||
let y <- *x;
|
||||
let y = move *x;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ fn add_int(x: &mut ints, v: int) {
|
||||
let mut values = ~[];
|
||||
x.values <-> values;
|
||||
values.push(v);
|
||||
x.values <- values;
|
||||
x.values <-> values;
|
||||
}
|
||||
|
||||
fn iter_ints(x: &ints, f: fn(x: &int) -> bool) {
|
||||
|
@ -7,7 +7,7 @@ mod a1 {
|
||||
#[legacy_exports];
|
||||
//
|
||||
use a2::b1::*;
|
||||
// <-\
|
||||
// = move\
|
||||
export word_traveler; // |
|
||||
}
|
||||
// |
|
||||
@ -15,7 +15,7 @@ mod a1 {
|
||||
#[legacy_exports];
|
||||
// |
|
||||
use a2::b2::*;
|
||||
// <-\ -\ |
|
||||
// = move\ -\ |
|
||||
export word_traveler; // | | |
|
||||
} // | | |
|
||||
}
|
||||
@ -30,7 +30,7 @@ mod a2 {
|
||||
#[legacy_exports];
|
||||
// | | |
|
||||
use a1::b2::*;
|
||||
// | <-/ -/
|
||||
// | = move/ -/
|
||||
export word_traveler; // |
|
||||
}
|
||||
// |
|
||||
|
@ -15,7 +15,7 @@ fn r(i: @mut int) -> r {
|
||||
fn test_box() {
|
||||
let i = @mut 0;
|
||||
{
|
||||
let a <- @r(i);
|
||||
let a = move @r(i);
|
||||
}
|
||||
assert *i == 1;
|
||||
}
|
||||
@ -23,7 +23,7 @@ fn test_box() {
|
||||
fn test_rec() {
|
||||
let i = @mut 0;
|
||||
{
|
||||
let a <- {x: r(i)};
|
||||
let a = move {x: r(i)};
|
||||
}
|
||||
assert *i == 1;
|
||||
}
|
||||
@ -35,7 +35,7 @@ fn test_tag() {
|
||||
|
||||
let i = @mut 0;
|
||||
{
|
||||
let a <- t0(r(i));
|
||||
let a = move t0(r(i));
|
||||
}
|
||||
assert *i == 1;
|
||||
}
|
||||
@ -43,7 +43,7 @@ fn test_tag() {
|
||||
fn test_tup() {
|
||||
let i = @mut 0;
|
||||
{
|
||||
let a <- (r(i), 0);
|
||||
let a = move (r(i), 0);
|
||||
}
|
||||
assert *i == 1;
|
||||
}
|
||||
@ -51,7 +51,7 @@ fn test_tup() {
|
||||
fn test_unique() {
|
||||
let i = @mut 0;
|
||||
{
|
||||
let a <- ~r(i);
|
||||
let a = move ~r(i);
|
||||
}
|
||||
assert *i == 1;
|
||||
}
|
||||
@ -59,7 +59,7 @@ fn test_unique() {
|
||||
fn test_box_rec() {
|
||||
let i = @mut 0;
|
||||
{
|
||||
let a <- @{
|
||||
let a = move @{
|
||||
x: r(i)
|
||||
};
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ fn filter<A,IA:iterable<A>>(self: IA, prd: fn@(A) -> bool, blk: fn(A)) {
|
||||
}
|
||||
|
||||
fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
|
||||
let mut b <- b0;
|
||||
let mut b = move b0;
|
||||
do self.iter |a| {
|
||||
b <- blk(b, a);
|
||||
b = move blk(b, a);
|
||||
}
|
||||
move b
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ mod pipes {
|
||||
let p = p.unwrap();
|
||||
let p = unsafe { uniquify(p) };
|
||||
assert (*p).payload.is_none();
|
||||
(*p).payload <- Some(move payload);
|
||||
(*p).payload = move Some(move payload);
|
||||
let old_state = swap_state_rel(&mut (*p).state, full);
|
||||
match old_state {
|
||||
empty => {
|
||||
@ -205,7 +205,7 @@ mod pingpong {
|
||||
let addr : *pipes::send_packet<pong> = match p {
|
||||
ping(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
let liberated_value = move *addr;
|
||||
cast::forget(move p);
|
||||
move liberated_value
|
||||
}
|
||||
@ -214,7 +214,7 @@ mod pingpong {
|
||||
let addr : *pipes::send_packet<ping> = match p {
|
||||
pong(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value <- *addr;
|
||||
let liberated_value = move *addr;
|
||||
cast::forget(move p);
|
||||
move liberated_value
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
|
||||
let bar = foo;
|
||||
let mut y: ~{x: int, y: int, z: int};
|
||||
if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; }
|
||||
if x { y = move bar; } else { y = ~{x: 4, y: 5, z: 6}; }
|
||||
return y.y;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
|
||||
let bar = foo;
|
||||
let mut y: @{x: int, y: int, z: int};
|
||||
if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; }
|
||||
if x { y = move bar; } else { y = @{x: 4, y: 5, z: 6}; }
|
||||
return y.y;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
fn main() { let x = ~{x: 1, y: 2, z: 3}; let y <- x; assert (y.y == 2); }
|
||||
fn main() { let x = ~{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); }
|
||||
|
@ -1,3 +1,3 @@
|
||||
|
||||
|
||||
fn main() { let x = @{x: 1, y: 2, z: 3}; let y <- x; assert (y.y == 2); }
|
||||
fn main() { let x = @{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); }
|
||||
|
@ -3,7 +3,7 @@ extern mod std;
|
||||
fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
|
||||
let bar = foo;
|
||||
let mut y: ~{x: int, y: int, z: int};
|
||||
if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; }
|
||||
if x { y = move bar; } else { y = ~{x: 4, y: 5, z: 6}; }
|
||||
return y.y;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ extern mod std;
|
||||
fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
|
||||
let bar = foo;
|
||||
let mut y: @{x: int, y: int, z: int};
|
||||
if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; }
|
||||
if x { y = move bar; } else { y = @{x: 4, y: 5, z: 6}; }
|
||||
return y.y;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@ extern mod std;
|
||||
|
||||
fn test(foo: ~{a: int, b: int, c: int}) -> ~{a: int, b: int, c: int} {
|
||||
let foo = foo;
|
||||
let bar <- foo;
|
||||
let baz <- bar;
|
||||
let quux <- baz;
|
||||
let bar = move foo;
|
||||
let baz = move bar;
|
||||
let quux = move baz;
|
||||
return quux;
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@ extern mod std;
|
||||
|
||||
fn test(foo: @{a: int, b: int, c: int}) -> @{a: int, b: int, c: int} {
|
||||
let foo = foo;
|
||||
let bar <- foo;
|
||||
let baz <- bar;
|
||||
let quux <- baz;
|
||||
let bar = move foo;
|
||||
let baz = move bar;
|
||||
let quux = move baz;
|
||||
return quux;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,6 @@ fn main() {
|
||||
|
||||
let y: int = 42;
|
||||
let mut x: int;
|
||||
x <- y;
|
||||
x = move y;
|
||||
assert (x == 42);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ proto! bank (
|
||||
)
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
|
||||
{ $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
|
||||
)
|
||||
|
||||
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
|
||||
|
@ -15,7 +15,7 @@ fn shrinky_pointer(i: @@mut int) -> shrinky_pointer {
|
||||
|
||||
fn main() {
|
||||
let my_total = @@mut 10;
|
||||
{ let pt <- shrinky_pointer(my_total); assert (pt.look_at() == 10); }
|
||||
{ let pt = move shrinky_pointer(my_total); assert (pt.look_at() == 10); }
|
||||
log(error, fmt!("my_total = %d", **my_total));
|
||||
assert (**my_total == 9);
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ fn main() {
|
||||
let box = @mut 10;
|
||||
fn dec_box(&&i: @mut int) { *i -= 1; }
|
||||
|
||||
{ let _i <- finish({val: box, fin: dec_box}); }
|
||||
{ let _i = move finish({val: box, fin: dec_box}); }
|
||||
assert (*box == 9);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn main() {
|
||||
let i <- ~100;
|
||||
let i = move ~100;
|
||||
assert *i == 100;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
let i = ~100;
|
||||
let j <- i;
|
||||
let j = move i;
|
||||
assert *j == 100;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let i = ~100;
|
||||
let j = ~200;
|
||||
let j <- i;
|
||||
let j = move i;
|
||||
assert *j == 100;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
let mut i;
|
||||
i <- ~100;
|
||||
i = move ~100;
|
||||
assert *i == 100;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let i = ~100;
|
||||
let mut j;
|
||||
j <- i;
|
||||
j = move i;
|
||||
assert *j == 100;
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
fn id(x: bool) -> bool { x }
|
||||
|
||||
fn call_id() {
|
||||
let c <- fail;
|
||||
let c = move fail;
|
||||
id(c); //~ WARNING unreachable statement
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
fn id(x: bool) -> bool { x }
|
||||
|
||||
fn call_id() {
|
||||
let c <- fail;
|
||||
let c = move fail;
|
||||
id(c);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ fn complainer(c: comm::Chan<bool>) -> complainer {
|
||||
}
|
||||
|
||||
fn f(c: comm::Chan<bool>) {
|
||||
let _c <- complainer(c);
|
||||
let _c = move complainer(c);
|
||||
fail;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ fn complainer(c: @int) -> complainer {
|
||||
}
|
||||
|
||||
fn f() {
|
||||
let c <- complainer(@0);
|
||||
let c = move complainer(@0);
|
||||
fail;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ fn zombiejesus() {
|
||||
fn notsure() {
|
||||
let mut _x;
|
||||
let mut _y = (_x = 0) == (_x = 0);
|
||||
let mut _z = (_x <- 0) < (_x = 0);
|
||||
let mut _z = (_x = move 0) < (_x = 0);
|
||||
let _a = (_x += 0) == (_x = 0);
|
||||
let _b = (_y <-> _z) == (_y <-> _z);
|
||||
}
|
||||
@ -63,7 +63,7 @@ fn angrydome() {
|
||||
break; }
|
||||
}
|
||||
|
||||
fn evil_lincoln() { let evil <- debug!("lincoln"); }
|
||||
fn evil_lincoln() { let evil = move debug!("lincoln"); }
|
||||
|
||||
fn main() {
|
||||
strange();
|
||||
|
@ -5,7 +5,7 @@ fn main() {
|
||||
let mut x: int;
|
||||
while z < 50 {
|
||||
z += 1;
|
||||
while false { x <- y; y = z; }
|
||||
while false { x = move y; y = z; }
|
||||
log(debug, y);
|
||||
}
|
||||
assert (y == 42 && z == 50);
|
||||
|
Loading…
x
Reference in New Issue
Block a user