Skip to content

Commit c087886

Browse files
committed
Make moves explicit in arguments
1 parent 2c6c963 commit c087886

23 files changed

+113
-109
lines changed

src/libcore/at_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ mod unsafe {
177177
(**repr).fill += sys::size_of::<T>();
178178
let p = ptr::addr_of((**repr).data);
179179
let p = ptr::offset(p, fill) as *mut T;
180-
rusti::move_val_init(*p, initval);
180+
rusti::move_val_init(*p, move initval);
181181
}
182182

183183
unsafe fn push_slow<T>(&v: @[const T], +initval: T) {

src/libcore/comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn send<T: Send>(ch: Chan<T>, +data: T) {
181181
let res = rustrt::rust_port_id_send(p, data_ptr);
182182
if res != 0 unsafe {
183183
// Data sent successfully
184-
unsafe::forget(data);
184+
unsafe::forget(move data);
185185
}
186186
task::yield();
187187
}

src/libcore/dlist.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,27 +198,27 @@ impl<T> DList<T> {
198198
199199
/// Add data to the head of the list. O(1).
200200
fn push_head(+data: T) {
201-
self.add_head(self.new_link(data));
201+
self.add_head(self.new_link(move data));
202202
}
203203
/**
204204
* Add data to the head of the list, and get the new containing
205205
* node. O(1).
206206
*/
207207
fn push_head_n(+data: T) -> DListNode<T> {
208-
let mut nobe = self.new_link(data);
208+
let mut nobe = self.new_link(move data);
209209
self.add_head(nobe);
210210
option::get(nobe)
211211
}
212212
/// Add data to the tail of the list. O(1).
213213
fn push(+data: T) {
214-
self.add_tail(self.new_link(data));
214+
self.add_tail(self.new_link(move data));
215215
}
216216
/**
217217
* Add data to the tail of the list, and get the new containing
218218
* node. O(1).
219219
*/
220220
fn push_n(+data: T) -> DListNode<T> {
221-
let mut nobe = self.new_link(data);
221+
let mut nobe = self.new_link(move data);
222222
self.add_tail(nobe);
223223
option::get(nobe)
224224
}
@@ -227,7 +227,7 @@ impl<T> DList<T> {
227227
* O(1).
228228
*/
229229
fn insert_before(+data: T, neighbour: DListNode<T>) {
230-
self.insert_left(self.new_link(data), neighbour);
230+
self.insert_left(self.new_link(move data), neighbour);
231231
}
232232
/**
233233
* Insert an existing node in the middle of the list, left of the
@@ -242,7 +242,7 @@ impl<T> DList<T> {
242242
* and get its containing node. O(1).
243243
*/
244244
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
245-
let mut nobe = self.new_link(data);
245+
let mut nobe = self.new_link(move data);
246246
self.insert_left(nobe, neighbour);
247247
option::get(nobe)
248248
}
@@ -251,7 +251,7 @@ impl<T> DList<T> {
251251
* O(1).
252252
*/
253253
fn insert_after(+data: T, neighbour: DListNode<T>) {
254-
self.insert_right(neighbour, self.new_link(data));
254+
self.insert_right(neighbour, self.new_link(move data));
255255
}
256256
/**
257257
* Insert an existing node in the middle of the list, right of the
@@ -266,7 +266,7 @@ impl<T> DList<T> {
266266
* and get its containing node. O(1).
267267
*/
268268
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
269-
let mut nobe = self.new_link(data);
269+
let mut nobe = self.new_link(move data);
270270
self.insert_right(neighbour, nobe);
271271
option::get(nobe)
272272
}

src/libcore/dvec.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ priv impl<A> DVec<A> {
9595
data <-> self.data;
9696
let data_ptr: *() = unsafe::reinterpret_cast(&data);
9797
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
98-
return f(data);
98+
return f(move data);
9999
}
100100
}
101101

@@ -123,15 +123,15 @@ impl<A> DVec<A> {
123123
*/
124124
#[inline(always)]
125125
fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
126-
self.check_out(|v| self.give_back(f(v)))
126+
self.check_out(|v| self.give_back(f(move v)))
127127
}
128128

129129
/// Returns the number of elements currently in the dvec
130130
pure fn len() -> uint {
131131
unchecked {
132132
do self.check_out |v| {
133133
let l = v.len();
134-
self.give_back(v);
134+
self.give_back(move v);
135135
l
136136
}
137137
}
@@ -148,7 +148,7 @@ impl<A> DVec<A> {
148148
do self.check_out |v| {
149149
let mut v <- v;
150150
let result = vec::pop(v);
151-
self.give_back(v);
151+
self.give_back(move v);
152152
move result
153153
}
154154
}
@@ -162,7 +162,7 @@ impl<A> DVec<A> {
162162
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
163163
log(error, ~"a");
164164
self.data <- ~[mut move t];
165-
vec::push_all_move(self.data, data);
165+
vec::push_all_move(self.data, move data);
166166
log(error, ~"b");
167167
}
168168
}
@@ -187,15 +187,15 @@ impl<A> DVec<A> {
187187
fn reverse() {
188188
do self.check_out |v| {
189189
vec::reverse(v);
190-
self.give_back(v);
190+
self.give_back(move v);
191191
}
192192
}
193193
194194
/// Gives access to the vector as a slice with immutable contents
195195
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
196196
do self.check_out |v| {
197197
let result = op(v);
198-
self.give_back(v);
198+
self.give_back(move v);
199199
move result
200200
}
201201
}
@@ -204,7 +204,7 @@ impl<A> DVec<A> {
204204
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
205205
do self.check_out |v| {
206206
let result = op(v);
207-
self.give_back(v);
207+
self.give_back(move v);
208208
move result
209209
}
210210
}
@@ -269,7 +269,7 @@ impl<A: Copy> DVec<A> {
269269
unchecked {
270270
do self.check_out |v| {
271271
let w = vec::from_mut(copy v);
272-
self.give_back(v);
272+
self.give_back(move v);
273273
move w
274274
}
275275
}

src/libcore/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
9090
do from_fn |move port| {
9191
let mut port_ = None;
9292
port_ <-> *port;
93-
let port = option::unwrap(port_);
93+
let port = option::unwrap(move port_);
9494
match recv(move port) {
9595
future_pipe::completed(move data) => move data
9696
}

src/libcore/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+T) -> U) -> Option<U> {
7474
* As `map`, but consumes the option and gives `f` ownership to avoid
7575
* copying.
7676
*/
77-
if opt.is_some() { Some(f(option::unwrap(opt))) } else { None }
77+
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
7878
}
7979

8080
pure fn chain<T, U>(opt: Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
@@ -112,7 +112,7 @@ pure fn while_some<T>(+x: Option<T>, blk: fn(+T) -> Option<T>) {
112112
113113
let mut opt <- x;
114114
while opt.is_some() {
115-
opt = blk(unwrap(opt));
115+
opt = blk(unwrap(move opt));
116116
}
117117
}
118118

@@ -186,7 +186,7 @@ fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
186186
pure fn unwrap_expect<T>(+opt: Option<T>, reason: &str) -> T {
187187
//! As unwrap, but with a specified failure message.
188188
if opt.is_none() { fail reason.to_unique(); }
189-
unwrap(opt)
189+
unwrap(move opt)
190190
}
191191

192192
// Some of these should change to be &Option<T>, some should not. See below.

0 commit comments

Comments
 (0)