Skip to content

Commit

Permalink
Update libcollections tests to pass the new type rules. They used to …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
nikomatsakis committed Nov 19, 2014
1 parent 0b6ec70 commit 2477bc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
28 changes: 14 additions & 14 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1678,10 +1678,10 @@ impl<'a> Iterator<uint> 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;
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -2140,8 +2140,8 @@ mod bench {
let mut vec: Vec<uint> = vec![];
b.iter(|| {
vec.push(0);
&vec
})
black_box(&vec);
});
}

#[bench]
Expand Down

0 comments on commit 2477bc4

Please sign in to comment.