diff --git a/mk/crates.mk b/mk/crates.mk index 67bd967a974a5..e4b56696b39e6 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -50,14 +50,14 @@ ################################################################################ TARGET_CRATES := std extra green rustuv native flate arena glob term semver \ - uuid serialize sync getopts collections num test time + uuid serialize sync getopts collections num test time rand HOST_CRATES := syntax rustc rustdoc fourcc hexfloat CRATES := $(TARGET_CRATES) $(HOST_CRATES) TOOLS := compiletest rustdoc rustc DEPS_std := native:rustrt native:compiler-rt -DEPS_extra := std term sync serialize getopts collections time -DEPS_green := std native:context_switch +DEPS_extra := std term sync serialize getopts collections time rand +DEPS_green := std rand native:context_switch DEPS_rustuv := std native:uv native:uv_support DEPS_native := std DEPS_syntax := std term serialize collections @@ -71,15 +71,16 @@ DEPS_glob := std DEPS_serialize := std collections DEPS_term := std collections DEPS_semver := std -DEPS_uuid := std serialize +DEPS_uuid := std serialize rand DEPS_sync := std DEPS_getopts := std -DEPS_collections := std +DEPS_collections := std rand DEPS_fourcc := syntax std DEPS_hexfloat := syntax std -DEPS_num := std +DEPS_num := std rand DEPS_test := std extra collections getopts serialize term DEPS_time := std serialize +DEPS_rand := std TOOL_DEPS_compiletest := test green rustuv getopts TOOL_DEPS_rustdoc := rustdoc native diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index 0d27071494fea..e20baa32c1a9a 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -50,13 +50,13 @@ concurrency at this writing: * [`sync::DuplexStream`] - An extension of `pipes::stream` that allows both sending and receiving, * [`sync::SyncChan`] - An extension of `pipes::stream` that provides synchronous message sending, * [`sync::SyncPort`] - An extension of `pipes::stream` that acknowledges each message received, -* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the +* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the message is received. * [`sync::Arc`] - The Arc (atomically reference counted) type, for safely sharing immutable data, * [`sync::RWArc`] - A dual-mode Arc protected by a reader-writer lock, * [`sync::MutexArc`] - An Arc with mutable data protected by a blocking mutex, * [`sync::Semaphore`] - A counting, blocking, bounded-waiting semaphore, -* [`sync::Mutex`] - A blocking, bounded-waiting, mutual exclusion lock with an associated +* [`sync::Mutex`] - A blocking, bounded-waiting, mutual exclusion lock with an associated FIFO condition variable, * [`sync::RWLock`] - A blocking, no-starvation, reader-writer lock with an associated condvar, * [`sync::Barrier`] - A barrier enables multiple tasks to synchronize the beginning @@ -343,8 +343,8 @@ a single large vector of floats. Each task needs the full vector to perform its ~~~ # extern crate sync; + extern crate rand; # use std::vec; -# use std::rand; use sync::Arc; fn pnorm(nums: &~[f64], p: uint) -> f64 { @@ -376,9 +376,9 @@ created by the line ~~~ # extern crate sync; +# extern crate rand; # use sync::Arc; # use std::vec; -# use std::rand; # fn main() { # let numbers = vec::from_fn(1000000, |_| rand::random::()); let numbers_arc=Arc::new(numbers); @@ -389,9 +389,9 @@ and a clone of it is sent to each task ~~~ # extern crate sync; +# extern crate rand; # use sync::Arc; # use std::vec; -# use std::rand; # fn main() { # let numbers=vec::from_fn(1000000, |_| rand::random::()); # let numbers_arc = Arc::new(numbers); @@ -406,9 +406,9 @@ Each task recovers the underlying data by ~~~ # extern crate sync; +# extern crate rand; # use sync::Arc; # use std::vec; -# use std::rand; # fn main() { # let numbers=vec::from_fn(1000000, |_| rand::random::()); # let numbers_arc=Arc::new(numbers); diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index de3f39ef81d15..8f37aecfc34c2 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2529,7 +2529,7 @@ of type `ABC` can be randomly generated and converted to a string: #[deriving(Eq)] struct Circle { radius: f64 } -#[deriving(Rand, Show)] +#[deriving(Clone, Show)] enum ABC { A, B, C } ~~~ diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index cf895d2b6dee5..260c1c8912475 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -39,6 +39,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; {error_deriving} struct Error; diff --git a/src/etc/ziggurat_tables.py b/src/etc/ziggurat_tables.py index d1980cec2ed3a..762f9565b7802 100755 --- a/src/etc/ziggurat_tables.py +++ b/src/etc/ziggurat_tables.py @@ -11,7 +11,7 @@ # except according to those terms. # This creates the tables used for distributions implemented using the -# ziggurat algorithm in `std::rand::distributions;`. They are +# ziggurat algorithm in `rand::distributions;`. They are # (basically) the tables as used in the ZIGNOR variant (Doornik 2005). # They are changed rarely, so the generated file should be checked in # to git. diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 116bb80d8c077..87e9c3f238ad5 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -947,8 +947,8 @@ mod tests { use std::uint; use std::vec; - use std::rand; - use std::rand::Rng; + use rand; + use rand::Rng; static BENCH_BITS : uint = 1 << 14; diff --git a/src/libcollections/deque.rs b/src/libcollections/deque.rs index ac3861f4e3668..f84354f9b009d 100644 --- a/src/libcollections/deque.rs +++ b/src/libcollections/deque.rs @@ -44,8 +44,9 @@ pub mod bench { extern crate test; use self::test::BenchHarness; use std::container::MutableMap; - use std::{vec, rand}; - use std::rand::Rng; + use std::vec; + use rand; + use rand::Rng; pub fn insert_rand_n>(n: uint, map: &mut M, diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 9193d31931067..a3b65609b0a37 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -633,7 +633,7 @@ mod tests { extern crate test; use self::test::BenchHarness; use deque::Deque; - use std::rand; + use rand; use super::{DList, Node, ListInsertion}; pub fn check_links(list: &DList) { diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs index 1d73fae11b09b..4a9f95dcb724d 100644 --- a/src/libcollections/hashmap.rs +++ b/src/libcollections/hashmap.rs @@ -61,8 +61,8 @@ use std::iter::{FilterMap, Chain, Repeat, Zip}; use std::iter; use std::mem::replace; use std::num; -use std::rand::Rng; -use std::rand; +use rand::Rng; +use rand; use std::vec::{Items, MutItems}; use std::vec_ng::Vec; use std::vec_ng; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index fb8cd61b70388..a087180d9a502 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -23,6 +23,8 @@ #[allow(unrecognized_lint)]; #[allow(default_type_param_usage)]; +extern crate rand; + #[cfg(test)] extern crate test; pub use bitv::Bitv; diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 6388b4c7c521d..5965417bac71b 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1009,8 +1009,8 @@ mod test_treemap { use super::{TreeMap, TreeNode}; - use std::rand::Rng; - use std::rand; + use rand::Rng; + use rand; #[test] fn find_empty() { diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 5d285e7d29e6f..2232af98eb311 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -898,7 +898,7 @@ mod test_map { mod bench_map { extern crate test; use super::TrieMap; - use std::rand::{weak_rng, Rng}; + use rand::{weak_rng, Rng}; use self::test::BenchHarness; #[bench] diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs index 6861f527b1d0b..673eb7e76de49 100644 --- a/src/libextra/lib.rs +++ b/src/libextra/lib.rs @@ -34,9 +34,10 @@ Rust extras are part of the standard Rust distribution. #[deny(non_camel_case_types)]; #[deny(missing_doc)]; -extern crate sync; -extern crate serialize; extern crate collections; +extern crate rand; +extern crate serialize; +extern crate sync; extern crate time; // Utility modules diff --git a/src/libextra/tempfile.rs b/src/libextra/tempfile.rs index 5948f356a651d..905541604e03d 100644 --- a/src/libextra/tempfile.rs +++ b/src/libextra/tempfile.rs @@ -12,8 +12,7 @@ use std::os; -use std::rand::Rng; -use std::rand; +use rand::{task_rng, Rng}; use std::io; use std::io::fs; @@ -35,7 +34,7 @@ impl TempDir { return TempDir::new_in(&abs_tmpdir, suffix); } - let mut r = rand::rng(); + let mut r = task_rng(); for _ in range(0u, 1000) { let p = tmpdir.join(r.gen_ascii_str(16) + suffix); match fs::mkdir(&p, io::UserRWX) { diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 1a14432be6a3a..6bf5092bb2d51 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -90,13 +90,14 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec { #[cfg(test)] mod tests { + extern crate rand; + use super::{inflate_bytes, deflate_bytes}; - use std::rand; - use std::rand::Rng; + use self::rand::Rng; #[test] fn test_flate_round_trip() { - let mut r = rand::rng(); + let mut r = rand::task_rng(); let mut words = ~[]; for _ in range(0, 20) { let range = r.gen_range(1u, 10); diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 59477b6734ad9..22dd4c74936b4 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -175,6 +175,8 @@ #[feature(macro_rules)]; #[allow(visible_private_types)]; +extern crate rand; + use std::mem::replace; use std::os; use std::rt::crate_map; diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index a128ee4a25027..aae0034263e37 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -9,7 +9,6 @@ // except according to those terms. use std::cast; -use std::rand::{XorShiftRng, Rng, Rand}; use std::rt::local::Local; use std::rt::rtio::{RemoteCallback, PausableIdleCallback, Callback, EventLoop}; use std::rt::task::BlockedTask; @@ -18,6 +17,8 @@ use std::sync::deque; use std::unstable::mutex::NativeMutex; use std::raw; +use rand::{XorShiftRng, Rng, Rand}; + use TaskState; use context::Context; use coroutine::Coroutine; @@ -957,7 +958,7 @@ fn new_sched_rng() -> XorShiftRng { fn new_sched_rng() -> XorShiftRng { use std::libc; use std::mem; - use std::rand::SeedableRng; + use rand::SeedableRng; let fd = "/dev/urandom".with_c_str(|name| { unsafe { libc::open(name, libc::O_RDONLY, 0) } diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index ea8720751d8b0..c6203b3f234c9 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -24,7 +24,7 @@ use std::from_str::FromStr; use std::num::CheckedDiv; use std::num::{Bitwise, ToPrimitive, FromPrimitive}; use std::num::{Zero, One, ToStrRadix, FromStrRadix}; -use std::rand::Rng; +use rand::Rng; use std::str; use std::uint; use std::vec; @@ -1470,7 +1470,7 @@ mod biguint_tests { use std::num::{Zero, One, FromStrRadix, ToStrRadix}; use std::num::{ToPrimitive, FromPrimitive}; use std::num::CheckedDiv; - use std::rand::{task_rng}; + use rand::{task_rng}; use std::str; use std::u64; use std::vec; @@ -2205,7 +2205,7 @@ mod bigint_tests { use std::num::CheckedDiv; use std::num::{Zero, One, FromStrRadix, ToStrRadix}; use std::num::{ToPrimitive, FromPrimitive}; - use std::rand::{task_rng}; + use rand::{task_rng}; use std::u64; #[test] diff --git a/src/libnum/lib.rs b/src/libnum/lib.rs index 8e42b01f14ccb..8ff042ba3621c 100644 --- a/src/libnum/lib.rs +++ b/src/libnum/lib.rs @@ -15,6 +15,8 @@ #[crate_type = "dylib"]; #[license = "MIT/ASL2"]; +extern crate rand; + pub mod bigint; pub mod rational; pub mod complex; diff --git a/src/libstd/rand/distributions/exponential.rs b/src/librand/distributions/exponential.rs similarity index 89% rename from src/libstd/rand/distributions/exponential.rs rename to src/librand/distributions/exponential.rs index 2fa9cf8bd48b2..369828d59696f 100644 --- a/src/libstd/rand/distributions/exponential.rs +++ b/src/librand/distributions/exponential.rs @@ -10,9 +10,9 @@ //! The exponential distribution. -use num::Float; -use rand::{Rng, Rand}; -use rand::distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; +use std::num::Float; +use {Rng, Rand}; +use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; /// A wrapper around an `f64` to generate Exp(1) random numbers. /// @@ -58,8 +58,7 @@ impl Rand for Exp1 { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{Exp, IndependentSample}; +/// use rand::distributions::{Exp, IndependentSample}; /// /// let exp = Exp::new(2.0); /// let v = exp.ind_sample(&mut rand::task_rng()); @@ -91,10 +90,9 @@ impl IndependentSample for Exp { #[cfg(test)] mod test { - use rand::distributions::*; - use prelude::*; - use rand::*; - use super::*; + use distributions::{Sample, IndependentSample}; + use {Rng, task_rng}; + use super::Exp; #[test] fn test_exp() { @@ -121,11 +119,10 @@ mod test { mod bench { extern crate test; use self::test::BenchHarness; - use mem::size_of; - use prelude::*; - use rand::{XorShiftRng, RAND_BENCH_N}; - use super::*; - use rand::distributions::*; + use std::mem::size_of; + use {XorShiftRng, RAND_BENCH_N}; + use super::Exp; + use distributions::Sample; #[bench] fn rand_exp(bh: &mut BenchHarness) { diff --git a/src/libstd/rand/distributions/gamma.rs b/src/librand/distributions/gamma.rs similarity index 94% rename from src/libstd/rand/distributions/gamma.rs rename to src/librand/distributions/gamma.rs index b9702ccd48da2..029333cd78894 100644 --- a/src/libstd/rand/distributions/gamma.rs +++ b/src/librand/distributions/gamma.rs @@ -10,9 +10,9 @@ //! The Gamma and derived distributions. -use num::Float; -use num; -use rand::{Rng, Open01}; +use std::num::Float; +use std::num; +use {Rng, Open01}; use super::normal::StandardNormal; use super::{IndependentSample, Sample, Exp}; @@ -20,7 +20,7 @@ use super::{IndependentSample, Sample, Exp}; /// /// The density function of this distribution is /// -/// ```ignore +/// ```notrust /// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k) /// ``` /// @@ -35,8 +35,7 @@ use super::{IndependentSample, Sample, Exp}; /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{IndependentSample, Gamma}; +/// use rand::distributions::{IndependentSample, Gamma}; /// /// let gamma = Gamma::new(2.0, 5.0); /// let v = gamma.ind_sample(&mut rand::task_rng()); @@ -179,8 +178,7 @@ impl IndependentSample for GammaLargeShape { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{ChiSquared, IndependentSample}; +/// use rand::distributions::{ChiSquared, IndependentSample}; /// /// let chi = ChiSquared::new(11.0); /// let v = chi.ind_sample(&mut rand::task_rng()); @@ -231,8 +229,7 @@ impl IndependentSample for ChiSquared { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{FisherF, IndependentSample}; +/// use rand::distributions::{FisherF, IndependentSample}; /// /// let f = FisherF::new(2.0, 32.0); /// let v = f.ind_sample(&mut rand::task_rng()); @@ -275,8 +272,7 @@ impl IndependentSample for FisherF { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{StudentT, IndependentSample}; +/// use rand::distributions::{StudentT, IndependentSample}; /// /// let t = StudentT::new(11.0); /// let v = t.ind_sample(&mut rand::task_rng()); @@ -310,10 +306,9 @@ impl IndependentSample for StudentT { #[cfg(test)] mod test { - use rand::distributions::*; - use prelude::*; - use rand::*; - use super::*; + use distributions::{Sample, IndependentSample}; + use {Rng, task_rng}; + use super::{ChiSquared, StudentT, FisherF}; #[test] fn test_chi_squared_one() { @@ -344,7 +339,7 @@ mod test { } #[test] #[should_fail] - fn test_log_normal_invalid_dof() { + fn test_chi_squared_invalid_dof() { ChiSquared::new(-1.0); } @@ -373,11 +368,10 @@ mod test { mod bench { extern crate test; use self::test::BenchHarness; - use mem::size_of; - use prelude::*; - use rand::distributions::IndependentSample; - use rand::{StdRng, RAND_BENCH_N}; - use super::*; + use std::mem::size_of; + use distributions::IndependentSample; + use {StdRng, RAND_BENCH_N}; + use super::Gamma; #[bench] diff --git a/src/libstd/rand/distributions/mod.rs b/src/librand/distributions/mod.rs similarity index 97% rename from src/libstd/rand/distributions/mod.rs rename to src/librand/distributions/mod.rs index 41a106ec887f2..22a09b152c7f5 100644 --- a/src/libstd/rand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -20,14 +20,9 @@ that do not need to record state. */ -use container::Container; -use iter::{range, Iterator}; -use option::{Some, None}; -use num; -use num::CheckedAdd; -use rand::{Rng, Rand}; -use clone::Clone; -use vec::MutableVector; +use std::num; +use std::num::CheckedAdd; +use {Rng, Rand}; pub use self::range::Range; pub use self::gamma::{Gamma, ChiSquared, FisherF, StudentT}; @@ -94,8 +89,7 @@ pub struct Weighted { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{Weighted, WeightedChoice, IndependentSample}; +/// use rand::distributions::{Weighted, WeightedChoice, IndependentSample}; /// /// let wc = WeightedChoice::new(~[Weighted { weight: 2, item: 'a' }, /// Weighted { weight: 4, item: 'b' }, @@ -253,9 +247,8 @@ fn ziggurat( #[cfg(test)] mod tests { - use prelude::*; - use rand::*; - use super::*; + use {task_rng, Rng, Rand}; + use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample}; #[deriving(Eq, Show)] struct ConstRand(uint); diff --git a/src/libstd/rand/distributions/normal.rs b/src/librand/distributions/normal.rs similarity index 91% rename from src/libstd/rand/distributions/normal.rs rename to src/librand/distributions/normal.rs index b2f952e2a4c98..4c9567efc6e88 100644 --- a/src/libstd/rand/distributions/normal.rs +++ b/src/librand/distributions/normal.rs @@ -10,9 +10,9 @@ //! The normal and derived distributions. -use num::Float; -use rand::{Rng, Rand, Open01}; -use rand::distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; +use std::num::Float; +use {Rng, Rand, Open01}; +use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample}; /// A wrapper around an `f64` to generate N(0, 1) random numbers /// (a.k.a. a standard normal, or Gaussian). @@ -74,8 +74,7 @@ impl Rand for StandardNormal { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{Normal, IndependentSample}; +/// use rand::distributions::{Normal, IndependentSample}; /// /// // mean 2, standard deviation 3 /// let normal = Normal::new(2.0, 3.0); @@ -117,8 +116,7 @@ impl IndependentSample for Normal { /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{LogNormal, IndependentSample}; +/// use rand::distributions::{LogNormal, IndependentSample}; /// /// // mean 2, standard deviation 3 /// let log_normal = LogNormal::new(2.0, 3.0); @@ -148,10 +146,9 @@ impl IndependentSample for LogNormal { #[cfg(test)] mod tests { - use prelude::*; - use rand::*; - use super::*; - use rand::distributions::*; + use distributions::{Sample, IndependentSample}; + use {Rng, task_rng}; + use super::{Normal, LogNormal}; #[test] fn test_normal() { @@ -189,11 +186,10 @@ mod tests { mod bench { extern crate test; use self::test::BenchHarness; - use mem::size_of; - use prelude::*; - use rand::{XorShiftRng, RAND_BENCH_N}; - use rand::distributions::*; - use super::*; + use std::mem::size_of; + use {XorShiftRng, RAND_BENCH_N}; + use distributions::{Sample}; + use super::Normal; #[bench] fn rand_normal(bh: &mut BenchHarness) { diff --git a/src/libstd/rand/distributions/range.rs b/src/librand/distributions/range.rs similarity index 96% rename from src/libstd/rand/distributions/range.rs rename to src/librand/distributions/range.rs index 8141b3d3e896f..8256a37f2ecdd 100644 --- a/src/libstd/rand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -12,10 +12,9 @@ // this is surprisingly complicated to be both generic & correct -use cmp::Ord; -use num::Bounded; -use rand::Rng; -use rand::distributions::{Sample, IndependentSample}; +use std::num::Bounded; +use Rng; +use distributions::{Sample, IndependentSample}; /// Sample values uniformly between two bounds. /// @@ -34,8 +33,7 @@ use rand::distributions::{Sample, IndependentSample}; /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::distributions::{IndependentSample, Range}; +/// use rand::distributions::{IndependentSample, Range}; /// /// fn main() { /// let between = Range::new(10u, 10000u); @@ -163,11 +161,10 @@ float_impl! { f64 } #[cfg(test)] mod tests { - use prelude::*; - use super::*; - use rand::*; - use rand::distributions::*; - use num::Bounded; + use distributions::{Sample, IndependentSample}; + use {Rng, task_rng}; + use super::Range; + use std::num::Bounded; #[should_fail] #[test] diff --git a/src/libstd/rand/distributions/ziggurat_tables.rs b/src/librand/distributions/ziggurat_tables.rs similarity index 100% rename from src/libstd/rand/distributions/ziggurat_tables.rs rename to src/librand/distributions/ziggurat_tables.rs diff --git a/src/libstd/rand/isaac.rs b/src/librand/isaac.rs similarity index 98% rename from src/libstd/rand/isaac.rs rename to src/librand/isaac.rs index 9871207a91e6a..b3226d60095b9 100644 --- a/src/libstd/rand/isaac.rs +++ b/src/librand/isaac.rs @@ -10,11 +10,10 @@ //! The ISAAC random number generator. -use rand::{Rng, SeedableRng, OSRng}; -use iter::{Iterator, range, range_step, Repeat}; -use option::{None, Some}; -use vec::{raw, MutableVector, ImmutableVector}; -use mem; +use {Rng, SeedableRng, OSRng}; +use std::iter::{range_step, Repeat}; +use std::vec::raw; +use std::mem; static RAND_SIZE_LEN: u32 = 8; static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN; @@ -430,10 +429,9 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng { #[cfg(test)] mod test { - use super::*; - use rand::{Rng, SeedableRng, OSRng}; - use prelude::*; - use vec; + use super::{IsaacRng, Isaac64Rng}; + use {Rng, SeedableRng, OSRng}; + use std::vec; #[test] fn test_rng_32_rand_seeded() { diff --git a/src/libstd/rand/mod.rs b/src/librand/lib.rs similarity index 90% rename from src/libstd/rand/mod.rs rename to src/librand/lib.rs index 20bce8d20589c..87a18497b8afd 100644 --- a/src/libstd/rand/mod.rs +++ b/src/librand/lib.rs @@ -48,38 +48,41 @@ randomness. # Examples ```rust -use std::rand; -use std::rand::Rng; +use rand::Rng; -let mut rng = rand::rng(); +let mut rng = rand::task_rng(); if rng.gen() { // bool println!("int: {}, uint: {}", rng.gen::(), rng.gen::()) } - ``` +``` ```rust -use std::rand; - let tuple_ptr = rand::random::<~(f64, char)>(); println!("{:?}", tuple_ptr) - ``` +``` */ -use cast; -use cmp::Ord; -use container::Container; -use iter::{Iterator, range}; -use kinds::marker; -use local_data; -use prelude::*; -use str; -use vec; +#[crate_id = "rand#0.10-pre"]; +#[license = "MIT/ASL2"]; +#[crate_type = "dylib"]; +#[crate_type = "rlib"]; +#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "http://www.rust-lang.org/favicon.ico", + html_root_url = "http://static.rust-lang.org/doc/master")]; + +#[feature(macro_rules, managed_boxes)]; + +use std::cast; +use std::kinds::marker; +use std::local_data; +use std::str; +use std::vec; -pub use self::isaac::{IsaacRng, Isaac64Rng}; -pub use self::os::OSRng; +pub use isaac::{IsaacRng, Isaac64Rng}; +pub use os::OSRng; -use self::distributions::{Range, IndependentSample}; -use self::distributions::range::SampleRange; +use distributions::{Range, IndependentSample}; +use distributions::range::SampleRange; pub mod distributions; pub mod isaac; @@ -135,7 +138,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut v = [0u8, .. 13579]; /// task_rng().fill_bytes(v); @@ -170,7 +173,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); /// let x: uint = rng.gen(); @@ -187,7 +190,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); /// let x: ~[uint] = rng.gen_vec(10); @@ -210,7 +213,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); /// let n: uint = rng.gen_range(0u, 10); @@ -228,7 +231,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); /// println!("{:b}", rng.gen_weighted_bool(3)); @@ -243,7 +246,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// println!("{}", task_rng().gen_ascii_str(10)); /// ``` @@ -269,7 +272,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let choices = [1, 2, 4, 8, 16, 32]; /// let mut rng = task_rng(); @@ -289,7 +292,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// println!("{:?}", task_rng().shuffle(~[1,2,3])); /// ``` @@ -304,7 +307,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); /// let mut y = [1,2,3]; @@ -328,7 +331,7 @@ pub trait Rng { /// # Example /// /// ```rust - /// use std::rand::{task_rng, Rng}; + /// use rand::{task_rng, Rng}; /// /// let mut rng = task_rng(); /// let sample = rng.sample(range(1, 100), 5); @@ -359,7 +362,7 @@ pub trait SeedableRng: Rng { /// # Example /// /// ```rust - /// use std::rand::{Rng, SeedableRng, StdRng}; + /// use rand::{Rng, SeedableRng, StdRng}; /// /// let mut rng: StdRng = SeedableRng::from_seed(&[1, 2, 3, 4]); /// println!("{}", rng.gen::()); @@ -373,7 +376,7 @@ pub trait SeedableRng: Rng { /// # Example /// /// ```rust - /// use std::rand::{Rng, SeedableRng, StdRng}; + /// use rand::{Rng, SeedableRng, StdRng}; /// /// let mut rng: StdRng = SeedableRng::from_seed(&[1, 2, 3, 4]); /// println!("{}", rng.gen::()); @@ -393,6 +396,7 @@ pub trait SeedableRng: Rng { /// operation. If one does not require high performance generation of /// random numbers, `task_rng` and/or `random` may be more /// appropriate. +#[deprecated="use `task_rng` or `StdRng::new`"] pub fn rng() -> StdRng { StdRng::new() } @@ -408,14 +412,26 @@ pub struct StdRng { priv rng: IsaacRng } pub struct StdRng { priv rng: Isaac64Rng } impl StdRng { - /// Create a randomly seeded instance of `StdRng`. This reads - /// randomness from the OS to seed the PRNG. + /// Create a randomly seeded instance of `StdRng`. + /// + /// This is a very expensive operation as it has to read + /// randomness from the operating system and use this in an + /// expensive seeding operation. If one is only generating a small + /// number of random numbers, or doesn't need the utmost speed for + /// generating each number, `task_rng` and/or `random` may be more + /// appropriate. #[cfg(not(target_word_size="64"))] pub fn new() -> StdRng { StdRng { rng: IsaacRng::new() } } - /// Create a randomly seeded instance of `StdRng`. This reads - /// randomness from the OS to seed the PRNG. + /// Create a randomly seeded instance of `StdRng`. + /// + /// This is a very expensive operation as it has to read + /// randomness from the operating system and use this in an + /// expensive seeding operation. If one is only generating a small + /// number of random numbers, or doesn't need the utmost speed for + /// generating each number, `task_rng` and/or `random` may be more + /// appropriate. #[cfg(target_word_size="64")] pub fn new() -> StdRng { StdRng { rng: Isaac64Rng::new() } @@ -609,7 +625,7 @@ impl Rng for TaskRng { /// # Example /// /// ```rust -/// use std::rand::random; +/// use rand::random; /// /// if random() { /// let x = random(); @@ -631,8 +647,8 @@ pub fn random() -> T { /// `[0,1)`. /// /// # Example -/// ```rust,ignore -/// use std::rand::{random, Open01}; +/// ```rust +/// use rand::{random, Open01}; /// /// let Open01(val) = random::>(); /// println!("f32 from (0,1): {}", val); @@ -647,8 +663,8 @@ pub struct Open01(F); /// `[0,1)`. /// /// # Example -/// ```rust,ignore -/// use std::rand::{random, Closed01}; +/// ```rust +/// use rand::{random, Closed01}; /// /// let Closed01(val) = random::>(); /// println!("f32 from [0,1]: {}", val); @@ -657,9 +673,8 @@ pub struct Closed01(F); #[cfg(test)] mod test { - use prelude::*; - use vec; - use super::*; + use std::vec; + use super::{Rng, task_rng, random, OSRng, SeedableRng, StdRng}; struct ConstRng { i: u64 } impl Rng for ConstRng { @@ -691,7 +706,7 @@ mod test { #[test] fn test_gen_range() { - let mut r = rng(); + let mut r = task_rng(); for _ in range(0, 1000) { let a = r.gen_range(-3i, 42); assert!(a >= -3 && a < 42); @@ -711,20 +726,20 @@ mod test { #[test] #[should_fail] fn test_gen_range_fail_int() { - let mut r = rng(); + let mut r = task_rng(); r.gen_range(5i, -2); } #[test] #[should_fail] fn test_gen_range_fail_uint() { - let mut r = rng(); + let mut r = task_rng(); r.gen_range(5u, 2u); } #[test] fn test_gen_f64() { - let mut r = rng(); + let mut r = task_rng(); let a = r.gen::(); let b = r.gen::(); debug!("{:?}", (a, b)); @@ -732,14 +747,14 @@ mod test { #[test] fn test_gen_weighted_bool() { - let mut r = rng(); + let mut r = task_rng(); assert_eq!(r.gen_weighted_bool(0u), true); assert_eq!(r.gen_weighted_bool(1u), true); } #[test] fn test_gen_ascii_str() { - let mut r = rng(); + let mut r = task_rng(); debug!("{}", r.gen_ascii_str(10u)); debug!("{}", r.gen_ascii_str(10u)); debug!("{}", r.gen_ascii_str(10u)); @@ -750,7 +765,7 @@ mod test { #[test] fn test_gen_vec() { - let mut r = rng(); + let mut r = task_rng(); assert_eq!(r.gen_vec::(0u).len(), 0u); assert_eq!(r.gen_vec::(10u).len(), 10u); assert_eq!(r.gen_vec::(16u).len(), 16u); @@ -758,13 +773,13 @@ mod test { #[test] fn test_choose() { - let mut r = rng(); + let mut r = task_rng(); assert_eq!(r.choose([1, 1, 1]), 1); } #[test] fn test_choose_option() { - let mut r = rng(); + let mut r = task_rng(); let v: &[int] = &[]; assert!(r.choose_option(v).is_none()); @@ -775,7 +790,7 @@ mod test { #[test] fn test_shuffle() { - let mut r = rng(); + let mut r = task_rng(); let empty: ~[int] = ~[]; assert_eq!(r.shuffle(~[]), empty); assert_eq!(r.shuffle(~[1, 1, 1]), ~[1, 1, 1]); @@ -806,7 +821,7 @@ mod test { let min_val = 1; let max_val = 100; - let mut r = rng(); + let mut r = task_rng(); let vals = range(min_val, max_val).to_owned_vec(); let small_sample = r.sample(vals.iter(), 5); let large_sample = r.sample(vals.iter(), vals.len() + 5); @@ -847,9 +862,8 @@ static RAND_BENCH_N: u64 = 100; mod bench { extern crate test; use self::test::BenchHarness; - use prelude::*; - use rand::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N}; - use mem::size_of; + use {XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N}; + use std::mem::size_of; #[bench] fn rand_xorshift(bh: &mut BenchHarness) { diff --git a/src/libstd/rand/os.rs b/src/librand/os.rs similarity index 94% rename from src/libstd/rand/os.rs rename to src/librand/os.rs index e9068c6b0c8a5..826c1640b69a3 100644 --- a/src/libstd/rand/os.rs +++ b/src/librand/os.rs @@ -11,18 +11,17 @@ //! Interfaces to the operating system provided random number //! generators. -use rand::Rng; -use ops::Drop; +use Rng; #[cfg(unix)] -use rand::reader::ReaderRng; +use reader::ReaderRng; #[cfg(unix)] -use io::File; +use std::io::File; #[cfg(windows)] -use cast; +use std::cast; #[cfg(windows)] -use libc::{c_long, DWORD, BYTE}; +use std::libc::{c_long, DWORD, BYTE}; #[cfg(windows)] type HCRYPTPROV = c_long; // the extern functions imported from the runtime on Windows are @@ -60,7 +59,6 @@ impl OSRng { /// Create a new `OSRng`. #[cfg(unix)] pub fn new() -> OSRng { - use path::Path; let reader = File::open(&Path::new("/dev/urandom")); let reader = reader.ok().expect("Error opening /dev/urandom"); let reader_rng = ReaderRng::new(reader); @@ -106,9 +104,6 @@ impl Rng for OSRng { unsafe { cast::transmute(v) } } fn fill_bytes(&mut self, v: &mut [u8]) { - use container::Container; - use vec::MutableVector; - extern { fn rust_win32_rand_gen(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: *mut BYTE); @@ -136,10 +131,9 @@ impl Drop for OSRng { #[cfg(test)] mod test { - use prelude::*; - use super::*; - use rand::Rng; - use task; + use super::OSRng; + use Rng; + use std::task; #[test] fn test_os_rng() { diff --git a/src/libstd/rand/rand_impls.rs b/src/librand/rand_impls.rs similarity index 97% rename from src/libstd/rand/rand_impls.rs rename to src/librand/rand_impls.rs index 8f4752b3c44c7..fbd160554602f 100644 --- a/src/libstd/rand/rand_impls.rs +++ b/src/librand/rand_impls.rs @@ -10,11 +10,11 @@ //! The implementations of `Rand` for the built-in types. -use char; -use int; -use option::{Option, Some, None}; -use rand::{Rand,Rng}; -use uint; +use std::char; +use std::int; +use std::uint; + +use {Rand,Rng}; impl Rand for int { #[inline] @@ -97,7 +97,7 @@ impl Rand for u64 { macro_rules! float_impls { ($mod_name:ident, $ty:ty, $mantissa_bits:expr, $method_name:ident, $ignored_bits:expr) => { mod $mod_name { - use rand::{Rand, Rng, Open01, Closed01}; + use {Rand, Rng, Open01, Closed01}; static SCALE: $ty = (1u64 << $mantissa_bits) as $ty; @@ -226,8 +226,7 @@ impl Rand for @T { #[cfg(test)] mod tests { - use prelude::*; - use rand::{Rng, task_rng, Open01, Closed01}; + use {Rng, task_rng, Open01, Closed01}; struct ConstantRng(u64); impl Rng for ConstantRng { diff --git a/src/libstd/rand/reader.rs b/src/librand/reader.rs similarity index 94% rename from src/libstd/rand/reader.rs rename to src/librand/reader.rs index 4c9a8f7f9a2d4..744930e028cb9 100644 --- a/src/libstd/rand/reader.rs +++ b/src/librand/reader.rs @@ -10,11 +10,7 @@ //! A wrapper around any Reader to treat it as an RNG. -use container::Container; -use result::{Ok, Err}; -use io::Reader; - -use rand::Rng; +use Rng; /// An RNG that reads random bytes straight from a `Reader`. This will /// work best with an infinite reader, but this is not required. @@ -24,7 +20,7 @@ use rand::Rng; /// # Example /// /// ```rust -/// use std::rand::{reader, Rng}; +/// use rand::{reader, Rng}; /// use std::io::MemReader; /// /// let mut rng = reader::ReaderRng::new(MemReader::new(~[1,2,3,4,5,6,7,8])); @@ -75,11 +71,10 @@ impl Rng for ReaderRng { #[cfg(test)] mod test { - use super::*; - use io::MemReader; - use cast; - use rand::*; - use prelude::*; + use super::ReaderRng; + use std::io::MemReader; + use std::cast; + use Rng; #[test] fn test_reader_rng_u64() { diff --git a/src/libstd/rand/reseeding.rs b/src/librand/reseeding.rs similarity index 95% rename from src/libstd/rand/reseeding.rs rename to src/librand/reseeding.rs index a916ce173fb60..a64124e637ec4 100644 --- a/src/libstd/rand/reseeding.rs +++ b/src/librand/reseeding.rs @@ -11,9 +11,8 @@ //! A wrapper around another RNG that reseeds it after it //! generates a certain number of random bytes. -use container::Container; -use default::Default; -use rand::{Rng, SeedableRng}; +use std::default::Default; +use {Rng, SeedableRng}; /// How many bytes of entropy the underling RNG is allowed to generate /// before it is reseeded. @@ -101,9 +100,8 @@ impl, Rsdr: Reseeder> /// # Example /// /// ```rust -/// use std::rand; -/// use std::rand::{Rng, SeedableRng}; -/// use std::rand::reseeding::{Reseeder, ReseedingRng}; +/// use rand::{Rng, SeedableRng}; +/// use rand::reseeding::{Reseeder, ReseedingRng}; /// /// struct TickTockReseeder { tick: bool } /// impl Reseeder for TickTockReseeder { @@ -142,10 +140,9 @@ impl Default for ReseedWithDefault { #[cfg(test)] mod test { - use prelude::*; - use super::*; - use default::Default; - use rand::{SeedableRng, Rng}; + use super::{ReseedingRng, ReseedWithDefault}; + use std::default::Default; + use {SeedableRng, Rng}; struct Counter { i: u32 @@ -205,7 +202,7 @@ mod test { static fill_bytes_v_len: uint = 13579; #[test] fn test_rng_fill_bytes() { - use rand::task_rng; + use task_rng; let mut v = ~[0u8, .. fill_bytes_v_len]; task_rng().fill_bytes(v); diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index c5e75b52bf33c..5dbebbb4db171 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -524,12 +524,14 @@ static H256: [u32, ..8] = [ #[cfg(test)] mod tests { + extern crate rand; + use super::{Digest, Sha256, FixedBuffer}; use std::num::Bounded; use std::vec; use std::vec_ng::Vec; - use std::rand::isaac::IsaacRng; - use std::rand::Rng; + use self::rand::isaac::IsaacRng; + use self::rand::Rng; use serialize::hex::FromHex; // A normal addition - no overflow occurs diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index ea9a922f2244f..a09b03ec58a2e 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -263,6 +263,7 @@ impl<'a> FromBase64 for &'a str { #[cfg(test)] mod tests { extern crate test; + extern crate rand; use self::test::BenchHarness; use base64::{Config, FromBase64, ToBase64, STANDARD, URL_SAFE}; @@ -335,7 +336,7 @@ mod tests { #[test] fn test_base64_random() { - use std::rand::{task_rng, random, Rng}; + use self::rand::{task_rng, random, Rng}; use std::vec; for _ in range(0, 1000) { diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index b491891ff59df..d6f7f58f01c84 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -12,10 +12,9 @@ #[macro_escape]; +use libc; use os; use prelude::*; -use rand; -use rand::Rng; use std::io::net::ip::*; use sync::atomics::{AtomicUint, INIT_ATOMIC_UINT, Relaxed}; @@ -65,10 +64,18 @@ pub fn next_test_port() -> u16 { /// Get a temporary path which could be the location of a unix socket pub fn next_test_unix() -> Path { + static mut COUNT: AtomicUint = INIT_ATOMIC_UINT; + // base port and pid are an attempt to be unique between multiple + // test-runners of different configurations running on one + // buildbot, the count is to be unique within this executable. + let string = format!("rust-test-unix-path-{}-{}-{}", + base_port(), + unsafe {libc::getpid()}, + unsafe {COUNT.fetch_add(1, Relaxed)}); if cfg!(unix) { - os::tmpdir().join(rand::task_rng().gen_ascii_str(20)) + os::tmpdir().join(string) } else { - Path::new(r"\\.\pipe\" + rand::task_rng().gen_ascii_str(20)) + Path::new(r"\\.\pipe\" + string) } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 4d3d1641bd0c2..a873eccfb038a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -73,7 +73,8 @@ #[cfg(test)] extern crate native; #[cfg(test)] extern crate green; -// Make extra accessible for benchmarking +// Make extra and rand accessible for benchmarking/testcases +#[cfg(test)] extern crate rand; #[cfg(test)] extern crate extra = "extra"; // Make std testable by not duplicating lang items. See #2912 @@ -173,7 +174,6 @@ pub mod c_str; pub mod os; pub mod io; pub mod path; -pub mod rand; pub mod cast; pub mod fmt; pub mod cleanup; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 8efa9763ba9ff..e529daaa500d6 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1409,7 +1409,7 @@ mod tests { } fn make_rand_name() -> ~str { - let mut rng = rand::rng(); + let mut rng = rand::task_rng(); let n = ~"TEST" + rng.gen_ascii_str(10u); assert!(getenv(n).is_none()); n diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index 17a35f331705d..b50d527e3f596 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -18,23 +18,27 @@ * With simple pipes, without Arc, a copy would have to be made for each task. * * ```rust + * extern crate sync; + * extern crate rand; * use sync::Arc; - * use std::{rand, vec}; + * use std::vec; * - * let numbers = vec::from_fn(100, |i| (i as f32) * rand::random()); - * let shared_numbers = Arc::new(numbers); + * fn main() { + * let numbers = vec::from_fn(100, |i| (i as f32) * rand::random()); + * let shared_numbers = Arc::new(numbers); * - * for _ in range(0, 10) { - * let (port, chan) = Chan::new(); - * chan.send(shared_numbers.clone()); + * for _ in range(0, 10) { + * let (port, chan) = Chan::new(); + * chan.send(shared_numbers.clone()); * - * spawn(proc() { - * let shared_numbers = port.recv(); - * let local_numbers = shared_numbers.get(); + * spawn(proc() { + * let shared_numbers = port.recv(); + * let local_numbers = shared_numbers.get(); * - * // Work with the local numbers - * }); - * } + * // Work with the local numbers + * }); + * } + * } * ``` */ diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 1dc474551cf7c..bc314bc204bec 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -216,7 +216,7 @@ pub struct TraitDef<'a> { pub struct MethodDef<'a> { /// name of the method name: &'a str, - /// List of generics, e.g. `R: std::rand::Rng` + /// List of generics, e.g. `R: rand::Rng` generics: LifetimeBounds<'a>, /// Whether there is a self argument (outer Option) i.e. whether diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index da9679eb65578..2d16c87b78b19 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -26,7 +26,7 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt, let trait_def = TraitDef { span: span, attributes: Vec::new(), - path: Path::new(vec!("std", "rand", "Rand")), + path: Path::new(vec!("rand", "Rand")), additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), methods: vec!( @@ -35,7 +35,7 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt, generics: LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("R", - vec!( Path::new(vec!("std", "rand", "Rng")) ))) + vec!( Path::new(vec!("rand", "Rng")) ))) }, explicit_self: None, args: vec!( @@ -58,7 +58,6 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") }; let rand_ident = vec!( - cx.ident_of("std"), cx.ident_of("rand"), cx.ident_of("Rand"), cx.ident_of("rand") @@ -89,7 +88,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) Vec::new()); let rand_name = cx.expr_path(rand_name); - // ::std::rand::Rand::rand(rng) + // ::rand::Rand::rand(rng) let rv_call = cx.expr_call(trait_span, rand_name, vec!( *rng.get(0) )); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 71ee32b4aade7..cd52ff4b0ac71 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -670,7 +670,7 @@ pub fn fresh_name(src: &ast::Ident) -> Name { // following: debug version. Could work in final except that it's incompatible with // good error messages and uses of struct names in ambiguous could-be-binding // locations. Also definitely destroys the guarantee given above about ptr_eq. - /*let num = rand::rng().gen_uint_range(0,0xffff); + /*let num = rand::task_rng().gen_uint_range(0,0xffff); gensym(format!("{}_{}",ident_to_str(src),num))*/ } diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 8dbdedc18483a..aa17cd4680948 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -62,6 +62,8 @@ Examples of string representations: // test harness access #[cfg(test)] extern crate test; + +extern crate rand; extern crate serialize; use std::cast::{transmute,transmute_copy}; @@ -71,11 +73,11 @@ use std::fmt; use std::from_str::FromStr; use std::hash::{Hash, sip}; use std::num::FromStrRadix; -use std::rand::Rng; -use std::rand; use std::str; use std::vec; +use rand::Rng; + use serialize::{Encoder, Encodable, Decoder, Decodable}; /// A 128-bit (16 byte) buffer containing the ID @@ -519,12 +521,12 @@ impl rand::Rand for Uuid { #[cfg(test)] mod test { extern crate collections; + extern crate rand; use super::{Uuid, VariantMicrosoft, VariantNCS, VariantRFC4122, Version1Mac, Version2Dce, Version3Md5, Version4Random, Version5Sha1}; use std::str; - use std::rand; use std::io::MemWriter; #[test] @@ -778,7 +780,7 @@ mod test { #[test] fn test_rand_rand() { - let mut rng = rand::rng(); + let mut rng = rand::task_rng(); let u: ~Uuid = rand::Rand::rand(&mut rng); let ub = u.as_bytes(); diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c index 6ba121c5d2d04..8ab8636aa3a28 100644 --- a/src/rt/rust_builtin.c +++ b/src/rt/rust_builtin.c @@ -410,7 +410,7 @@ rust_win32_rand_acquire(HCRYPTPROV* phProv) { win32_require (_T("CryptAcquireContext"), // changes to the parameters here should be reflected in the docs of - // std::rand::os::OSRng + // rand::os::OSRng CryptAcquireContext(phProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT|CRYPT_SILENT)); diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 1830a888345ff..fcea5222e108b 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -9,11 +9,12 @@ // except according to those terms. extern crate collections; +extern crate rand; extern crate time; use collections::{TrieMap, TreeMap, HashMap, HashSet}; use std::os; -use std::rand::{Rng, IsaacRng, SeedableRng}; +use rand::{Rng, IsaacRng, SeedableRng}; use std::uint; use std::vec; diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index d1c311d2a7d52..96f3c6814ab93 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -11,13 +11,13 @@ // except according to those terms. extern crate collections; +extern crate rand; extern crate time; use collections::bitv::BitvSet; use collections::TreeSet; use collections::HashSet; use std::os; -use std::rand; use std::uint; struct Results { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 7b23e27e82a3c..120caa53293a1 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -12,13 +12,13 @@ #[feature(macro_rules)]; +extern crate rand; extern crate time; use time::precise_time_s; +use rand::Rng; use std::mem::swap; use std::os; -use std::rand::Rng; -use std::rand; use std::str; use std::vec; use std::io::File; @@ -83,7 +83,7 @@ fn read_line() { } fn vec_plus() { - let mut r = rand::rng(); + let mut r = rand::task_rng(); let mut v = ~[]; let mut i = 0; @@ -99,7 +99,7 @@ fn vec_plus() { } fn vec_append() { - let mut r = rand::rng(); + let mut r = rand::task_rng(); let mut v = ~[]; let mut i = 0; @@ -116,7 +116,7 @@ fn vec_append() { } fn vec_push_all() { - let mut r = rand::rng(); + let mut r = rand::task_rng(); let mut v = ~[]; for i in range(0u, 1500) { diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 42918ae5aa006..4954f083b3694 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -11,8 +11,10 @@ // Multi-language Perlin noise benchmark. // See https://github.com/nsf/pnoise for timings and alternative implementations. +extern crate rand; + use std::f32::consts::PI; -use std::rand::{Rng, StdRng}; +use rand::{Rng, StdRng}; struct Vec2 { x: f32, diff --git a/src/test/compile-fail/box-static-bound.rs b/src/test/compile-fail/box-static-bound.rs index 45a42f821456d..1ec5dfa2da9f2 100644 --- a/src/test/compile-fail/box-static-bound.rs +++ b/src/test/compile-fail/box-static-bound.rs @@ -19,4 +19,3 @@ fn g(x: T) -> @T { } fn main() {} - diff --git a/src/test/compile-fail/deriving-span-Clone-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Clone-enum-struct-variant.rs index 89839c06f3baa..6f3ce6abe1a76 100644 --- a/src/test/compile-fail/deriving-span-Clone-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-Clone-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Clone-enum.rs b/src/test/compile-fail/deriving-span-Clone-enum.rs index 4c47e77dd8178..c138c259a0f12 100644 --- a/src/test/compile-fail/deriving-span-Clone-enum.rs +++ b/src/test/compile-fail/deriving-span-Clone-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Clone-struct.rs b/src/test/compile-fail/deriving-span-Clone-struct.rs index 1a2eb3fc6403e..9226c4a79603b 100644 --- a/src/test/compile-fail/deriving-span-Clone-struct.rs +++ b/src/test/compile-fail/deriving-span-Clone-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Clone-tuple-struct.rs b/src/test/compile-fail/deriving-span-Clone-tuple-struct.rs index 03fb284b50b83..e49bd45f4d075 100644 --- a/src/test/compile-fail/deriving-span-Clone-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Clone-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Default-struct.rs b/src/test/compile-fail/deriving-span-Default-struct.rs index 21da9fef3982f..5da4ae5ca4242 100644 --- a/src/test/compile-fail/deriving-span-Default-struct.rs +++ b/src/test/compile-fail/deriving-span-Default-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Default-tuple-struct.rs b/src/test/compile-fail/deriving-span-Default-tuple-struct.rs index 2cfc7e2a259a3..3f44ea926b5c9 100644 --- a/src/test/compile-fail/deriving-span-Default-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Default-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Eq-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Eq-enum-struct-variant.rs index ce3d84a2e9b41..482954b39f7f2 100644 --- a/src/test/compile-fail/deriving-span-Eq-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-Eq-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Eq-enum.rs b/src/test/compile-fail/deriving-span-Eq-enum.rs index c59a81fd147c6..5221869a28503 100644 --- a/src/test/compile-fail/deriving-span-Eq-enum.rs +++ b/src/test/compile-fail/deriving-span-Eq-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Eq-struct.rs b/src/test/compile-fail/deriving-span-Eq-struct.rs index b797a0d7790a3..a063628993e5a 100644 --- a/src/test/compile-fail/deriving-span-Eq-struct.rs +++ b/src/test/compile-fail/deriving-span-Eq-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Eq-tuple-struct.rs b/src/test/compile-fail/deriving-span-Eq-tuple-struct.rs index fb4d850ed11e2..efa92c0a29a14 100644 --- a/src/test/compile-fail/deriving-span-Eq-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Eq-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Hash-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Hash-enum-struct-variant.rs index 182c669cbea1c..b08f7305cfc48 100644 --- a/src/test/compile-fail/deriving-span-Hash-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-Hash-enum-struct-variant.rs @@ -12,8 +12,8 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; -use std::hash::Hash; struct Error; diff --git a/src/test/compile-fail/deriving-span-Hash-enum.rs b/src/test/compile-fail/deriving-span-Hash-enum.rs index 7617e0a33c385..6fe0094c8d210 100644 --- a/src/test/compile-fail/deriving-span-Hash-enum.rs +++ b/src/test/compile-fail/deriving-span-Hash-enum.rs @@ -12,8 +12,8 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; -use std::hash::Hash; struct Error; diff --git a/src/test/compile-fail/deriving-span-Hash-struct.rs b/src/test/compile-fail/deriving-span-Hash-struct.rs index f20da9a9d16a7..0ae28d084ec04 100644 --- a/src/test/compile-fail/deriving-span-Hash-struct.rs +++ b/src/test/compile-fail/deriving-span-Hash-struct.rs @@ -12,8 +12,8 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; -use std::hash::Hash; struct Error; diff --git a/src/test/compile-fail/deriving-span-Hash-tuple-struct.rs b/src/test/compile-fail/deriving-span-Hash-tuple-struct.rs index 9b7ae50b738b8..1b69abb3e16e7 100644 --- a/src/test/compile-fail/deriving-span-Hash-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Hash-tuple-struct.rs @@ -12,8 +12,8 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; -use std::hash::Hash; struct Error; diff --git a/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs index 319ba14c31c96..edfc949970f2e 100644 --- a/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-Ord-enum.rs b/src/test/compile-fail/deriving-span-Ord-enum.rs index 0067546d1aa0a..13da4454c3e27 100644 --- a/src/test/compile-fail/deriving-span-Ord-enum.rs +++ b/src/test/compile-fail/deriving-span-Ord-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-Ord-struct.rs b/src/test/compile-fail/deriving-span-Ord-struct.rs index a64f51f142dec..bab38983dfb19 100644 --- a/src/test/compile-fail/deriving-span-Ord-struct.rs +++ b/src/test/compile-fail/deriving-span-Ord-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs b/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs index d289a42693292..bb211d7781e42 100644 --- a/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs index 615112c129e22..9338e23fbb475 100644 --- a/src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Rand-enum.rs b/src/test/compile-fail/deriving-span-Rand-enum.rs index a1943941e4171..1a978176d7983 100644 --- a/src/test/compile-fail/deriving-span-Rand-enum.rs +++ b/src/test/compile-fail/deriving-span-Rand-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Rand-struct.rs b/src/test/compile-fail/deriving-span-Rand-struct.rs index 00d9c1de5c55f..7f62850398071 100644 --- a/src/test/compile-fail/deriving-span-Rand-struct.rs +++ b/src/test/compile-fail/deriving-span-Rand-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs b/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs index c61a7c76bfb16..9b11c02784654 100644 --- a/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs index e22b51d19e56e..972f60bf2c9ab 100644 --- a/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Show-enum.rs b/src/test/compile-fail/deriving-span-Show-enum.rs index fffbd49a2bb38..ba3fd1766b2f8 100644 --- a/src/test/compile-fail/deriving-span-Show-enum.rs +++ b/src/test/compile-fail/deriving-span-Show-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Show-struct.rs b/src/test/compile-fail/deriving-span-Show-struct.rs index 45afd4454e86b..1e38c9dda5bd7 100644 --- a/src/test/compile-fail/deriving-span-Show-struct.rs +++ b/src/test/compile-fail/deriving-span-Show-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Show-tuple-struct.rs b/src/test/compile-fail/deriving-span-Show-tuple-struct.rs index 1a199974eba0f..7347b324a235b 100644 --- a/src/test/compile-fail/deriving-span-Show-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Show-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs index 7fc030bdb36f6..4d362678283d3 100644 --- a/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalEq-enum.rs b/src/test/compile-fail/deriving-span-TotalEq-enum.rs index 166311e030b1e..66f84612f8115 100644 --- a/src/test/compile-fail/deriving-span-TotalEq-enum.rs +++ b/src/test/compile-fail/deriving-span-TotalEq-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalEq-struct.rs b/src/test/compile-fail/deriving-span-TotalEq-struct.rs index f96c41a3865c1..ba29180e5e68b 100644 --- a/src/test/compile-fail/deriving-span-TotalEq-struct.rs +++ b/src/test/compile-fail/deriving-span-TotalEq-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs b/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs index 4b825adb8cfab..6dbd1e3cee946 100644 --- a/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs index 7be90a2aa769d..54f7667be30a7 100644 --- a/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs +++ b/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq, Ord, TotalEq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalOrd-enum.rs b/src/test/compile-fail/deriving-span-TotalOrd-enum.rs index ba97b28d18c70..6f51522d1a60f 100644 --- a/src/test/compile-fail/deriving-span-TotalOrd-enum.rs +++ b/src/test/compile-fail/deriving-span-TotalOrd-enum.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq, Ord, TotalEq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalOrd-struct.rs b/src/test/compile-fail/deriving-span-TotalOrd-struct.rs index 014a5b97e3650..b659e4cee2201 100644 --- a/src/test/compile-fail/deriving-span-TotalOrd-struct.rs +++ b/src/test/compile-fail/deriving-span-TotalOrd-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq, Ord, TotalEq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs b/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs index 7e4d5b2201b3b..d4f30946d8ec8 100644 --- a/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; #[deriving(Eq, Ord, TotalEq)] struct Error; diff --git a/src/test/compile-fail/deriving-span-Zero-struct.rs b/src/test/compile-fail/deriving-span-Zero-struct.rs index 7256b1179dbf4..2e00c92f469e6 100644 --- a/src/test/compile-fail/deriving-span-Zero-struct.rs +++ b/src/test/compile-fail/deriving-span-Zero-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/deriving-span-Zero-tuple-struct.rs b/src/test/compile-fail/deriving-span-Zero-tuple-struct.rs index d483a86fddbb8..9487c6ced629f 100644 --- a/src/test/compile-fail/deriving-span-Zero-tuple-struct.rs +++ b/src/test/compile-fail/deriving-span-Zero-tuple-struct.rs @@ -12,6 +12,7 @@ #[feature(struct_variant)]; extern crate extra; +extern crate rand; struct Error; diff --git a/src/test/compile-fail/task-rng-isnt-sendable.rs b/src/test/compile-fail/task-rng-isnt-sendable.rs index beabe03674a86..8b9d4de9f04c1 100644 --- a/src/test/compile-fail/task-rng-isnt-sendable.rs +++ b/src/test/compile-fail/task-rng-isnt-sendable.rs @@ -10,9 +10,11 @@ // ensure that the TaskRng isn't/doesn't become accidentally sendable. +extern crate rand; + fn test_send() {} pub fn main() { - test_send::<::std::rand::TaskRng>(); - //~^ ERROR: incompatible type `std::rand::TaskRng`, which does not fulfill `Send` + test_send::<::rand::TaskRng>(); + //~^ ERROR: incompatible type `rand::TaskRng`, which does not fulfill `Send` } diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs index 80371aa984052..45bb29f617fdb 100644 --- a/src/test/run-make/unicode-input/multiple_files.rs +++ b/src/test/run-make/unicode-input/multiple_files.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +extern crate rand; +use rand::{task_rng, Rng}; + use std::{char, os, str}; -use std::rand::{task_rng, Rng}; use std::io::{File, Process}; // creates unicode_input_multiple_files_{main,chars}.rs, where the diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index 3227f672bcd66..1ae6838be5bcc 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +extern crate rand; +use rand::{task_rng, Rng}; + use std::{char, os, str}; -use std::rand::{task_rng, Rng}; use std::io::{File, Process}; // creates a file with `fn main() { }` and checks the diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs index ac4101ae5b174..75567efa4703d 100644 --- a/src/test/run-pass/deriving-encodable-decodable.rs +++ b/src/test/run-pass/deriving-encodable-decodable.rs @@ -16,10 +16,11 @@ #[feature(struct_variant, managed_boxes)]; +extern crate rand; extern crate serialize; use std::io::MemWriter; -use std::rand::{random, Rand}; +use rand::{random, Rand}; use serialize::{Encodable, Decodable}; use serialize::ebml; use serialize::ebml::writer::Encoder; diff --git a/src/test/run-pass/deriving-global.rs b/src/test/run-pass/deriving-global.rs index 174081786a776..a174b2c7ab1a4 100644 --- a/src/test/run-pass/deriving-global.rs +++ b/src/test/run-pass/deriving-global.rs @@ -22,6 +22,8 @@ // except according to those terms. extern crate serialize; // {En,De}codable +extern crate rand; // Rand + mod submod { // if any of these are implemented without global calls for any // function calls, then being in a submodule will (correctly) diff --git a/src/test/run-pass/deriving-rand.rs b/src/test/run-pass/deriving-rand.rs index 8277c0459c971..c43d8a26fd9c4 100644 --- a/src/test/run-pass/deriving-rand.rs +++ b/src/test/run-pass/deriving-rand.rs @@ -9,9 +9,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-fast #7103 `extern crate` does not work on check-fast + #[feature(struct_variant)]; -use std::rand; +extern crate rand; #[deriving(Rand)] struct A; diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs index 1c4ff92907d61..c09b90ba6fb8b 100644 --- a/src/test/run-pass/morestack6.rs +++ b/src/test/run-pass/morestack6.rs @@ -13,7 +13,8 @@ // This test attempts to force the dynamic linker to resolve // external symbols as close to the red zone as possible. -use std::rand; +extern crate rand; + use std::task; mod rustrt { @@ -59,14 +60,14 @@ fn runtest2(f: extern fn(), frame_backoff: u32, last_stk: *u8) -> u32 { } pub fn main() { - use std::rand::Rng; + use rand::Rng; let fns = ~[ calllink01, calllink02, calllink08, calllink10 ]; - let mut rng = rand::rng(); + let mut rng = rand::task_rng(); for f in fns.iter() { let f = *f; let sz = rng.gen::() % 256u32 + 256u32; diff --git a/src/test/run-pass/vector-sort-failure-safe.rs b/src/test/run-pass/vector-sort-failure-safe.rs index 2c4a8aece194d..e307ae36f96c1 100644 --- a/src/test/run-pass/vector-sort-failure-safe.rs +++ b/src/test/run-pass/vector-sort-failure-safe.rs @@ -8,8 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-fast #7103 `extern crate` does not work on check-fast +extern crate rand; + use std::task; -use std::rand::{task_rng, Rng}; +use rand::{task_rng, Rng}; static MAX_LEN: uint = 20; static mut drop_counts: [uint, .. MAX_LEN] = [0, .. MAX_LEN];