about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-02-03 20:11:38 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2015-02-04 09:39:40 +1100
commitdf1ac7aa63ea89a067c57663eab035f7b83f6933 (patch)
treef053537b23c43f7e1badcc0409e740202461bb9b
parenteaf4c5c784637f3df8bdebc6ec21dbd4bc69420a (diff)
downloadrust-df1ac7aa63ea89a067c57663eab035f7b83f6933.tar.gz
rust-df1ac7aa63ea89a067c57663eab035f7b83f6933.zip
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]
-rwxr-xr-xsrc/etc/generate-deriving-span-tests.py3
-rw-r--r--src/libcollections/lib.rs1
-rw-r--r--src/libcoretest/lib.rs1
-rw-r--r--src/libflate/lib.rs1
-rw-r--r--src/librand/lib.rs4
-rw-r--r--src/librustc_back/sha2.rs1
-rw-r--r--src/libstd/collections/hash/map.rs1
-rw-r--r--src/libstd/lib.rs2
-rw-r--r--src/libstd/num/strconv.rs1
-rw-r--r--src/libstd/old_io/fs.rs1
-rw-r--r--src/libstd/old_io/tempfile.rs1
-rw-r--r--src/libstd/os.rs2
-rw-r--r--src/libstd/rand/mod.rs3
-rw-r--r--src/libstd/sync/rwlock.rs2
-rw-r--r--src/libsyntax/ext/deriving/rand.rs4
-rw-r--r--src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs25
-rw-r--r--src/test/compile-fail/deriving-span-Rand-enum.rs25
-rw-r--r--src/test/compile-fail/deriving-span-Rand-struct.rs23
-rw-r--r--src/test/compile-fail/deriving-span-Rand-tuple-struct.rs23
-rw-r--r--src/test/compile-fail/lint-unused-extern-crate.rs1
-rw-r--r--src/test/compile-fail/macros-nonfatal-errors.rs1
21 files changed, 26 insertions, 100 deletions
diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py
index eeb1b89472b..a8a62358d3a 100755
--- a/src/etc/generate-deriving-span-tests.py
+++ b/src/etc/generate-deriving-span-tests.py
@@ -114,8 +114,7 @@ traits = {
     '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),
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs
index ce00bd48bb8..dea2d509676 100644
--- a/src/libcollections/lib.rs
+++ b/src/libcollections/lib.rs
@@ -34,6 +34,7 @@
 #![feature(unicode)]
 #![feature(unsafe_destructor, slicing_syntax)]
 #![cfg_attr(test, feature(test))]
+#![cfg_attr(test, allow(deprecated))] // rand
 
 #![no_std]
 
diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs
index c26d3e7bb8a..50066ab07f5 100644
--- a/src/libcoretest/lib.rs
+++ b/src/libcoretest/lib.rs
@@ -12,6 +12,7 @@
 #![feature(int_uint)]
 #![feature(unboxed_closures)]
 #![feature(unsafe_destructor, slicing_syntax)]
+#![allow(deprecated)] // rand
 
 extern crate core;
 extern crate test;
diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs
index e7fb2ba56ab..d42849ed758 100644
--- a/src/libflate/lib.rs
+++ b/src/libflate/lib.rs
@@ -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;
diff --git a/src/librand/lib.rs b/src/librand/lib.rs
index 3ff40038872..3b78e5f88ee 100644
--- a/src/librand/lib.rs
+++ b/src/librand/lib.rs
@@ -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;
diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs
index d99ce8b64b0..4dc95088e98 100644
--- a/src/librustc_back/sha2.rs
+++ b/src/librustc_back/sha2.rs
@@ -528,6 +528,7 @@ static H256: [u32; 8] = [
 
 #[cfg(test)]
 mod tests {
+    #![allow(deprecated)]
     extern crate rand;
 
     use self::rand::Rng;
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 3e2c7627dbe..449c8a9e5dc 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -1566,6 +1566,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() }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 96aebb735ef..21197f639ad 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -142,7 +142,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;
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 1d3bf484edb..9c4741b3ce3 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -459,6 +459,7 @@ mod tests {
 
 #[cfg(test)]
 mod bench {
+    #![allow(deprecated)] // rand
     extern crate test;
 
     mod uint {
diff --git a/src/libstd/old_io/fs.rs b/src/libstd/old_io/fs.rs
index 0a9aeb849be..82ede30cb91 100644
--- a/src/libstd/old_io/fs.rs
+++ b/src/libstd/old_io/fs.rs
@@ -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};
diff --git a/src/libstd/old_io/tempfile.rs b/src/libstd/old_io/tempfile.rs
index 20cbde5db71..d2c3a8e60ad 100644
--- a/src/libstd/old_io/tempfile.rs
+++ b/src/libstd/old_io/tempfile.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 //! Temporary files and directories
+#![allow(deprecated)] // rand
 
 use old_io::{fs, IoError, IoErrorKind, IoResult};
 use old_io;
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 600ca60349a..7a9f61f1d64 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -1425,6 +1425,8 @@ mod arch_consts {
 
 #[cfg(test)]
 mod tests {
+    #![allow(deprecated)] // rand
+
     use prelude::v1::*;
 
     use iter::repeat;
diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs
index 211abc2fc83..48ff6db4392 100644
--- a/src/libstd/rand/mod.rs
+++ b/src/libstd/rand/mod.rs
@@ -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;
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index 95b570dd9c8..63ca5b5669a 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -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};
diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs
index 9fd5091e194..ec6eb9bee61 100644
--- a/src/libsyntax/ext/deriving/rand.rs
+++ b/src/libsyntax/ext/deriving/rand.rs
@@ -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(),
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
deleted file mode 100644
index 4d3542c586b..00000000000
--- a/src/test/compile-fail/deriving-span-Rand-enum-struct-variant.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
-
-extern crate rand;
-
-
-struct Error;
-
-#[derive(Rand)]
-enum Enum {
-   A {
-     x: Error //~ ERROR
-   }
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/deriving-span-Rand-enum.rs b/src/test/compile-fail/deriving-span-Rand-enum.rs
deleted file mode 100644
index dcfdbdc8062..00000000000
--- a/src/test/compile-fail/deriving-span-Rand-enum.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
-
-extern crate rand;
-
-
-struct Error;
-
-#[derive(Rand)]
-enum Enum {
-   A(
-     Error //~ ERROR
-     )
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/deriving-span-Rand-struct.rs b/src/test/compile-fail/deriving-span-Rand-struct.rs
deleted file mode 100644
index 73d89693b2b..00000000000
--- a/src/test/compile-fail/deriving-span-Rand-struct.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
-
-extern crate rand;
-
-
-struct Error;
-
-#[derive(Rand)]
-struct Struct {
-    x: Error //~ ERROR
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs b/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs
deleted file mode 100644
index 8038bf3ff09..00000000000
--- a/src/test/compile-fail/deriving-span-Rand-tuple-struct.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
-
-extern crate rand;
-
-
-struct Error;
-
-#[derive(Rand)]
-struct Struct(
-    Error //~ ERROR
-);
-
-fn main() {}
diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs
index 03bb7cc1f15..ada0cd2bc98 100644
--- a/src/test/compile-fail/lint-unused-extern-crate.rs
+++ b/src/test/compile-fail/lint-unused-extern-crate.rs
@@ -12,6 +12,7 @@
 
 #![deny(unused_extern_crates)]
 #![allow(unused_variables)]
+#![allow(deprecated)]
 #![feature(libc)]
 #![feature(collections)]
 #![feature(rand)]
diff --git a/src/test/compile-fail/macros-nonfatal-errors.rs b/src/test/compile-fail/macros-nonfatal-errors.rs
index ce1b372a4c1..42a0f41dd97 100644
--- a/src/test/compile-fail/macros-nonfatal-errors.rs
+++ b/src/test/compile-fail/macros-nonfatal-errors.rs
@@ -15,7 +15,6 @@
 #![feature(trace_macros, concat_idents)]
 
 #[derive(Default, //~ ERROR
-           Rand, //~ ERROR
            Zero)] //~ ERROR
 enum CantDeriveThose {}