diff --git a/Cargo.lock b/Cargo.lock index ab6731e4d433d..bad7e1630473d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1050,11 +1050,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-std-workspace-core 1.0.0", + "wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2246,7 +2249,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2286,7 +2289,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3534,6 +3537,7 @@ dependencies = [ "core 0.0.0", "dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "panic_abort 0.0.0", @@ -4269,6 +4273,11 @@ dependencies = [ "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.2.8" @@ -4443,7 +4452,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450" -"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" +"checksum getrandom 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2512b3191f22e2763a5db387f1c9409379772e2050841722eb4a8c4f497bf096" "checksum git2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cb400360e8a4d61b10e648285bbfa919bbf9519d0d5d5720354456f44349226" "checksum git2-curl 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2293de73491c3dc4174c5949ef53d2cc037b27613f88d72032e3f5237247a7dd" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" @@ -4703,6 +4712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f42f536e22f7fcbb407639765c8fd78707a33109301f834a594758bedd6e8cf" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" "checksum want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" +"checksum wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd5442abcac6525a045cc8c795aedb60da7a2e5e89c7bf18a0d5357849bb23c7" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 5334c4dfc68cc..4e72a01c2e409 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -25,6 +25,9 @@ profiler_builtins = { path = "../libprofiler_builtins", optional = true } unwind = { path = "../libunwind" } hashbrown = { version = "0.4.0", features = ['rustc-dep-of-std'] } +[target.'cfg(not(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown")))'.dependencies] +getrandom = { version = "0.1.9", features = ['rustc-dep-of-std'] } + [dependencies.backtrace] version = "0.3.34" default-features = false # don't use coresymbolication on OSX diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 8db7bc12cd308..2e43932f3257d 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -39,8 +39,6 @@ fn main() { println!("cargo:rustc-link-lib=resolv"); } else if target.contains("uwp") { println!("cargo:rustc-link-lib=ws2_32"); - // For BCryptGenRandom - println!("cargo:rustc-link-lib=bcrypt"); } else if target.contains("windows") { println!("cargo:rustc-link-lib=advapi32"); println!("cargo:rustc-link-lib=ws2_32"); diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 1e28ee8da26b4..cd274adadb82c 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -12,7 +12,6 @@ use crate::fmt::{self, Debug}; use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13}; use crate::iter::{FromIterator, FusedIterator}; use crate::ops::Index; -use crate::sys; /// A hash map implemented with quadratic probing and SIMD lookup. /// @@ -2445,13 +2444,25 @@ impl RandomState { // iteration order allows a form of DOS attack. To counter that we // increment one of the seeds on every RandomState creation, giving // every corresponding HashMap a different iteration order. - thread_local!(static KEYS: Cell<(u64, u64)> = { - Cell::new(sys::hashmap_random_keys()) + thread_local!(static KEYS: Cell<[u64; 2]> = { + let mut buf = [0u8; 16]; + // Use a constant seed on wasm32-unknown-unknown. + // `cfg(target = "..")` does not work right now, see: + // https://github.com/rust-lang/rust/issues/63217 + if cfg!(not(all( + target_arch = "wasm32", + target_vendor = "unknown", + target_os = "unknown", + ))) { + getrandom::getrandom(&mut buf).unwrap(); + } + let n = u128::from_ne_bytes(buf); + Cell::new([n as u64, (n >> 64) as u64]) }); KEYS.with(|keys| { - let (k0, k1) = keys.get(); - keys.set((k0.wrapping_add(1), k1)); + let [k0, k1] = keys.get(); + keys.set([k0.wrapping_add(1), k1]); RandomState { k0: k0, k1: k1 } }) } diff --git a/src/libstd/sys/cloudabi/mod.rs b/src/libstd/sys/cloudabi/mod.rs index 6e147612eb4b7..a8e661f014ce7 100644 --- a/src/libstd/sys/cloudabi/mod.rs +++ b/src/libstd/sys/cloudabi/mod.rs @@ -58,14 +58,3 @@ pub unsafe fn abort_internal() -> ! { } pub use libc::strlen; - -pub fn hashmap_random_keys() -> (u64, u64) { - unsafe { - let mut v: mem::MaybeUninit<(u64, u64)> = mem::MaybeUninit::uninit(); - libc::arc4random_buf( - v.as_mut_ptr() as *mut libc::c_void, - mem::size_of_val(&v) - ); - v.assume_init() - } -} diff --git a/src/libstd/sys/sgx/mod.rs b/src/libstd/sys/sgx/mod.rs index 601957acd5c63..e5c1c9cbb9cc5 100644 --- a/src/libstd/sys/sgx/mod.rs +++ b/src/libstd/sys/sgx/mod.rs @@ -137,21 +137,6 @@ pub unsafe extern "C" fn __rust_abort() { abort_internal(); } -pub fn hashmap_random_keys() -> (u64, u64) { - fn rdrand64() -> u64 { - unsafe { - let mut ret: u64 = 0; - for _ in 0..10 { - if crate::arch::x86_64::_rdrand64_step(&mut ret) == 1 { - return ret; - } - } - rtabort!("Failed to obtain random data"); - } - } - (rdrand64(), rdrand64()) -} - pub use crate::sys_common::{AsInner, FromInner, IntoInner}; pub trait TryIntoInner: Sized { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index b1f7aac8b4b40..ad5e83de69949 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -19,7 +19,6 @@ use crate::io::ErrorKind; #[cfg(all(not(rustdoc), target_os = "hermit"))] pub use crate::os::hermit as platform; #[cfg(all(not(rustdoc), target_os = "redox"))] pub use crate::os::redox as platform; -pub use self::rand::hashmap_random_keys; pub use libc::strlen; #[macro_use] @@ -48,7 +47,6 @@ pub mod os; pub mod path; pub mod pipe; pub mod process; -pub mod rand; pub mod rwlock; pub mod stack_overflow; pub mod thread; diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs deleted file mode 100644 index c5be17633025f..0000000000000 --- a/src/libstd/sys/unix/rand.rs +++ /dev/null @@ -1,189 +0,0 @@ -use crate::mem; -use crate::slice; - -pub fn hashmap_random_keys() -> (u64, u64) { - let mut v = (0, 0); - unsafe { - let view = slice::from_raw_parts_mut(&mut v as *mut _ as *mut u8, - mem::size_of_val(&v)); - imp::fill_bytes(view); - } - return v -} - -#[cfg(all(unix, - not(target_os = "ios"), - not(target_os = "openbsd"), - not(target_os = "freebsd"), - not(target_os = "fuchsia"), - not(target_os = "redox")))] -mod imp { - use crate::fs::File; - use crate::io::Read; - - #[cfg(any(target_os = "linux", target_os = "android"))] - fn getrandom(buf: &mut [u8]) -> libc::c_long { - unsafe { - libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr(), buf.len(), libc::GRND_NONBLOCK) - } - } - - #[cfg(not(any(target_os = "linux", target_os = "android")))] - fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool { false } - - #[cfg(any(target_os = "linux", target_os = "android"))] - fn getrandom_fill_bytes(v: &mut [u8]) -> bool { - use crate::sync::atomic::{AtomicBool, Ordering}; - use crate::sys::os::errno; - - static GETRANDOM_UNAVAILABLE: AtomicBool = AtomicBool::new(false); - if GETRANDOM_UNAVAILABLE.load(Ordering::Relaxed) { - return false; - } - - let mut read = 0; - while read < v.len() { - let result = getrandom(&mut v[read..]); - if result == -1 { - let err = errno() as libc::c_int; - if err == libc::EINTR { - continue; - } else if err == libc::ENOSYS || err == libc::EPERM { - // Fall back to reading /dev/urandom if `getrandom` is not - // supported on the current kernel. - // - // Also fall back in case it is disabled by something like - // seccomp or inside of virtual machines. - GETRANDOM_UNAVAILABLE.store(true, Ordering::Relaxed); - return false; - } else if err == libc::EAGAIN { - return false; - } else { - panic!("unexpected getrandom error: {}", err); - } - } else { - read += result as usize; - } - } - true - } - - pub fn fill_bytes(v: &mut [u8]) { - // getrandom_fill_bytes here can fail if getrandom() returns EAGAIN, - // meaning it would have blocked because the non-blocking pool (urandom) - // has not initialized in the kernel yet due to a lack of entropy. The - // fallback we do here is to avoid blocking applications which could - // depend on this call without ever knowing they do and don't have a - // work around. The PRNG of /dev/urandom will still be used but over a - // possibly predictable entropy pool. - if getrandom_fill_bytes(v) { - return; - } - - // getrandom failed because it is permanently or temporarily (because - // of missing entropy) unavailable. Open /dev/urandom, read from it, - // and close it again. - let mut file = File::open("/dev/urandom").expect("failed to open /dev/urandom"); - file.read_exact(v).expect("failed to read /dev/urandom") - } -} - -#[cfg(target_os = "openbsd")] -mod imp { - use crate::sys::os::errno; - - pub fn fill_bytes(v: &mut [u8]) { - // getentropy(2) permits a maximum buffer size of 256 bytes - for s in v.chunks_mut(256) { - let ret = unsafe { - libc::getentropy(s.as_mut_ptr() as *mut libc::c_void, s.len()) - }; - if ret == -1 { - panic!("unexpected getentropy error: {}", errno()); - } - } - } -} - -// On iOS and MacOS `SecRandomCopyBytes` calls `CCRandomCopyBytes` with -// `kCCRandomDefault`. `CCRandomCopyBytes` manages a CSPRNG which is seeded -// from `/dev/random` and which runs on its own thread accessed via GCD. -// This seems needlessly heavyweight for the purposes of generating two u64s -// once per thread in `hashmap_random_keys`. Therefore `SecRandomCopyBytes` is -// only used on iOS where direct access to `/dev/urandom` is blocked by the -// sandbox. -#[cfg(target_os = "ios")] -mod imp { - use crate::io; - use crate::ptr; - use libc::{c_int, size_t}; - - enum SecRandom {} - - #[allow(non_upper_case_globals)] - const kSecRandomDefault: *const SecRandom = ptr::null(); - - extern { - fn SecRandomCopyBytes(rnd: *const SecRandom, - count: size_t, - bytes: *mut u8) -> c_int; - } - - pub fn fill_bytes(v: &mut [u8]) { - let ret = unsafe { - SecRandomCopyBytes(kSecRandomDefault, - v.len(), - v.as_mut_ptr()) - }; - if ret == -1 { - panic!("couldn't generate random bytes: {}", - io::Error::last_os_error()); - } - } -} - -#[cfg(target_os = "freebsd")] -mod imp { - use crate::ptr; - - pub fn fill_bytes(v: &mut [u8]) { - let mib = [libc::CTL_KERN, libc::KERN_ARND]; - // kern.arandom permits a maximum buffer size of 256 bytes - for s in v.chunks_mut(256) { - let mut s_len = s.len(); - let ret = unsafe { - libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint, - s.as_mut_ptr() as *mut _, &mut s_len, - ptr::null(), 0) - }; - if ret == -1 || s_len != s.len() { - panic!("kern.arandom sysctl failed! (returned {}, s.len() {}, oldlenp {})", - ret, s.len(), s_len); - } - } - } -} - -#[cfg(target_os = "fuchsia")] -mod imp { - #[link(name = "zircon")] - extern { - fn zx_cprng_draw(buffer: *mut u8, len: usize); - } - - pub fn fill_bytes(v: &mut [u8]) { - unsafe { zx_cprng_draw(v.as_mut_ptr(), v.len()) } - } -} - -#[cfg(target_os = "redox")] -mod imp { - use crate::fs::File; - use crate::io::Read; - - pub fn fill_bytes(v: &mut [u8]) { - // Open rand:, read from it, and close it again. - let mut file = File::open("rand:").expect("failed to open rand:"); - file.read_exact(v).expect("failed to read rand:") - } -} diff --git a/src/libstd/sys/vxworks/mod.rs b/src/libstd/sys/vxworks/mod.rs index 1eff4fbcd83b7..de878e614c9e3 100644 --- a/src/libstd/sys/vxworks/mod.rs +++ b/src/libstd/sys/vxworks/mod.rs @@ -4,7 +4,6 @@ use crate::io::ErrorKind; pub use crate::os::vxworks as platform; -pub use self::rand::hashmap_random_keys; pub use libc::strlen; pub mod alloc; @@ -24,7 +23,6 @@ pub mod os; pub mod path; pub mod pipe; pub mod process; -pub mod rand; pub mod rwlock; pub mod stack_overflow; pub mod thread; diff --git a/src/libstd/sys/vxworks/rand.rs b/src/libstd/sys/vxworks/rand.rs deleted file mode 100644 index 1ec0cbe4dcf5b..0000000000000 --- a/src/libstd/sys/vxworks/rand.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::mem; -use crate::slice; - -pub fn hashmap_random_keys() -> (u64, u64) { - let mut v = (0, 0); - unsafe { - let view = slice::from_raw_parts_mut(&mut v as *mut _ as *mut u8, - mem::size_of_val(&v)); - imp::fill_bytes(view); - } - return v -} - -mod imp { - use libc; - use crate::io; - - extern "C" { - fn randBytes (randBuf: *mut libc::c_uchar, - numOfBytes: libc::c_int) -> libc::c_int; - } - - pub fn fill_bytes(v: &mut [u8]) { - let ret = unsafe { - randBytes(v.as_mut_ptr() as *mut libc::c_uchar, v.len() as libc::c_int) - }; - if ret == -1 { - panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); - } - } -} diff --git a/src/libstd/sys/wasi/mod.rs b/src/libstd/sys/wasi/mod.rs index f842869e08ee6..5238fa301a194 100644 --- a/src/libstd/sys/wasi/mod.rs +++ b/src/libstd/sys/wasi/mod.rs @@ -86,16 +86,6 @@ pub unsafe fn abort_internal() -> ! { libc::abort() } -pub fn hashmap_random_keys() -> (u64, u64) { - let mut ret = (0u64, 0u64); - unsafe { - let base = &mut ret as *mut (u64, u64) as *mut libc::c_void; - let len = mem::size_of_val(&ret); - cvt_wasi(libc::__wasi_random_get(base, len)).unwrap(); - } - return ret -} - #[doc(hidden)] pub trait IsMinusOne { fn is_minus_one(&self) -> bool; diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs index 56cbafcfdb8a2..ff6778b9a6bd8 100644 --- a/src/libstd/sys/wasm/mod.rs +++ b/src/libstd/sys/wasm/mod.rs @@ -92,15 +92,6 @@ pub unsafe fn abort_internal() -> ! { ExitSysCall::perform(1) } -// We don't have randomness yet, but I totally used a random number generator to -// generate these numbers. -// -// More seriously though this is just for DOS protection in hash maps. It's ok -// if we don't do that on wasm just yet. -pub fn hashmap_random_keys() -> (u64, u64) { - (1, 2) -} - // Implement a minimal set of system calls to enable basic IO pub enum SysCallIndex { Read = 0, diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index f706709c9ccf4..6c77bdf23b542 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -664,8 +664,6 @@ if #[cfg(not(target_vendor = "uwp"))] { pub const TOKEN_READ: DWORD = 0x20008; extern "system" { - #[link_name = "SystemFunction036"] - pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: ULONG) -> BOOLEAN; pub fn ReadConsoleW(hConsoleInput: HANDLE, lpBuffer: LPVOID, @@ -724,8 +722,6 @@ if #[cfg(target_vendor = "uwp")] { fileInfoClass: FILE_INFO_BY_HANDLE_CLASS, lpFileInformation: LPVOID, dwBufferSize: DWORD) -> BOOL; - pub fn BCryptGenRandom(hAlgorithm: LPVOID, pBuffer: *mut u8, - cbBuffer: ULONG, dwFlags: ULONG) -> LONG; } } } diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index d59ac5959a678..eace3506608d0 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -8,7 +8,6 @@ use crate::path::PathBuf; use crate::time::Duration; pub use libc::strlen; -pub use self::rand::hashmap_random_keys; #[macro_use] pub mod compat; @@ -31,7 +30,6 @@ pub mod os_str; pub mod path; pub mod pipe; pub mod process; -pub mod rand; pub mod rwlock; pub mod thread; pub mod thread_local; diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 041d5385eb69b..0abc3e4056612 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -11,7 +11,6 @@ use crate::sync::atomic::AtomicUsize; use crate::sys::c; use crate::sys::fs::{File, OpenOptions}; use crate::sys::handle::Handle; -use crate::sys::hashmap_random_keys; //////////////////////////////////////////////////////////////////////////////// // Anonymous pipes @@ -161,7 +160,10 @@ fn random_number() -> usize { return N.fetch_add(1, SeqCst) } - N.store(hashmap_random_keys().0 as usize, SeqCst); + let mut buf = [0u8; mem::size_of::()]; + getrandom::getrandom(&mut buf).expect("OS RNG failure"); + let n = usize::from_ne_bytes(buf); + N.store(n, SeqCst); } } diff --git a/src/libstd/sys/windows/rand.rs b/src/libstd/sys/windows/rand.rs deleted file mode 100644 index c9bcb5d741514..0000000000000 --- a/src/libstd/sys/windows/rand.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::io; -use crate::mem; -use crate::sys::c; - -#[cfg(not(target_vendor = "uwp"))] -pub fn hashmap_random_keys() -> (u64, u64) { - let mut v = (0, 0); - let ret = unsafe { - c::RtlGenRandom(&mut v as *mut _ as *mut u8, - mem::size_of_val(&v) as c::ULONG) - }; - if ret == 0 { - panic!("couldn't generate random bytes: {}", - io::Error::last_os_error()); - } - return v -} - -#[cfg(target_vendor = "uwp")] -pub fn hashmap_random_keys() -> (u64, u64) { - use crate::ptr; - - let mut v = (0, 0); - let ret = unsafe { - c::BCryptGenRandom(ptr::null_mut(), &mut v as *mut _ as *mut u8, - mem::size_of_val(&v) as c::ULONG, - c::BCRYPT_USE_SYSTEM_PREFERRED_RNG) - }; - if ret != 0 { - panic!("couldn't generate random bytes: {}", - io::Error::last_os_error()); - } - return v -} diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index de54eb8f57312..add6a38744e68 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -168,6 +168,7 @@ const WHITELIST: &[Crate<'_>] = &[ Crate("vcpkg"), Crate("version_check"), Crate("void"), + Crate("wasi"), Crate("winapi"), Crate("winapi-build"), Crate("winapi-i686-pc-windows-gnu"), diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index c6bb16318b6ee..f23a78d7c3b30 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -82,6 +82,9 @@ const EXCEPTION_PATHS: &[&str] = &[ "src/librustdoc", "src/libsyntax", "src/bootstrap", + + // constant hash map seed for `wasm32-unknown-unknown` + "src/libstd/collections/hash/map.rs", ]; pub fn check(path: &Path, bad: &mut bool) {