Skip to content

Commit 2477bc4

Browse files
committed
Update libcollections tests to pass the new type rules. They used to return a pointer to the value they were modifying, but this should not have been legal, since that pointer would have to outlive the closure, and the closure continues to modify the value during the execution. This return value was just passed to black_box so as to convince llvm that the value was live, so rather than returning a pointer, modify to just call black_box directly inside the fn.
1 parent 0b6ec70 commit 2477bc4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/libcollections/bit.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,10 +1678,10 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16781678
mod tests {
16791679
use std::prelude::*;
16801680
use std::iter::range_step;
1681-
use std::u32;
16821681
use std::rand;
16831682
use std::rand::Rng;
1684-
use test::Bencher;
1683+
use std::u32;
1684+
use test::{Bencher, black_box};
16851685

16861686
use super::{Bitv, BitvSet, from_fn, from_bytes};
16871687
use bitv;
@@ -2676,8 +2676,8 @@ mod tests {
26762676
for _ in range(0u, 100) {
26772677
bitv |= 1 << ((r.next_u32() as uint) % u32::BITS);
26782678
}
2679-
&bitv
2680-
})
2679+
black_box(&bitv)
2680+
});
26812681
}
26822682

26832683
#[bench]
@@ -2688,8 +2688,8 @@ mod tests {
26882688
for _ in range(0u, 100) {
26892689
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
26902690
}
2691-
&bitv
2692-
})
2691+
black_box(&bitv)
2692+
});
26932693
}
26942694

26952695
#[bench]
@@ -2700,8 +2700,8 @@ mod tests {
27002700
for _ in range(0u, 100) {
27012701
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
27022702
}
2703-
&bitv
2704-
})
2703+
black_box(&bitv);
2704+
});
27052705
}
27062706

27072707
#[bench]
@@ -2712,8 +2712,8 @@ mod tests {
27122712
for _ in range(0u, 100) {
27132713
bitv.set((r.next_u32() as uint) % u32::BITS, true);
27142714
}
2715-
&bitv
2716-
})
2715+
black_box(&bitv);
2716+
});
27172717
}
27182718

27192719
#[bench]
@@ -2724,8 +2724,8 @@ mod tests {
27242724
for _ in range(0u, 100) {
27252725
bitv.insert((r.next_u32() as uint) % u32::BITS);
27262726
}
2727-
&bitv
2728-
})
2727+
black_box(&bitv);
2728+
});
27292729
}
27302730

27312731
#[bench]
@@ -2736,8 +2736,8 @@ mod tests {
27362736
for _ in range(0u, 100) {
27372737
bitv.insert((r.next_u32() as uint) % BENCH_BITS);
27382738
}
2739-
&bitv
2740-
})
2739+
black_box(&bitv);
2740+
});
27412741
}
27422742

27432743
#[bench]

src/libcollections/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ mod bench {
20842084
use std::rand::{weak_rng, Rng};
20852085
use std::mem;
20862086
use std::ptr;
2087-
use test::Bencher;
2087+
use test::{Bencher, black_box};
20882088

20892089
use vec::Vec;
20902090

@@ -2140,8 +2140,8 @@ mod bench {
21402140
let mut vec: Vec<uint> = vec![];
21412141
b.iter(|| {
21422142
vec.push(0);
2143-
&vec
2144-
})
2143+
black_box(&vec);
2144+
});
21452145
}
21462146

21472147
#[bench]

0 commit comments

Comments
 (0)