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]
This commit is contained in:
Huon Wilson 2015-02-03 20:11:38 +11:00
parent eaf4c5c784
commit df1ac7aa63
21 changed files with 26 additions and 100 deletions

View file

@ -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),

View file

@ -34,6 +34,7 @@
#![feature(unicode)]
#![feature(unsafe_destructor, slicing_syntax)]
#![cfg_attr(test, feature(test))]
#![cfg_attr(test, allow(deprecated))] // rand
#![no_std]

View file

@ -12,6 +12,7 @@
#![feature(int_uint)]
#![feature(unboxed_closures)]
#![feature(unsafe_destructor, slicing_syntax)]
#![allow(deprecated)] // rand
extern crate core;
extern crate test;

View file

@ -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;

View file

@ -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;

View file

@ -528,6 +528,7 @@ static H256: [u32; 8] = [
#[cfg(test)]
mod tests {
#![allow(deprecated)]
extern crate rand;
use self::rand::Rng;

View file

@ -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() }

View file

@ -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;

View file

@ -459,6 +459,7 @@ mod tests {
#[cfg(test)]
mod bench {
#![allow(deprecated)] // rand
extern crate test;
mod uint {

View file

@ -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};

View file

@ -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;

View file

@ -1425,6 +1425,8 @@ mod arch_consts {
#[cfg(test)]
mod tests {
#![allow(deprecated)] // rand
use prelude::v1::*;
use iter::repeat;

View file

@ -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;

View file

@ -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};

View file

@ -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(),

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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() {}

View file

@ -12,6 +12,7 @@
#![deny(unused_extern_crates)]
#![allow(unused_variables)]
#![allow(deprecated)]
#![feature(libc)]
#![feature(collections)]
#![feature(rand)]

View file

@ -15,7 +15,6 @@
#![feature(trace_macros, concat_idents)]
#[derive(Default, //~ ERROR
Rand, //~ ERROR
Zero)] //~ ERROR
enum CantDeriveThose {}