Skip to content

Commit 5912b14

Browse files
committed
libcore: Get rid of move.
1 parent 78f3e0d commit 5912b14

30 files changed

+358
-362
lines changed

src/libcore/at_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ pub mod raw {
229229
(**repr).unboxed.fill += sys::size_of::<T>();
230230
let p = addr_of(&((**repr).unboxed.data));
231231
let p = ptr::offset(p, fill) as *mut T;
232-
rusti::move_val_init(&mut(*p), move initval);
232+
rusti::move_val_init(&mut(*p), initval);
233233
}
234234

235235
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {
236236
reserve_at_least(&mut *v, v.len() + 1u);
237-
push_fast(v, move initval);
237+
push_fast(v, initval);
238238
}
239239

240240
/**

src/libcore/cast.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U {
2929
* reinterpret_cast on pointer types.
3030
*/
3131
#[inline(always)]
32-
pub unsafe fn forget<T>(thing: T) { rusti::forget(move thing); }
32+
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }
3333

3434
/**
3535
* Force-increment the reference count on a shared box. If used
3636
* carelessly, this can leak the box. Use this in conjunction with transmute
3737
* and/or reinterpret_cast when such calls would otherwise scramble a box's
3838
* reference count
3939
*/
40-
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(move t); }
40+
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
4141

4242
/**
4343
* Transform a value of one type into a value of another type.
@@ -50,23 +50,23 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(move t); }
5050
#[inline(always)]
5151
pub unsafe fn transmute<L, G>(thing: L) -> G {
5252
let newthing: G = reinterpret_cast(&thing);
53-
forget(move thing);
54-
move newthing
53+
forget(thing);
54+
newthing
5555
}
5656

5757
/// Coerce an immutable reference to be mutable.
5858
#[inline(always)]
59-
pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(move ptr) }
59+
pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(ptr) }
6060

6161
/// Coerce a mutable reference to be immutable.
6262
#[inline(always)]
6363
pub unsafe fn transmute_immut<T>(ptr: &a/mut T) -> &a/T {
64-
transmute(move ptr)
64+
transmute(ptr)
6565
}
6666

6767
/// Coerce a borrowed pointer to have an arbitrary associated region.
6868
#[inline(always)]
69-
pub unsafe fn transmute_region<T>(ptr: &a/T) -> &b/T { transmute(move ptr) }
69+
pub unsafe fn transmute_region<T>(ptr: &a/T) -> &b/T { transmute(ptr) }
7070

7171
/// Coerce an immutable reference to be mutable.
7272
#[inline(always)]
@@ -83,7 +83,7 @@ pub unsafe fn transmute_immut_unsafe<T>(ptr: *const T) -> *T {
8383
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
8484
#[inline(always)]
8585
pub unsafe fn transmute_mut_region<T>(ptr: &a/mut T) -> &b/mut T {
86-
transmute(move ptr)
86+
transmute(ptr)
8787
}
8888

8989
/// Transforms lifetime of the second pointer to match the first.
@@ -132,9 +132,9 @@ pub mod tests {
132132
use managed::raw::BoxRepr;
133133
unsafe {
134134
let x = @100u8;
135-
let x: *BoxRepr = transmute(move x);
135+
let x: *BoxRepr = transmute(x);
136136
assert (*x).data == 100;
137-
let _x: @int = transmute(move x);
137+
let _x: @int = transmute(x);
138138
}
139139
}
140140

src/libcore/dlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<T: Copy> DList<T> {
493493
v[index] = *data;
494494
}
495495
}
496-
move v
496+
v
497497
}
498498
}
499499

src/libcore/dvec.rs

+34-34
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ pub pure fn DVec<A>() -> DVec<A> {
6767

6868
/// Creates a new dvec with a single element
6969
pub pure fn from_elem<A>(e: A) -> DVec<A> {
70-
DVec {mut data: ~[move e]}
70+
DVec {mut data: ~[e]}
7171
}
7272

7373
/// Creates a new dvec with the contents of a vector
7474
pub pure fn from_vec<A>(v: ~[A]) -> DVec<A> {
75-
DVec {mut data: move v}
75+
DVec {mut data: v}
7676
}
7777

7878
/// Consumes the vector and returns its contents
7979
pub pure fn unwrap<A>(d: DVec<A>) -> ~[A] {
80-
let DVec {data: v} = move d;
81-
move v
80+
let DVec {data: v} = d;
81+
v
8282
}
8383

8484
priv impl<A> DVec<A> {
@@ -99,14 +99,14 @@ priv impl<A> DVec<A> {
9999
data <-> self.data;
100100
let data_ptr: *() = cast::reinterpret_cast(&data);
101101
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
102-
return f(move data);
102+
return f(data);
103103
}
104104
}
105105
106106
#[inline(always)]
107107
fn give_back(data: ~[A]) {
108108
unsafe {
109-
self.data = move data;
109+
self.data = data;
110110
}
111111
}
112112
@@ -130,7 +130,7 @@ impl<A> DVec<A> {
130130
*/
131131
#[inline(always)]
132132
fn swap(f: &fn(v: ~[A]) -> ~[A]) {
133-
self.check_out(|v| self.give_back(f(move v)))
133+
self.check_out(|v| self.give_back(f(v)))
134134
}
135135
136136
/**
@@ -141,7 +141,7 @@ impl<A> DVec<A> {
141141
#[inline(always)]
142142
fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) {
143143
do self.swap |v| {
144-
vec::cast_from_mut(f(vec::cast_to_mut(move v)))
144+
vec::cast_from_mut(f(vec::cast_to_mut(v)))
145145
}
146146
}
147147
@@ -156,16 +156,16 @@ impl<A> DVec<A> {
156156
#[inline(always)]
157157
fn set(w: ~[A]) {
158158
self.check_not_borrowed();
159-
self.data = move w;
159+
self.data = w;
160160
}
161161
162162
/// Remove and return the last element
163163
fn pop() -> A {
164164
do self.check_out |v| {
165-
let mut v = move v;
165+
let mut v = v;
166166
let result = v.pop();
167-
self.give_back(move v);
168-
move result
167+
self.give_back(v);
168+
result
169169
}
170170
}
171171
@@ -176,53 +176,53 @@ impl<A> DVec<A> {
176176
data <-> self.data;
177177
let data_ptr: *() = cast::reinterpret_cast(&data);
178178
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
179-
self.data = move ~[move t];
180-
self.data.push_all_move(move data);
179+
self.data = ~[t];
180+
self.data.push_all_move(data);
181181
}
182182
}
183183
184184
/// Append a single item to the end of the list
185185
#[inline(always)]
186186
fn push(t: A) {
187187
self.check_not_borrowed();
188-
self.data.push(move t);
188+
self.data.push(t);
189189
}
190190
191191
/// Remove and return the first element
192192
fn shift() -> A {
193193
do self.check_out |v| {
194-
let mut v = move v;
194+
let mut v = v;
195195
let result = v.shift();
196-
self.give_back(move v);
197-
move result
196+
self.give_back(v);
197+
result
198198
}
199199
}
200200
201201
/// Reverse the elements in the list, in place
202202
fn reverse() {
203203
do self.check_out |v| {
204-
let mut v = move v;
204+
let mut v = v;
205205
vec::reverse(v);
206-
self.give_back(move v);
206+
self.give_back(v);
207207
}
208208
}
209209
210210
/// Gives access to the vector as a slice with immutable contents
211211
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
212212
do self.check_out |v| {
213213
let result = op(v);
214-
self.give_back(move v);
215-
move result
214+
self.give_back(v);
215+
result
216216
}
217217
}
218218
219219
/// Gives access to the vector as a slice with mutable contents
220220
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
221221
do self.check_out |v| {
222-
let mut v = move v;
222+
let mut v = v;
223223
let result = op(v);
224-
self.give_back(move v);
225-
move result
224+
self.give_back(v);
225+
result
226226
}
227227
}
228228
}
@@ -240,15 +240,15 @@ impl<A: Copy> DVec<A> {
240240
/// Appends elements from `from_idx` to `to_idx` (exclusive)
241241
fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
242242
do self.swap |v| {
243-
let mut v = move v;
243+
let mut v = v;
244244
let new_len = vec::len(v) + to_idx - from_idx;
245245
vec::reserve(&mut v, new_len);
246246
let mut i = from_idx;
247247
while i < to_idx {
248248
v.push(ts[i]);
249249
i += 1u;
250250
}
251-
move v
251+
v
252252
}
253253
}
254254
@@ -265,7 +265,7 @@ impl<A: Copy> DVec<A> {
265265
none { v }
266266
Some(h) {
267267
let len = v.len() + h;
268-
let mut v = move v;
268+
let mut v = v;
269269
vec::reserve(v, len);
270270
v
271271
}
@@ -286,8 +286,8 @@ impl<A: Copy> DVec<A> {
286286
unsafe {
287287
do self.check_out |v| {
288288
let w = copy v;
289-
self.give_back(move v);
290-
move w
289+
self.give_back(v);
290+
w
291291
}
292292
}
293293
}
@@ -312,9 +312,9 @@ impl<A: Copy> DVec<A> {
312312
*/
313313
fn grow_set_elt(idx: uint, initval: &A, val: A) {
314314
do self.swap |v| {
315-
let mut v = move v;
315+
let mut v = v;
316316
v.grow_set(idx, initval, val);
317-
move v
317+
v
318318
}
319319
}
320320
@@ -340,7 +340,7 @@ impl<A: Copy> DVec<A> {
340340
for vec::rev_each(v) |e| {
341341
if !f(e) { break; }
342342
}
343-
move v
343+
v
344344
}
345345
}
346346

@@ -353,7 +353,7 @@ impl<A: Copy> DVec<A> {
353353
for vec::rev_eachi(v) |i, e| {
354354
if !f(i, e) { break; }
355355
}
356-
move v
356+
v
357357
}
358358
}
359359
}

src/libcore/either.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>])
8484
Right(r) => rights.push(r)
8585
}
8686
}
87-
return (move lefts, move rights);
87+
return (lefts, rights);
8888
}
8989

9090
#[inline(always)]
@@ -131,8 +131,8 @@ pub pure fn is_right<T, U>(eith: &Either<T, U>) -> bool {
131131
pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
132132
//! Retrieves the value in the left branch. Fails if the either is Right.
133133
134-
match move eith {
135-
Left(move x) => move x,
134+
match eith {
135+
Left(x) => x,
136136
Right(_) => fail!(~"either::unwrap_left Right")
137137
}
138138
}
@@ -141,8 +141,8 @@ pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
141141
pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
142142
//! Retrieves the value in the right branch. Fails if the either is Left.
143143
144-
match move eith {
145-
Right(move x) => move x,
144+
match eith {
145+
Right(x) => x,
146146
Left(_) => fail!(~"either::unwrap_right Left")
147147
}
148148
}

0 commit comments

Comments
 (0)