Skip to content

Commit df1ac7a

Browse files
committed
Deprecate in-tree rand, std::rand and #[derive(Rand)].
Use the crates.io crate `rand` (version 0.1 should be a drop in replacement for `std::rand`) and `rand_macros` (`#[derive_Rand]` should be a drop-in replacement). [breaking-change]
1 parent eaf4c5c commit df1ac7a

21 files changed

+26
-100
lines changed

Diff for: src/etc/generate-deriving-span-tests.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def write_file(name, string):
114114
'Encodable': (0, [], 0), # FIXME: quoting gives horrible spans
115115
}
116116

117-
for (trait, supers, errs) in [('Rand', [], 1),
118-
('Clone', [], 1),
117+
for (trait, supers, errs) in [('Clone', [], 1),
119118
('PartialEq', [], 2),
120119
('PartialOrd', ['PartialEq'], 8),
121120
('Eq', ['PartialEq'], 1),

Diff for: src/libcollections/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#![feature(unicode)]
3535
#![feature(unsafe_destructor, slicing_syntax)]
3636
#![cfg_attr(test, feature(test))]
37+
#![cfg_attr(test, allow(deprecated))] // rand
3738

3839
#![no_std]
3940

Diff for: src/libcoretest/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(int_uint)]
1313
#![feature(unboxed_closures)]
1414
#![feature(unsafe_destructor, slicing_syntax)]
15+
#![allow(deprecated)] // rand
1516

1617
extern crate core;
1718
extern crate test;

Diff for: src/libflate/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> Option<Bytes> {
130130

131131
#[cfg(test)]
132132
mod tests {
133+
#![allow(deprecated)]
133134
use super::{inflate_bytes, deflate_bytes};
134135
use std::rand;
135136
use std::rand::Rng;

Diff for: src/librand/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#![feature(staged_api)]
2929
#![staged_api]
3030
#![feature(core)]
31+
#![deprecated(reason = "use the crates.io `rand` library instead",
32+
since = "1.0.0-alpha")]
33+
34+
#![allow(deprecated)]
3135

3236
#[macro_use]
3337
extern crate core;

Diff for: src/librustc_back/sha2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ static H256: [u32; 8] = [
528528

529529
#[cfg(test)]
530530
mod tests {
531+
#![allow(deprecated)]
531532
extern crate rand;
532533

533534
use self::rand::Rng;

Diff for: src/libstd/collections/hash/map.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,7 @@ pub struct RandomState {
15661566
impl RandomState {
15671567
/// Construct a new `RandomState` that is initialized with random keys.
15681568
#[inline]
1569+
#[allow(deprecated)]
15691570
pub fn new() -> RandomState {
15701571
let mut r = rand::thread_rng();
15711572
RandomState { k0: r.gen(), k1: r.gen() }

Diff for: src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ extern crate core;
142142
#[macro_reexport(vec)]
143143
extern crate "collections" as core_collections;
144144

145-
extern crate "rand" as core_rand;
145+
#[allow(deprecated)] extern crate "rand" as core_rand;
146146
extern crate alloc;
147147
extern crate unicode;
148148
extern crate libc;

Diff for: src/libstd/num/strconv.rs

+1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ mod tests {
459459

460460
#[cfg(test)]
461461
mod bench {
462+
#![allow(deprecated)] // rand
462463
extern crate test;
463464

464465
mod uint {

Diff for: src/libstd/old_io/fs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ fn access_string(access: FileAccess) -> &'static str {
822822
#[allow(unused_imports)]
823823
#[allow(unused_variables)]
824824
#[allow(unused_mut)]
825+
#[allow(deprecated)] // rand
825826
mod test {
826827
use prelude::v1::*;
827828
use old_io::{SeekSet, SeekCur, SeekEnd, Read, Open, ReadWrite, FileType};

Diff for: src/libstd/old_io/tempfile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
//! Temporary files and directories
12+
#![allow(deprecated)] // rand
1213

1314
use old_io::{fs, IoError, IoErrorKind, IoResult};
1415
use old_io;

Diff for: src/libstd/os.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,8 @@ mod arch_consts {
14251425

14261426
#[cfg(test)]
14271427
mod tests {
1428+
#![allow(deprecated)] // rand
1429+
14281430
use prelude::v1::*;
14291431

14301432
use iter::repeat;

Diff for: src/libstd/rand/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@
220220
//! ```
221221
222222
#![unstable(feature = "rand")]
223+
#![deprecated(reason = "use the crates.io `rand` library instead",
224+
since = "1.0.0-alpha")]
225+
#![allow(deprecated)]
223226

224227
use cell::RefCell;
225228
use clone::Clone;

Diff for: src/libstd/sync/rwlock.rs

+2
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ impl<'a, T> Drop for RwLockWriteGuard<'a, T> {
383383

384384
#[cfg(test)]
385385
mod tests {
386+
#![allow(deprecated)] // rand
387+
386388
use prelude::v1::*;
387389

388390
use rand::{self, Rng};

Diff for: src/libsyntax/ext/deriving/rand.rs

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ pub fn expand_deriving_rand<F>(cx: &mut ExtCtxt,
2424
push: F) where
2525
F: FnOnce(P<Item>),
2626
{
27+
cx.span_warn(span,
28+
"`#[derive(Rand)]` is deprecated in favour of `#[derive_Rand]` from \
29+
`rand_macros` on crates.io");
30+
2731
let trait_def = TraitDef {
2832
span: span,
2933
attributes: Vec::new(),

Diff for: src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs

-25
This file was deleted.

Diff for: src/test/compile-fail/deriving-span-Rand-enum.rs

-25
This file was deleted.

Diff for: src/test/compile-fail/deriving-span-Rand-struct.rs

-23
This file was deleted.

Diff for: src/test/compile-fail/deriving-span-Rand-tuple-struct.rs

-23
This file was deleted.

Diff for: src/test/compile-fail/lint-unused-extern-crate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#![deny(unused_extern_crates)]
1414
#![allow(unused_variables)]
15+
#![allow(deprecated)]
1516
#![feature(libc)]
1617
#![feature(collections)]
1718
#![feature(rand)]

Diff for: src/test/compile-fail/macros-nonfatal-errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![feature(trace_macros, concat_idents)]
1616

1717
#[derive(Default, //~ ERROR
18-
Rand, //~ ERROR
1918
Zero)] //~ ERROR
2019
enum CantDeriveThose {}
2120

0 commit comments

Comments
 (0)