From 11e92f37c13194ad5c1f82a980e7f7ee02345801 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 23 Oct 2012 11:11:23 -0700 Subject: Remove uses of binary move - <- - from tests and libraries --- src/libstd/arc.rs | 12 ++++++------ src/libstd/map.rs | 2 +- src/libstd/sort.rs | 44 ++++++++++++++++++++++---------------------- src/libstd/sync.rs | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 9c793028a52..2f4c9a4eb06 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -99,7 +99,7 @@ pub fn clone(rc: &ARC) -> ARC { * guaranteed to deadlock. */ fn unwrap(rc: ARC) -> T { - let ARC { x: x } <- rc; + let ARC { x: x } = move rc; unsafe { unwrap_shared_mutable_state(move x) } } @@ -192,9 +192,9 @@ impl &MutexARC { */ // FIXME(#3724) make this a by-move method on the arc pub fn unwrap_mutex_arc(arc: MutexARC) -> 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 &RWARC { fn downgrade(token: RWWriteMode/&a) -> RWReadMode/&a { // 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 &RWARC { */ // FIXME(#3724) make this a by-move method on the arc pub fn unwrap_rw_arc(arc: RWARC) -> 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!" } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index e49f1abd02b..0ee7cb6fcf9 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -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) -> bool) { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 0b00da9f81d..8c8971b7eb7 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -15,7 +15,7 @@ type Le = pure fn(v1: &T, v2: &T) -> bool; pub fn merge_sort(le: Le, 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_(le: Le, v: &[const T], slice: Slice) -> ~[T] { @@ -23,10 +23,10 @@ pub fn merge_sort(le: Le, 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(le: Le, v: &[const T]) -> ~[T] { fn merge(le: Le, 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(compare_func: Le, 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(compare_func: Le, arr: &[mut T], left: uint, fn qsort(compare_func: Le, arr: &[mut T], left: uint, right: uint) { if right > left { - let pivot = (left + right) / 2u; + let pivot = (left + right) / 2; let new_pivot = part::(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::(compare_func, arr, left, new_pivot - 1u); + qsort::(compare_func, arr, left, new_pivot - 1); } - qsort::(compare_func, arr, new_pivot + 1u, right); + qsort::(compare_func, arr, new_pivot + 1, right); } } @@ -87,8 +87,8 @@ fn qsort(compare_func: Le, arr: &[mut T], left: uint, * This is an unstable sort. */ pub fn quick_sort(compare_func: Le, arr: &[mut T]) { - if len::(arr) == 0u { return; } - qsort::(compare_func, arr, 0u, len::(arr) - 1u); + if len::(arr) == 0 { return; } + qsort::(compare_func, arr, 0, len::(arr) - 1); } fn qsort3(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::(v1); quick_sort3::(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::(v1); pure fn leual(a: &int, b: &int) -> bool { *a <= *b } quick_sort::(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::(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; } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 73fc78a091a..43d1c9664a5 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -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(); -- cgit 1.4.1-3-g733a5