std: Remove rand
crate and module
This commit removes the `rand` crate from the standard library facade as well as the `__rand` module in the standard library. Neither of these were used in any meaningful way in the standard library itself. The only need for randomness in libstd is to initialize the thread-local keys of a `HashMap`, and that unconditionally used `OsRng` defined in the standard library anyway. The cruft of the `rand` crate and the extra `rand` support in the standard library makes libstd slightly more difficult to port to new platforms, namely WebAssembly which doesn't have any randomness at all (without interfacing with JS). The purpose of this commit is to clarify and streamline randomness in libstd, focusing on how it's only required in one location, hashmap seeds. Note that the `rand` crate out of tree has almost always been a drop-in replacement for the `rand` crate in-tree, so any usage (accidental or purposeful) of the crate in-tree should switch to the `rand` crate on crates.io. This then also has the further benefit of avoiding duplication (mostly) between the two crates!
This commit is contained in:
parent
fc77b623d3
commit
6bc8f164b0
46 changed files with 160 additions and 4379 deletions
|
@ -356,6 +356,7 @@ use prelude::v1::*;
|
|||
|
||||
// Access to Bencher, etc.
|
||||
#[cfg(test)] extern crate test;
|
||||
#[cfg(test)] extern crate rand;
|
||||
|
||||
// We want to reexport a few macros from core but libcore has already been
|
||||
// imported by the compiler (via our #[no_std] attribute) In this case we just
|
||||
|
@ -364,9 +365,6 @@ use prelude::v1::*;
|
|||
debug_assert_ne, unreachable, unimplemented, write, writeln, try)]
|
||||
extern crate core as __core;
|
||||
|
||||
#[doc(masked)]
|
||||
#[allow(deprecated)]
|
||||
extern crate rand as core_rand;
|
||||
#[macro_use]
|
||||
#[macro_reexport(vec, format)]
|
||||
extern crate alloc;
|
||||
|
@ -504,24 +502,12 @@ mod sys;
|
|||
|
||||
// Private support modules
|
||||
mod panicking;
|
||||
mod rand;
|
||||
mod memchr;
|
||||
|
||||
// The runtime entry point and a few unstable public functions used by the
|
||||
// compiler
|
||||
pub mod rt;
|
||||
|
||||
// Some external utilities of the standard library rely on randomness (aka
|
||||
// rustc_back::TempDir and tests) and need a way to get at the OS rng we've got
|
||||
// here. This module is not at all intended for stabilization as-is, however,
|
||||
// but it may be stabilized long-term. As a result we're exposing a hidden,
|
||||
// unstable module so we can get our build working.
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "rand", issue = "27703")]
|
||||
pub mod __rand {
|
||||
pub use rand::{thread_rng, ThreadRng, Rng};
|
||||
}
|
||||
|
||||
// Include a number of private modules that exist solely to provide
|
||||
// the rustdoc documentation for primitive types. Using `include!`
|
||||
// because rustdoc only looks for these modules at the crate level.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue