From 2477bc4451dc93b9e89c3e1e1621b4333675d94b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 14 Nov 2014 05:55:10 -0500 Subject: [PATCH] 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. --- src/libcollections/bit.rs | 28 ++++++++++++++-------------- src/libcollections/slice.rs | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 0529bb8904ab..64abc78daf30 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -1678,10 +1678,10 @@ impl<'a> Iterator for TwoBitPositions<'a> { mod tests { use std::prelude::*; use std::iter::range_step; - use std::u32; use std::rand; use std::rand::Rng; - use test::Bencher; + use std::u32; + use test::{Bencher, black_box}; use super::{Bitv, BitvSet, from_fn, from_bytes}; use bitv; @@ -2676,8 +2676,8 @@ mod tests { for _ in range(0u, 100) { bitv |= 1 << ((r.next_u32() as uint) % u32::BITS); } - &bitv - }) + black_box(&bitv) + }); } #[bench] @@ -2688,8 +2688,8 @@ mod tests { for _ in range(0u, 100) { bitv.set((r.next_u32() as uint) % BENCH_BITS, true); } - &bitv - }) + black_box(&bitv) + }); } #[bench] @@ -2700,8 +2700,8 @@ mod tests { for _ in range(0u, 100) { bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen()); } - &bitv - }) + black_box(&bitv); + }); } #[bench] @@ -2712,8 +2712,8 @@ mod tests { for _ in range(0u, 100) { bitv.set((r.next_u32() as uint) % u32::BITS, true); } - &bitv - }) + black_box(&bitv); + }); } #[bench] @@ -2724,8 +2724,8 @@ mod tests { for _ in range(0u, 100) { bitv.insert((r.next_u32() as uint) % u32::BITS); } - &bitv - }) + black_box(&bitv); + }); } #[bench] @@ -2736,8 +2736,8 @@ mod tests { for _ in range(0u, 100) { bitv.insert((r.next_u32() as uint) % BENCH_BITS); } - &bitv - }) + black_box(&bitv); + }); } #[bench] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 132a07af6b67..5e341ba8b04d 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -2084,7 +2084,7 @@ mod bench { use std::rand::{weak_rng, Rng}; use std::mem; use std::ptr; - use test::Bencher; + use test::{Bencher, black_box}; use vec::Vec; @@ -2140,8 +2140,8 @@ mod bench { let mut vec: Vec = vec![]; b.iter(|| { vec.push(0); - &vec - }) + black_box(&vec); + }); } #[bench]