Skip to content

Commit

Permalink
Auto merge of #21892 - huonw:deprecate-rand, r=alexcrichton
Browse files Browse the repository at this point in the history
Use [`rand`](https://crates.io/crates/rand) and [`derive_rand`](https://crates.io/crates/derive_rand) from crates.io.

[breaking-change]
  • Loading branch information
bors committed Feb 4, 2015
2 parents d6c15d9 + df1ac7a commit c3e1f77
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 100 deletions.
3 changes: 1 addition & 2 deletions src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ def write_file(name, string):
'Encodable': (0, [], 0), # FIXME: quoting gives horrible spans
}

for (trait, supers, errs) in [('Rand', [], 1),
('Clone', [], 1),
for (trait, supers, errs) in [('Clone', [], 1),
('PartialEq', [], 2),
('PartialOrd', ['PartialEq'], 8),
('Eq', ['PartialEq'], 1),
Expand Down
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#![feature(unicode)]
#![feature(unsafe_destructor, slicing_syntax)]
#![cfg_attr(test, feature(test))]
#![cfg_attr(test, allow(deprecated))] // rand

#![no_std]

Expand Down
1 change: 1 addition & 0 deletions src/libcoretest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#![feature(int_uint)]
#![feature(unboxed_closures)]
#![feature(unsafe_destructor, slicing_syntax)]
#![allow(deprecated)] // rand

extern crate core;
extern crate test;
Expand Down
1 change: 1 addition & 0 deletions src/libflate/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> Option<Bytes> {

#[cfg(test)]
mod tests {
#![allow(deprecated)]
use super::{inflate_bytes, deflate_bytes};
use std::rand;
use std::rand::Rng;
Expand Down
4 changes: 4 additions & 0 deletions src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#![feature(staged_api)]
#![staged_api]
#![feature(core)]
#![deprecated(reason = "use the crates.io `rand` library instead",
since = "1.0.0-alpha")]

#![allow(deprecated)]

#[macro_use]
extern crate core;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_back/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ static H256: [u32; 8] = [

#[cfg(test)]
mod tests {
#![allow(deprecated)]
extern crate rand;

use self::rand::Rng;
Expand Down
1 change: 1 addition & 0 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ pub struct RandomState {
impl RandomState {
/// Construct a new `RandomState` that is initialized with random keys.
#[inline]
#[allow(deprecated)]
pub fn new() -> RandomState {
let mut r = rand::thread_rng();
RandomState { k0: r.gen(), k1: r.gen() }
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extern crate core;
#[macro_reexport(vec)]
extern crate "collections" as core_collections;

extern crate "rand" as core_rand;
#[allow(deprecated)] extern crate "rand" as core_rand;
extern crate alloc;
extern crate unicode;
extern crate libc;
Expand Down
1 change: 1 addition & 0 deletions src/libstd/num/strconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ mod tests {

#[cfg(test)]
mod bench {
#![allow(deprecated)] // rand
extern crate test;

mod uint {
Expand Down
1 change: 1 addition & 0 deletions src/libstd/old_io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ fn access_string(access: FileAccess) -> &'static str {
#[allow(unused_imports)]
#[allow(unused_variables)]
#[allow(unused_mut)]
#[allow(deprecated)] // rand
mod test {
use prelude::v1::*;
use old_io::{SeekSet, SeekCur, SeekEnd, Read, Open, ReadWrite, FileType};
Expand Down
1 change: 1 addition & 0 deletions src/libstd/old_io/tempfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

//! Temporary files and directories
#![allow(deprecated)] // rand

use env;
use iter::{IteratorExt};
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ mod arch_consts {

#[cfg(test)]
mod tests {
#![allow(deprecated)] // rand

use prelude::v1::*;

use iter::repeat;
Expand Down
3 changes: 3 additions & 0 deletions src/libstd/rand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
//! ```

#![unstable(feature = "rand")]
#![deprecated(reason = "use the crates.io `rand` library instead",
since = "1.0.0-alpha")]
#![allow(deprecated)]

use cell::RefCell;
use clone::Clone;
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ impl<'a, T> Drop for RwLockWriteGuard<'a, T> {

#[cfg(test)]
mod tests {
#![allow(deprecated)] // rand

use prelude::v1::*;

use rand::{self, Rng};
Expand Down
4 changes: 4 additions & 0 deletions src/libsyntax/ext/deriving/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub fn expand_deriving_rand<F>(cx: &mut ExtCtxt,
push: F) where
F: FnOnce(P<Item>),
{
cx.span_warn(span,
"`#[derive(Rand)]` is deprecated in favour of `#[derive_Rand]` from \
`rand_macros` on crates.io");

let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
Expand Down
25 changes: 0 additions & 25 deletions src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs

This file was deleted.

25 changes: 0 additions & 25 deletions src/test/compile-fail/deriving-span-Rand-enum.rs

This file was deleted.

23 changes: 0 additions & 23 deletions src/test/compile-fail/deriving-span-Rand-struct.rs

This file was deleted.

23 changes: 0 additions & 23 deletions src/test/compile-fail/deriving-span-Rand-tuple-struct.rs

This file was deleted.

1 change: 1 addition & 0 deletions src/test/compile-fail/lint-unused-extern-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#![deny(unused_extern_crates)]
#![allow(unused_variables)]
#![allow(deprecated)]
#![feature(libc)]
#![feature(collections)]
#![feature(rand)]
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/macros-nonfatal-errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#![feature(trace_macros, concat_idents)]

#[derive(Default, //~ ERROR
Rand, //~ ERROR
Zero)] //~ ERROR
enum CantDeriveThose {}

Expand Down

0 comments on commit c3e1f77

Please sign in to comment.