From 37e737203eb9a31c3234679e558060fc83e471f2 Mon Sep 17 00:00:00 2001 From: klensy Date: Mon, 5 Jul 2021 22:49:36 +0300 Subject: [PATCH 1/3] rand 0.7 -> 0.8 rand_xorshift 0.2 -> 0.3 --- Cargo.lock | 14 +++++++------- compiler/rustc_incremental/Cargo.toml | 2 +- library/alloc/Cargo.toml | 4 ++-- library/alloc/benches/slice.rs | 8 ++++---- library/alloc/benches/vec.rs | 6 +++--- library/alloc/tests/slice.rs | 7 +++++-- library/core/Cargo.toml | 2 +- library/std/Cargo.toml | 2 +- library/std/src/collections/hash/map/tests.rs | 4 ++-- library/std/tests/env.rs | 5 ++++- 10 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b3a714920bb4..079fd90a3e1cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ version = "0.0.0" dependencies = [ "compiler_builtins", "core", - "rand 0.7.3", + "rand 0.8.3", "rand_xorshift", ] @@ -714,7 +714,7 @@ dependencies = [ name = "core" version = "0.0.0" dependencies = [ - "rand 0.7.3", + "rand 0.8.3", ] [[package]] @@ -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]] @@ -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", @@ -4954,7 +4954,7 @@ dependencies = [ "panic_abort", "panic_unwind", "profiler_builtins", - "rand 0.7.3", + "rand 0.8.3", "rustc-demangle", "std_detect", "unwind", diff --git a/compiler/rustc_incremental/Cargo.toml b/compiler/rustc_incremental/Cargo.toml index dece752c1945f..4339d6005b66c 100644 --- a/compiler/rustc_incremental/Cargo.toml +++ b/compiler/rustc_incremental/Cargo.toml @@ -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" } diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index b3ff0fd0a313c..f07d6f22c0aa5 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -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" diff --git a/library/alloc/benches/slice.rs b/library/alloc/benches/slice.rs index e20c043286e6f..5fa407996fbfd 100644 --- a/library/alloc/benches/slice.rs +++ b/library/alloc/benches/slice.rs @@ -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 { 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 { 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 { @@ -221,14 +221,14 @@ fn gen_strings(len: usize) -> Vec { let mut v = vec![]; for _ in 0..len { let n = rng.gen::() % 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 { diff --git a/library/alloc/benches/vec.rs b/library/alloc/benches/vec.rs index c93a493cadb0d..c5fc8277bd0d6 100644 --- a/library/alloc/benches/vec.rs +++ b/library/alloc/benches/vec.rs @@ -1,4 +1,4 @@ -use rand::RngCore; +use rand::{thread_rng, RngCore}; use std::iter::{repeat, FromIterator}; use test::{black_box, Bencher}; @@ -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[..]); @@ -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[..]); diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index 13b8c059e37ae..dfed0d8b353ce 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -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::(&Standard).map(|x| x % modulus).take(len).collect(); + let orig: Vec<_> = (&mut rng) + .sample_iter::(Standard) + .map(|x| x % modulus) + .take(len) + .collect(); // Sort in default order. let mut v = orig.clone(); diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index 6f10b9e434290..80a282929a2cb 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -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 diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 2b77dc54ab35c..f6bcebedfd496 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -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'] } diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs index d9b20aee2d27f..06771adfaef26 100644 --- a/library/std/src/collections/hash/map/tests.rs +++ b/library/std/src/collections/hash/map/tests.rs @@ -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) => { diff --git a/library/std/tests/env.rs b/library/std/tests/env.rs index b095c2dde6285..602ff0907eba6 100644 --- a/library/std/tests/env.rs +++ b/library/std/tests/env.rs @@ -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::()); + let n = format!( + "TEST{}", + rng.sample_iter(Alphanumeric).map(char::from).take(10).collect::() + ); let n = OsString::from(n); assert!(var_os(&n).is_none()); n From d2bd3f20f45bfeafbd9475aff87a7aebfaceafe2 Mon Sep 17 00:00:00 2001 From: klensy Date: Mon, 27 Sep 2021 10:54:24 +0300 Subject: [PATCH 2/3] try to fix wasm32-unknown-unknown build --- Cargo.lock | 96 +++++++++++++++++++++++++++++++++++++---- library/test/Cargo.toml | 3 ++ 2 files changed, 90 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 079fd90a3e1cf..f54dadfebfdbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,6 +232,12 @@ dependencies = [ "toml", ] +[[package]] +name = "bumpalo" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" + [[package]] name = "byte-tools" version = "0.3.1" @@ -1401,18 +1407,20 @@ checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ "cfg-if 0.1.10", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] name = "getrandom" -version = "0.2.0" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "js-sys", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -1742,6 +1750,15 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "json" version = "0.12.4" @@ -2251,7 +2268,7 @@ dependencies = [ "colored", "compiletest_rs", "env_logger 0.8.1", - "getrandom 0.2.0", + "getrandom 0.2.3", "hex 0.4.2", "libc", "log", @@ -2897,7 +2914,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ - "getrandom 0.2.0", + "getrandom 0.2.3", ] [[package]] @@ -2985,7 +3002,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.0", + "getrandom 0.2.3", "redox_syscall", ] @@ -4958,7 +4975,7 @@ dependencies = [ "rustc-demangle", "std_detect", "unwind", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -5175,6 +5192,7 @@ dependencies = [ "cfg-if 0.1.10", "core", "getopts", + "getrandom 0.2.3", "libc", "panic_abort", "panic_unwind", @@ -5662,6 +5680,66 @@ dependencies = [ "rustc-std-workspace-core", ] +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" + [[package]] name = "winapi" version = "0.3.9" diff --git a/library/test/Cargo.toml b/library/test/Cargo.toml index 04dab6b804acc..3cf36342c42c9 100644 --- a/library/test/Cargo.toml +++ b/library/test/Cargo.toml @@ -18,6 +18,9 @@ panic_abort = { path = "../panic_abort" } # not actually used but needed to always have proc_macro in the sysroot proc_macro = { path = "../proc_macro" } +[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] +getrandom = { version = "0.2", features = ['js'] } + # Forward features to the `std` crate as necessary [features] default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"] From de39f1adc2ba0e7f5ed3f53fbb473e7ead960ef5 Mon Sep 17 00:00:00 2001 From: klensy Date: Mon, 27 Sep 2021 11:24:48 +0300 Subject: [PATCH 3/3] add entries to tidy allow list --- src/tools/tidy/src/deps.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 60703384e9e85..1108db90d711a 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -82,6 +82,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "bitflags", "block-buffer", "block-padding", + "bumpalo", "byteorder", "byte-tools", "cc", @@ -127,6 +128,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "itertools", "itoa", "jobserver", + "js-sys", "lazy_static", "libc", "libz-sys", @@ -218,6 +220,11 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "vcpkg", "version_check", "wasi", + "wasm-bindgen", + "wasm-bindgen-backend", + "wasm-bindgen-macro", + "wasm-bindgen-macro-support", + "wasm-bindgen-shared", "winapi", "winapi-i686-pc-windows-gnu", "winapi-util",