Skip to content

Commit 90d06b8

Browse files
committed
Make moves explicit in std tests
1 parent 30a6279 commit 90d06b8

File tree

11 files changed

+98
-96
lines changed

11 files changed

+98
-96
lines changed

src/libstd/arc.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn mutex_arc_with_condvars<T: Send>(user_data: T,
124124
num_condvars: uint) -> MutexARC<T> {
125125
let data =
126126
MutexARCInner { lock: mutex_with_condvars(num_condvars),
127-
failed: false, data: user_data };
127+
failed: false, data: move user_data };
128128
MutexARC { x: unsafe { shared_mutable_state(move data) } }
129129
}
130130

@@ -258,7 +258,7 @@ pub fn rw_arc_with_condvars<T: Const Send>(user_data: T,
258258
num_condvars: uint) -> RWARC<T> {
259259
let data =
260260
RWARCInner { lock: rwlock_with_condvars(num_condvars),
261-
failed: false, data: user_data };
261+
failed: false, data: move user_data };
262262
RWARC { x: unsafe { shared_mutable_state(move data) }, cant_nest: () }
263263
}
264264
@@ -448,7 +448,7 @@ mod tests {
448448

449449
let (c, p) = pipes::stream();
450450

451-
do task::spawn() {
451+
do task::spawn() |move c| {
452452
let p = pipes::PortSet();
453453
c.send(p.chan());
454454

@@ -471,8 +471,8 @@ mod tests {
471471
let arc = ~MutexARC(false);
472472
let arc2 = ~arc.clone();
473473
let (c,p) = pipes::oneshot();
474-
let (c,p) = (~mut Some(c), ~mut Some(p));
475-
do task::spawn {
474+
let (c,p) = (~mut Some(move c), ~mut Some(move p));
475+
do task::spawn |move arc2, move p| {
476476
// wait until parent gets in
477477
pipes::recv_one(option::swap_unwrap(p));
478478
do arc2.access_cond |state, cond| {
@@ -494,7 +494,7 @@ mod tests {
494494
let arc2 = ~arc.clone();
495495
let (c,p) = pipes::stream();
496496

497-
do task::spawn_unlinked {
497+
do task::spawn_unlinked |move arc2, move p| {
498498
let _ = p.recv();
499499
do arc2.access_cond |one, cond| {
500500
cond.signal();
@@ -513,7 +513,7 @@ mod tests {
513513
fn test_mutex_arc_poison() {
514514
let arc = ~MutexARC(1);
515515
let arc2 = ~arc.clone();
516-
do task::try {
516+
do task::try |move arc2| {
517517
do arc2.access |one| {
518518
assert *one == 2;
519519
}
@@ -527,21 +527,21 @@ mod tests {
527527
let arc = MutexARC(1);
528528
let arc2 = ~(&arc).clone();
529529
let (c,p) = pipes::stream();
530-
do task::spawn {
530+
do task::spawn |move c, move arc2| {
531531
do arc2.access |one| {
532532
c.send(());
533533
assert *one == 2;
534534
}
535535
}
536536
let _ = p.recv();
537-
let one = unwrap_mutex_arc(arc);
537+
let one = unwrap_mutex_arc(move arc);
538538
assert one == 1;
539539
}
540540
#[test] #[should_fail] #[ignore(cfg(windows))]
541541
fn test_rw_arc_poison_wr() {
542542
let arc = ~RWARC(1);
543543
let arc2 = ~arc.clone();
544-
do task::try {
544+
do task::try |move arc2| {
545545
do arc2.write |one| {
546546
assert *one == 2;
547547
}
@@ -554,7 +554,7 @@ mod tests {
554554
fn test_rw_arc_poison_ww() {
555555
let arc = ~RWARC(1);
556556
let arc2 = ~arc.clone();
557-
do task::try {
557+
do task::try |move arc2| {
558558
do arc2.write |one| {
559559
assert *one == 2;
560560
}
@@ -567,7 +567,7 @@ mod tests {
567567
fn test_rw_arc_poison_dw() {
568568
let arc = ~RWARC(1);
569569
let arc2 = ~arc.clone();
570-
do task::try {
570+
do task::try |move arc2| {
571571
do arc2.write_downgrade |write_mode| {
572572
do (&write_mode).write |one| {
573573
assert *one == 2;
@@ -582,7 +582,7 @@ mod tests {
582582
fn test_rw_arc_no_poison_rr() {
583583
let arc = ~RWARC(1);
584584
let arc2 = ~arc.clone();
585-
do task::try {
585+
do task::try |move arc2| {
586586
do arc2.read |one| {
587587
assert *one == 2;
588588
}
@@ -595,7 +595,7 @@ mod tests {
595595
fn test_rw_arc_no_poison_rw() {
596596
let arc = ~RWARC(1);
597597
let arc2 = ~arc.clone();
598-
do task::try {
598+
do task::try |move arc2| {
599599
do arc2.read |one| {
600600
assert *one == 2;
601601
}
@@ -608,9 +608,9 @@ mod tests {
608608
fn test_rw_arc_no_poison_dr() {
609609
let arc = ~RWARC(1);
610610
let arc2 = ~arc.clone();
611-
do task::try {
611+
do task::try |move arc2| {
612612
do arc2.write_downgrade |write_mode| {
613-
let read_mode = arc2.downgrade(write_mode);
613+
let read_mode = arc2.downgrade(move write_mode);
614614
do (&read_mode).read |one| {
615615
assert *one == 2;
616616
}
@@ -626,7 +626,7 @@ mod tests {
626626
let arc2 = ~arc.clone();
627627
let (c,p) = pipes::stream();
628628

629-
do task::spawn {
629+
do task::spawn |move arc2, move c| {
630630
do arc2.write |num| {
631631
for 10.times {
632632
let tmp = *num;
@@ -642,7 +642,8 @@ mod tests {
642642
let mut children = ~[];
643643
for 5.times {
644644
let arc3 = ~arc.clone();
645-
do task::task().future_result(|+r| children.push(r)).spawn {
645+
do task::task().future_result(|+r| children.push(move r)).spawn
646+
|move arc3| {
646647
do arc3.read |num| {
647648
assert *num >= 0;
648649
}
@@ -670,9 +671,9 @@ mod tests {
670671
let mut reader_convos = ~[];
671672
for 10.times {
672673
let ((rc1,rp1),(rc2,rp2)) = (pipes::stream(),pipes::stream());
673-
reader_convos.push((rc1,rp2));
674+
reader_convos.push((move rc1, move rp2));
674675
let arcn = ~arc.clone();
675-
do task::spawn {
676+
do task::spawn |move rp1, move rc2, move arcn| {
676677
rp1.recv(); // wait for downgrader to give go-ahead
677678
do arcn.read |state| {
678679
assert *state == 31337;
@@ -684,7 +685,7 @@ mod tests {
684685
// Writer task
685686
let arc2 = ~arc.clone();
686687
let ((wc1,wp1),(wc2,wp2)) = (pipes::stream(),pipes::stream());
687-
do task::spawn {
688+
do task::spawn |move arc2, move wc2, move wp1| {
688689
wp1.recv();
689690
do arc2.write_cond |state, cond| {
690691
assert *state == 0;
@@ -717,7 +718,7 @@ mod tests {
717718
}
718719
}
719720
}
720-
let read_mode = arc.downgrade(write_mode);
721+
let read_mode = arc.downgrade(move write_mode);
721722
do (&read_mode).read |state| {
722723
// complete handshake with other readers
723724
for vec::each(reader_convos) |x| {

src/libstd/bitv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct BigBitv {
9696
}
9797

9898
fn BigBitv(storage: ~[mut uint]) -> BigBitv {
99-
BigBitv {storage: storage}
99+
BigBitv {storage: move storage}
100100
}
101101

102102
/**
@@ -223,7 +223,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv {
223223
let s = to_mut(from_elem(nelems, elem));
224224
Big(~BigBitv(move s))
225225
};
226-
Bitv {rep: rep, nbits: nbits}
226+
Bitv {rep: move rep, nbits: nbits}
227227
}
228228

229229
priv impl Bitv {
@@ -301,7 +301,7 @@ impl Bitv {
301301
let st = to_mut(from_elem(self.nbits / uint_bits + 1, 0));
302302
let len = st.len();
303303
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
304-
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: st})}
304+
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: move st})}
305305
}
306306
}
307307
}

src/libstd/cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn test_basic() {
5757
let value = value_cell.take();
5858
assert value == ~10;
5959
assert value_cell.is_empty();
60-
value_cell.put_back(value);
60+
value_cell.put_back(move value);
6161
assert !value_cell.is_empty();
6262
}
6363

src/libstd/comm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ pub fn DuplexStream<T: Send, U: Send>()
5252
let (c2, p1) = pipes::stream();
5353
let (c1, p2) = pipes::stream();
5454
(DuplexStream {
55-
chan: c1,
56-
port: p1
55+
chan: move c1,
56+
port: move p1
5757
},
5858
DuplexStream {
59-
chan: c2,
60-
port: p2
59+
chan: move c2,
60+
port: move p2
6161
})
6262
}
6363

src/libstd/json.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ pub fn Parser(rdr: io::Reader) -> Parser {
329329
Parser {
330330
rdr: rdr,
331331
ch: rdr.read_char(),
332-
line: 1u,
333-
col: 1u,
332+
line: 1,
333+
col: 1,
334334
}
335335
}
336336

@@ -342,7 +342,7 @@ pub impl Parser {
342342
self.parse_whitespace();
343343
// Make sure there is no trailing characters.
344344
if self.eof() {
345-
Ok(value)
345+
Ok(move value)
346346
} else {
347347
self.error(~"trailing characters")
348348
}
@@ -610,12 +610,12 @@ priv impl Parser {
610610

611611
if self.ch == ']' {
612612
self.bump();
613-
return Ok(List(values));
613+
return Ok(List(move values));
614614
}
615615

616616
loop {
617617
match move self.parse_value() {
618-
Ok(move v) => values.push(v),
618+
Ok(move v) => values.push(move v),
619619
Err(move e) => return Err(e)
620620
}
621621

@@ -626,7 +626,7 @@ priv impl Parser {
626626

627627
match self.ch {
628628
',' => self.bump(),
629-
']' => { self.bump(); return Ok(List(values)); }
629+
']' => { self.bump(); return Ok(List(move values)); }
630630
_ => return self.error(~"expected `,` or `]`")
631631
}
632632
};
@@ -640,7 +640,7 @@ priv impl Parser {
640640

641641
if self.ch == '}' {
642642
self.bump();
643-
return Ok(Object(values));
643+
return Ok(Object(move values));
644644
}
645645

646646
while !self.eof() {
@@ -664,14 +664,14 @@ priv impl Parser {
664664
self.bump();
665665

666666
match move self.parse_value() {
667-
Ok(move value) => { values.insert(key, value); }
667+
Ok(move value) => { values.insert(key, move value); }
668668
Err(move e) => return Err(e)
669669
}
670670
self.parse_whitespace();
671671

672672
match self.ch {
673673
',' => self.bump(),
674-
'}' => { self.bump(); return Ok(Object(values)); }
674+
'}' => { self.bump(); return Ok(Object(move values)); }
675675
_ => {
676676
if self.eof() { break; }
677677
return self.error(~"expected `,` or `}`");
@@ -703,7 +703,7 @@ pub struct Deserializer {
703703
pub fn Deserializer(rdr: io::Reader) -> Result<Deserializer, Error> {
704704
match move from_reader(rdr) {
705705
Ok(move json) => {
706-
let des = Deserializer { json: json, stack: ~[] };
706+
let des = Deserializer { json: move json, stack: ~[] };
707707
Ok(move des)
708708
}
709709
Err(move e) => Err(e)
@@ -819,7 +819,7 @@ pub impl Deserializer: serialization::Deserializer {
819819
};
820820
let res = f(len);
821821
self.pop();
822-
res
822+
move res
823823
}
824824

825825
fn read_managed_vec<T>(&self, f: fn(uint) -> T) -> T {
@@ -830,7 +830,7 @@ pub impl Deserializer: serialization::Deserializer {
830830
};
831831
let res = f(len);
832832
self.pop();
833-
res
833+
move res
834834
}
835835

836836
fn read_vec_elt<T>(&self, idx: uint, f: fn() -> T) -> T {
@@ -851,14 +851,14 @@ pub impl Deserializer: serialization::Deserializer {
851851
debug!("read_rec()");
852852
let value = f();
853853
self.pop();
854-
value
854+
move value
855855
}
856856

857857
fn read_struct<T>(&self, _name: &str, f: fn() -> T) -> T {
858858
debug!("read_struct()");
859859
let value = f();
860860
self.pop();
861-
value
861+
move value
862862
}
863863

864864
fn read_field<T>(&self, name: &str, idx: uint, f: fn() -> T) -> T {
@@ -891,7 +891,7 @@ pub impl Deserializer: serialization::Deserializer {
891891
debug!("read_tup(len=%u)", len);
892892
let value = f();
893893
self.pop();
894-
value
894+
move value
895895
}
896896

897897
fn read_tup_elt<T>(&self, idx: uint, f: fn() -> T) -> T {
@@ -1183,11 +1183,11 @@ mod tests {
11831183

11841184
for items.each |item| {
11851185
match *item {
1186-
(copy key, copy value) => { d.insert(key, value); },
1186+
(copy key, copy value) => { d.insert(key, move value); },
11871187
}
11881188
};
11891189

1190-
Object(d)
1190+
Object(move d)
11911191
}
11921192

11931193
#[test]

0 commit comments

Comments
 (0)