Skip to content

Commit

Permalink
rand 0.7 -> 0.8
Browse files Browse the repository at this point in the history
rand_xorshift 0.2 -> 0.3
  • Loading branch information
klensy committed Sep 27, 2021
1 parent f6e6ddc commit 37e7372
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 24 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ version = "0.0.0"
dependencies = [
"compiler_builtins",
"core",
"rand 0.7.3",
"rand 0.8.3",
"rand_xorshift",
]

Expand Down Expand Up @@ -714,7 +714,7 @@ dependencies = [
name = "core"
version = "0.0.0"
dependencies = [
"rand 0.7.3",
"rand 0.8.3",
]

[[package]]
Expand Down Expand Up @@ -2929,11 +2929,11 @@ dependencies = [

[[package]]
name = "rand_xorshift"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
dependencies = [
"rand_core 0.5.1",
"rand_core 0.6.2",
]

[[package]]
Expand Down Expand Up @@ -3896,7 +3896,7 @@ dependencies = [
name = "rustc_incremental"
version = "0.0.0"
dependencies = [
"rand 0.7.3",
"rand 0.8.3",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
Expand Down Expand Up @@ -4954,7 +4954,7 @@ dependencies = [
"panic_abort",
"panic_unwind",
"profiler_builtins",
"rand 0.7.3",
"rand 0.8.3",
"rustc-demangle",
"std_detect",
"unwind",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_incremental/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ doctest = false
[dependencies]
rustc_graphviz = { path = "../rustc_graphviz" }
tracing = "0.1"
rand = "0.7"
rand = "0.8"
rustc_middle = { path = "../rustc_middle" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_hir = { path = "../rustc_hir" }
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ core = { path = "../core" }
compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std'] }

[dev-dependencies]
rand = "0.7"
rand_xorshift = "0.2"
rand = "0.8"
rand_xorshift = "0.3"

[[test]]
name = "collectionstests"
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/benches/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ const SEED: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

fn gen_random(len: usize) -> Vec<u64> {
let mut rng = XorShiftRng::from_seed(SEED);
(&mut rng).sample_iter(&Standard).take(len).collect()
(&mut rng).sample_iter(Standard).take(len).collect()
}

fn gen_random_bytes(len: usize) -> Vec<u8> {
let mut rng = XorShiftRng::from_seed(SEED);
(&mut rng).sample_iter(&Standard).take(len).collect()
(&mut rng).sample_iter(Standard).take(len).collect()
}

fn gen_mostly_ascending(len: usize) -> Vec<u64> {
Expand Down Expand Up @@ -221,14 +221,14 @@ fn gen_strings(len: usize) -> Vec<String> {
let mut v = vec![];
for _ in 0..len {
let n = rng.gen::<usize>() % 20 + 1;
v.push((&mut rng).sample_iter(&Alphanumeric).take(n).collect());
v.push((&mut rng).sample_iter(Alphanumeric).map(char::from).take(n).collect());
}
v
}

fn gen_big_random(len: usize) -> Vec<[u64; 16]> {
let mut rng = XorShiftRng::from_seed(SEED);
(&mut rng).sample_iter(&Standard).map(|x| [x; 16]).take(len).collect()
(&mut rng).sample_iter(Standard).map(|x| [x; 16]).take(len).collect()
}

macro_rules! sort {
Expand Down
6 changes: 3 additions & 3 deletions library/alloc/benches/vec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rand::RngCore;
use rand::{thread_rng, RngCore};
use std::iter::{repeat, FromIterator};
use test::{black_box, Bencher};

Expand Down Expand Up @@ -476,7 +476,7 @@ fn bench_in_place_recycle(b: &mut Bencher) {
#[bench]
fn bench_in_place_zip_recycle(b: &mut Bencher) {
let mut data = vec![0u8; 1000];
let mut rng = rand::thread_rng();
let mut rng = thread_rng();
let mut subst = vec![0u8; 1000];
rng.fill_bytes(&mut subst[..]);

Expand All @@ -495,7 +495,7 @@ fn bench_in_place_zip_recycle(b: &mut Bencher) {
#[bench]
fn bench_in_place_zip_iter_mut(b: &mut Bencher) {
let mut data = vec![0u8; 256];
let mut rng = rand::thread_rng();
let mut rng = thread_rng();
let mut subst = vec![0u8; 1000];
rng.fill_bytes(&mut subst[..]);

Expand Down
7 changes: 5 additions & 2 deletions library/alloc/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,11 @@ fn test_sort() {
for len in (2..25).chain(500..510) {
for &modulus in &[5, 10, 100, 1000] {
for _ in 0..10 {
let orig: Vec<_> =
rng.sample_iter::<i32, _>(&Standard).map(|x| x % modulus).take(len).collect();
let orig: Vec<_> = (&mut rng)
.sample_iter::<i32, _>(Standard)
.map(|x| x % modulus)
.take(len)
.collect();

// Sort in default order.
let mut v = orig.clone();
Expand Down
2 changes: 1 addition & 1 deletion library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ path = "benches/lib.rs"
test = true

[dev-dependencies]
rand = "0.7"
rand = "0.8"

[features]
# Make panics and failed asserts immediately abort without formatting any message
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ default-features = false
features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive']

[dev-dependencies]
rand = "0.7"
rand = "0.8"

[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
dlmalloc = { version = "0.2.1", features = ['rustc-dep-of-std'] }
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/collections/hash/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,12 +711,12 @@ fn test_entry_take_doesnt_corrupt() {

// Populate the map with some items.
for _ in 0..50 {
let x = rng.gen_range(-10, 10);
let x = rng.gen_range(-10..10);
m.insert(x, ());
}

for _ in 0..1000 {
let x = rng.gen_range(-10, 10);
let x = rng.gen_range(-10..10);
match m.entry(x) {
Vacant(_) => {}
Occupied(e) => {
Expand Down
5 changes: 4 additions & 1 deletion library/std/tests/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use rand::{thread_rng, Rng};

fn make_rand_name() -> OsString {
let rng = thread_rng();
let n = format!("TEST{}", rng.sample_iter(&Alphanumeric).take(10).collect::<String>());
let n = format!(
"TEST{}",
rng.sample_iter(Alphanumeric).map(char::from).take(10).collect::<String>()
);
let n = OsString::from(n);
assert!(var_os(&n).is_none());
n
Expand Down

0 comments on commit 37e7372

Please sign in to comment.