Skip to content

Commit 4cf51c2

Browse files
committed
libstd: Get rid of move.
1 parent 9727008 commit 4cf51c2

31 files changed

+357
-363
lines changed

src/libstd/arc.rs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct ARC<T> { x: SharedMutableState<T> }
8181

8282
/// Create an atomically reference counted wrapper.
8383
pub fn ARC<T: Const Owned>(data: T) -> ARC<T> {
84-
ARC { x: unsafe { shared_mutable_state(move data) } }
84+
ARC { x: unsafe { shared_mutable_state(data) } }
8585
}
8686

8787
/**
@@ -113,8 +113,8 @@ pub fn clone<T: Const Owned>(rc: &ARC<T>) -> ARC<T> {
113113
* guaranteed to deadlock.
114114
*/
115115
pub fn unwrap<T: Const Owned>(rc: ARC<T>) -> T {
116-
let ARC { x: x } = move rc;
117-
unsafe { unwrap_shared_mutable_state(move x) }
116+
let ARC { x: x } = rc;
117+
unsafe { unwrap_shared_mutable_state(x) }
118118
}
119119

120120
impl<T: Const Owned> Clone for ARC<T> {
@@ -134,7 +134,7 @@ struct MutexARC<T> { x: SharedMutableState<MutexARCInner<T>> }
134134

135135
/// Create a mutex-protected ARC with the supplied data.
136136
pub fn MutexARC<T: Owned>(user_data: T) -> MutexARC<T> {
137-
mutex_arc_with_condvars(move user_data, 1)
137+
mutex_arc_with_condvars(user_data, 1)
138138
}
139139
/**
140140
* Create a mutex-protected ARC with the supplied data and a specified number
@@ -144,8 +144,8 @@ pub fn mutex_arc_with_condvars<T: Owned>(user_data: T,
144144
num_condvars: uint) -> MutexARC<T> {
145145
let data =
146146
MutexARCInner { lock: mutex_with_condvars(num_condvars),
147-
failed: false, data: move user_data };
148-
MutexARC { x: unsafe { shared_mutable_state(move data) } }
147+
failed: false, data: user_data };
148+
MutexARC { x: unsafe { shared_mutable_state(data) } }
149149
}
150150

151151
impl<T: Owned> Clone for MutexARC<T> {
@@ -220,13 +220,13 @@ impl<T: Owned> &MutexARC<T> {
220220
*/
221221
// FIXME(#3724) make this a by-move method on the arc
222222
pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T {
223-
let MutexARC { x: x } = move arc;
224-
let inner = unsafe { unwrap_shared_mutable_state(move x) };
225-
let MutexARCInner { failed: failed, data: data, _ } = move inner;
223+
let MutexARC { x: x } = arc;
224+
let inner = unsafe { unwrap_shared_mutable_state(x) };
225+
let MutexARCInner { failed: failed, data: data, _ } = inner;
226226
if failed {
227227
fail!(~"Can't unwrap poisoned MutexARC - another task failed inside!")
228228
}
229-
move data
229+
data
230230
}
231231
232232
// Common code for {mutex.access,rwlock.write}{,_cond}.
@@ -284,7 +284,7 @@ struct RWARC<T> {
284284
285285
/// Create a reader/writer ARC with the supplied data.
286286
pub fn RWARC<T: Const Owned>(user_data: T) -> RWARC<T> {
287-
rw_arc_with_condvars(move user_data, 1)
287+
rw_arc_with_condvars(user_data, 1)
288288
}
289289
/**
290290
* Create a reader/writer ARC with the supplied data and a specified number
@@ -296,8 +296,8 @@ pub fn rw_arc_with_condvars<T: Const Owned>(
296296
{
297297
let data =
298298
RWARCInner { lock: rwlock_with_condvars(num_condvars),
299-
failed: false, data: move user_data };
300-
RWARC { x: unsafe { shared_mutable_state(move data) }, cant_nest: () }
299+
failed: false, data: user_data };
300+
RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () }
301301
}
302302
303303
impl<T: Const Owned> RWARC<T> {
@@ -386,7 +386,7 @@ impl<T: Const Owned> &RWARC<T> {
386386
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
387387
check_poison(false, (*state).failed);
388388
blk(RWWriteMode((&mut (*state).data,
389-
move write_mode,
389+
write_mode,
390390
PoisonOnFail(&mut (*state).failed))))
391391
}
392392
}
@@ -396,17 +396,17 @@ impl<T: Const Owned> &RWARC<T> {
396396
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
397397
// The rwlock should assert that the token belongs to us for us.
398398
let state = unsafe { get_shared_immutable_state(&self.x) };
399-
let RWWriteMode((data, t, _poison)) = move token;
399+
let RWWriteMode((data, t, _poison)) = token;
400400
// Let readers in
401-
let new_token = (&state.lock).downgrade(move t);
401+
let new_token = (&state.lock).downgrade(t);
402402
// Whatever region the input reference had, it will be safe to use
403403
// the same region for the output reference. (The only 'unsafe' part
404404
// of this cast is removing the mutability.)
405405
let new_data = unsafe { cast::transmute_immut(data) };
406406
// Downgrade ensured the token belonged to us. Just a sanity check.
407407
assert ptr::ref_eq(&state.data, new_data);
408408
// Produce new token
409-
RWReadMode((new_data, move new_token))
409+
RWReadMode((new_data, new_token))
410410
}
411411
}
412412
@@ -419,13 +419,13 @@ impl<T: Const Owned> &RWARC<T> {
419419
*/
420420
// FIXME(#3724) make this a by-move method on the arc
421421
pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T {
422-
let RWARC { x: x, _ } = move arc;
423-
let inner = unsafe { unwrap_shared_mutable_state(move x) };
424-
let RWARCInner { failed: failed, data: data, _ } = move inner;
422+
let RWARC { x: x, _ } = arc;
423+
let inner = unsafe { unwrap_shared_mutable_state(x) };
424+
let RWARCInner { failed: failed, data: data, _ } = inner;
425425
if failed {
426426
fail!(~"Can't unwrap poisoned RWARC - another task failed inside!")
427427
}
428-
move data
428+
data
429429
}
430430
431431
// Borrowck rightly complains about immutably aliasing the rwlock in order to
@@ -509,7 +509,7 @@ mod tests {
509509

510510
let (p, c) = pipes::stream();
511511

512-
do task::spawn() |move c| {
512+
do task::spawn() || {
513513
let p = pipes::PortSet();
514514
c.send(p.chan());
515515

@@ -532,8 +532,8 @@ mod tests {
532532
let arc = ~MutexARC(false);
533533
let arc2 = ~arc.clone();
534534
let (p,c) = pipes::oneshot();
535-
let (c,p) = (~mut Some(move c), ~mut Some(move p));
536-
do task::spawn |move arc2, move p| {
535+
let (c,p) = (~mut Some(c), ~mut Some(p));
536+
do task::spawn || {
537537
// wait until parent gets in
538538
pipes::recv_one(option::swap_unwrap(p));
539539
do arc2.access_cond |state, cond| {
@@ -555,7 +555,7 @@ mod tests {
555555
let arc2 = ~arc.clone();
556556
let (p, c) = pipes::stream();
557557

558-
do task::spawn_unlinked |move arc2, move p| {
558+
do task::spawn_unlinked || {
559559
let _ = p.recv();
560560
do arc2.access_cond |one, cond| {
561561
cond.signal();
@@ -574,7 +574,7 @@ mod tests {
574574
pub fn test_mutex_arc_poison() {
575575
let arc = ~MutexARC(1);
576576
let arc2 = ~arc.clone();
577-
do task::try |move arc2| {
577+
do task::try || {
578578
do arc2.access |one| {
579579
assert *one == 2;
580580
}
@@ -588,21 +588,21 @@ mod tests {
588588
let arc = MutexARC(1);
589589
let arc2 = ~(&arc).clone();
590590
let (p, c) = pipes::stream();
591-
do task::spawn |move c, move arc2| {
591+
do task::spawn || {
592592
do arc2.access |one| {
593593
c.send(());
594594
assert *one == 2;
595595
}
596596
}
597597
let _ = p.recv();
598-
let one = unwrap_mutex_arc(move arc);
598+
let one = unwrap_mutex_arc(arc);
599599
assert one == 1;
600600
}
601601
#[test] #[should_fail] #[ignore(cfg(windows))]
602602
pub fn test_rw_arc_poison_wr() {
603603
let arc = ~RWARC(1);
604604
let arc2 = ~arc.clone();
605-
do task::try |move arc2| {
605+
do task::try || {
606606
do arc2.write |one| {
607607
assert *one == 2;
608608
}
@@ -615,7 +615,7 @@ mod tests {
615615
pub fn test_rw_arc_poison_ww() {
616616
let arc = ~RWARC(1);
617617
let arc2 = ~arc.clone();
618-
do task::try |move arc2| {
618+
do task::try || {
619619
do arc2.write |one| {
620620
assert *one == 2;
621621
}
@@ -628,7 +628,7 @@ mod tests {
628628
pub fn test_rw_arc_poison_dw() {
629629
let arc = ~RWARC(1);
630630
let arc2 = ~arc.clone();
631-
do task::try |move arc2| {
631+
do task::try || {
632632
do arc2.write_downgrade |write_mode| {
633633
do (&write_mode).write |one| {
634634
assert *one == 2;
@@ -643,7 +643,7 @@ mod tests {
643643
pub fn test_rw_arc_no_poison_rr() {
644644
let arc = ~RWARC(1);
645645
let arc2 = ~arc.clone();
646-
do task::try |move arc2| {
646+
do task::try || {
647647
do arc2.read |one| {
648648
assert *one == 2;
649649
}
@@ -656,7 +656,7 @@ mod tests {
656656
pub fn test_rw_arc_no_poison_rw() {
657657
let arc = ~RWARC(1);
658658
let arc2 = ~arc.clone();
659-
do task::try |move arc2| {
659+
do task::try || {
660660
do arc2.read |one| {
661661
assert *one == 2;
662662
}
@@ -669,9 +669,9 @@ mod tests {
669669
pub fn test_rw_arc_no_poison_dr() {
670670
let arc = ~RWARC(1);
671671
let arc2 = ~arc.clone();
672-
do task::try |move arc2| {
672+
do task::try || {
673673
do arc2.write_downgrade |write_mode| {
674-
let read_mode = arc2.downgrade(move write_mode);
674+
let read_mode = arc2.downgrade(write_mode);
675675
do (&read_mode).read |one| {
676676
assert *one == 2;
677677
}
@@ -687,7 +687,7 @@ mod tests {
687687
let arc2 = ~arc.clone();
688688
let (p,c) = pipes::stream();
689689

690-
do task::spawn |move arc2, move c| {
690+
do task::spawn || {
691691
do arc2.write |num| {
692692
for 10.times {
693693
let tmp = *num;
@@ -703,8 +703,8 @@ mod tests {
703703
let mut children = ~[];
704704
for 5.times {
705705
let arc3 = ~arc.clone();
706-
do task::task().future_result(|+r| children.push(move r)).spawn
707-
|move arc3| {
706+
do task::task().future_result(|+r| children.push(r)).spawn
707+
|| {
708708
do arc3.read |num| {
709709
assert *num >= 0;
710710
}
@@ -732,9 +732,9 @@ mod tests {
732732
let mut reader_convos = ~[];
733733
for 10.times {
734734
let ((rp1,rc1),(rp2,rc2)) = (pipes::stream(),pipes::stream());
735-
reader_convos.push((move rc1, move rp2));
735+
reader_convos.push((rc1, rp2));
736736
let arcn = ~arc.clone();
737-
do task::spawn |move rp1, move rc2, move arcn| {
737+
do task::spawn || {
738738
rp1.recv(); // wait for downgrader to give go-ahead
739739
do arcn.read |state| {
740740
assert *state == 31337;
@@ -746,7 +746,7 @@ mod tests {
746746
// Writer task
747747
let arc2 = ~arc.clone();
748748
let ((wp1,wc1),(wp2,wc2)) = (pipes::stream(),pipes::stream());
749-
do task::spawn |move arc2, move wc2, move wp1| {
749+
do task::spawn || {
750750
wp1.recv();
751751
do arc2.write_cond |state, cond| {
752752
assert *state == 0;
@@ -779,7 +779,7 @@ mod tests {
779779
}
780780
}
781781
}
782-
let read_mode = arc.downgrade(move write_mode);
782+
let read_mode = arc.downgrade(write_mode);
783783
do (&read_mode).read |state| {
784784
// complete handshake with other readers
785785
for vec::each(reader_convos) |x| {

src/libstd/bitv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct BigBitv {
108108
}
109109

110110
fn BigBitv(storage: ~[uint]) -> BigBitv {
111-
BigBitv {storage: move storage}
111+
BigBitv {storage: storage}
112112
}
113113

114114
/**
@@ -232,9 +232,9 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv {
232232
if nbits % uint_bits == 0 {0} else {1};
233233
let elem = if init {!0} else {0};
234234
let s = from_elem(nelems, elem);
235-
Big(~BigBitv(move s))
235+
Big(~BigBitv(s))
236236
};
237-
Bitv {rep: move rep, nbits: nbits}
237+
Bitv {rep: rep, nbits: nbits}
238238
}
239239

240240
priv impl Bitv {
@@ -519,7 +519,7 @@ impl Clone for Bitv {
519519
let mut st = from_elem(self.nbits / uint_bits + 1, 0);
520520
let len = st.len();
521521
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
522-
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: move st})}
522+
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: st})}
523523
}
524524
}
525525
}
@@ -555,7 +555,7 @@ pub fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv {
555555
for uint::range(0, len) |i| {
556556
bitv.set(i, f(i));
557557
}
558-
move bitv
558+
bitv
559559
}
560560
561561
const uint_bits: uint = 32u + (1u << 32u >> 27u);

src/libstd/cell.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Cell<T> {
2121

2222
/// Creates a new full cell with the given value.
2323
pub fn Cell<T>(value: T) -> Cell<T> {
24-
Cell { value: Some(move value) }
24+
Cell { value: Some(value) }
2525
}
2626

2727
pub pure fn empty_cell<T>() -> Cell<T> {
@@ -37,15 +37,15 @@ impl<T> Cell<T> {
3737
3838
let mut value = None;
3939
value <-> self.value;
40-
return option::unwrap(move value);
40+
return option::unwrap(value);
4141
}
4242
4343
/// Returns the value, failing if the cell is full.
4444
fn put_back(value: T) {
4545
if !self.is_empty() {
4646
fail!(~"attempt to put a value back into a full cell");
4747
}
48-
self.value = Some(move value);
48+
self.value = Some(value);
4949
}
5050

5151
/// Returns true if the cell is empty and false if the cell is full.
@@ -57,8 +57,8 @@ impl<T> Cell<T> {
5757
fn with_ref<R>(op: fn(v: &T) -> R) -> R {
5858
let v = self.take();
5959
let r = op(&v);
60-
self.put_back(move v);
61-
move r
60+
self.put_back(v);
61+
r
6262
}
6363
}
6464

@@ -69,7 +69,7 @@ fn test_basic() {
6969
let value = value_cell.take();
7070
assert value == ~10;
7171
assert value_cell.is_empty();
72-
value_cell.put_back(move value);
72+
value_cell.put_back(value);
7373
assert !value_cell.is_empty();
7474
}
7575

0 commit comments

Comments
 (0)