Skip to content

Commit 88a145e

Browse files
committed
rollup merge of rust-lang#24303: alexcrichton/remove-deprecated
This commit removes these long deprecated modules. Such a nice diff stat!
2 parents 330466e + b8760af commit 88a145e

File tree

143 files changed

+621
-25016
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+621
-25016
lines changed

src/compiletest/compiletest.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
#![feature(box_syntax)]
1414
#![feature(collections)]
15-
#![feature(old_io)]
1615
#![feature(rustc_private)]
17-
#![feature(unboxed_closures)]
1816
#![feature(std_misc)]
1917
#![feature(test)]
2018
#![feature(path_ext)]
2119
#![feature(str_char)]
20+
#![feature(libc)]
2221

2322
#![deny(warnings)]
2423

24+
extern crate libc;
2525
extern crate test;
2626
extern crate getopts;
2727

@@ -42,6 +42,7 @@ pub mod header;
4242
pub mod runtest;
4343
pub mod common;
4444
pub mod errors;
45+
mod raise_fd_limit;
4546

4647
pub fn main() {
4748
let config = parse_config(env::args().collect());
@@ -245,11 +246,7 @@ pub fn run_tests(config: &Config) {
245246
// sadly osx needs some file descriptor limits raised for running tests in
246247
// parallel (especially when we have lots and lots of child processes).
247248
// For context, see #8904
248-
#[allow(deprecated)]
249-
fn raise_fd_limit() {
250-
std::old_io::test::raise_fd_limit();
251-
}
252-
raise_fd_limit();
249+
unsafe { raise_fd_limit::raise_fd_limit(); }
253250
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
254251
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
255252
env::set_var("__COMPAT_LAYER", "RunAsInvoker");

src/compiletest/raise_fd_limit.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
/// darwin_fd_limit exists to work around an issue where launchctl on Mac OS X
12+
/// defaults the rlimit maxfiles to 256/unlimited. The default soft limit of 256
13+
/// ends up being far too low for our multithreaded scheduler testing, depending
14+
/// on the number of cores available.
15+
///
16+
/// This fixes issue #7772.
17+
#[cfg(any(target_os = "macos", target_os = "ios"))]
18+
#[allow(non_camel_case_types)]
19+
pub unsafe fn raise_fd_limit() {
20+
use libc;
21+
use std::cmp;
22+
use std::io;
23+
use std::mem::size_of_val;
24+
use std::ptr::null_mut;
25+
26+
type rlim_t = libc::uint64_t;
27+
28+
#[repr(C)]
29+
struct rlimit {
30+
rlim_cur: rlim_t,
31+
rlim_max: rlim_t
32+
}
33+
extern {
34+
// name probably doesn't need to be mut, but the C function doesn't
35+
// specify const
36+
fn sysctl(name: *mut libc::c_int, namelen: libc::c_uint,
37+
oldp: *mut libc::c_void, oldlenp: *mut libc::size_t,
38+
newp: *mut libc::c_void, newlen: libc::size_t) -> libc::c_int;
39+
fn getrlimit(resource: libc::c_int, rlp: *mut rlimit) -> libc::c_int;
40+
fn setrlimit(resource: libc::c_int, rlp: *const rlimit) -> libc::c_int;
41+
}
42+
static CTL_KERN: libc::c_int = 1;
43+
static KERN_MAXFILESPERPROC: libc::c_int = 29;
44+
static RLIMIT_NOFILE: libc::c_int = 8;
45+
46+
// The strategy here is to fetch the current resource limits, read the
47+
// kern.maxfilesperproc sysctl value, and bump the soft resource limit for
48+
// maxfiles up to the sysctl value.
49+
50+
// Fetch the kern.maxfilesperproc value
51+
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
52+
let mut maxfiles: libc::c_int = 0;
53+
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
54+
if sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
55+
null_mut(), 0) != 0 {
56+
let err = io::Error::last_os_error();
57+
panic!("raise_fd_limit: error calling sysctl: {}", err);
58+
}
59+
60+
// Fetch the current resource limits
61+
let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
62+
if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 {
63+
let err = io::Error::last_os_error();
64+
panic!("raise_fd_limit: error calling getrlimit: {}", err);
65+
}
66+
67+
// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard
68+
// limit
69+
rlim.rlim_cur = cmp::min(maxfiles as rlim_t, rlim.rlim_max);
70+
71+
// Set our newly-increased resource limit
72+
if setrlimit(RLIMIT_NOFILE, &rlim) != 0 {
73+
let err = io::Error::last_os_error();
74+
panic!("raise_fd_limit: error calling setrlimit: {}", err);
75+
}
76+
}
77+
78+
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
79+
pub unsafe fn raise_fd_limit() {}

src/compiletest/runtest.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::net::TcpStream;
2929
use std::path::{Path, PathBuf};
3030
use std::process::{Command, Output, ExitStatus};
3131
use std::str;
32-
use std::time::Duration;
3332
use test::MetricMap;
3433

3534
pub fn run(config: Config, testfile: &Path) {
@@ -452,11 +451,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
452451
.expect(&format!("failed to exec `{:?}`", config.adb_path));
453452
loop {
454453
//waiting 1 second for gdbserver start
455-
#[allow(deprecated)]
456-
fn sleep() {
457-
::std::old_io::timer::sleep(Duration::milliseconds(1000));
458-
}
459-
sleep();
454+
::std::thread::sleep_ms(1000);
460455
if TcpStream::connect("127.0.0.1:5039").is_ok() {
461456
break
462457
}

src/libcollections/linked_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ mod test {
943943
use std::clone::Clone;
944944
use std::iter::Iterator;
945945
use std::option::Option::{Some, None, self};
946-
use std::rand;
946+
use std::__rand::{thread_rng, Rng};
947947
use std::thread;
948948
use std::vec::Vec;
949949

@@ -1095,7 +1095,7 @@ mod test {
10951095
let mut v = vec![];
10961096
for i in 0..sz {
10971097
check_links(&m);
1098-
let r: u8 = rand::random();
1098+
let r: u8 = thread_rng().next_u32() as u8;
10991099
match r % 6 {
11001100
0 => {
11011101
m.pop_back();

src/libcollectionstest/bench.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ macro_rules! map_insert_rand_bench {
1212
($name: ident, $n: expr, $map: ident) => (
1313
#[bench]
1414
pub fn $name(b: &mut ::test::Bencher) {
15-
use std::rand;
16-
use std::rand::Rng;
15+
use std::__rand::{thread_rng, Rng};
1716
use test::black_box;
1817

1918
let n: usize = $n;
2019
let mut map = $map::new();
2120
// setup
22-
let mut rng = rand::weak_rng();
21+
let mut rng = thread_rng();
2322

2423
for _ in 0..n {
2524
let i = rng.gen::<usize>() % n;
@@ -67,16 +66,15 @@ macro_rules! map_find_rand_bench {
6766
#[bench]
6867
pub fn $name(b: &mut ::test::Bencher) {
6968
use std::iter::Iterator;
70-
use std::rand::Rng;
71-
use std::rand;
69+
use std::__rand::{thread_rng, Rng};
7270
use std::vec::Vec;
7371
use test::black_box;
7472

7573
let mut map = $map::new();
7674
let n: usize = $n;
7775

7876
// setup
79-
let mut rng = rand::weak_rng();
77+
let mut rng = thread_rng();
8078
let mut keys: Vec<_> = (0..n).map(|_| rng.gen::<usize>() % n).collect();
8179

8280
for &k in &keys {

src/libcollectionstest/bit/set.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,15 @@ fn test_bit_vec_clone() {
389389

390390
mod bench {
391391
use std::collections::{BitSet, BitVec};
392-
use std::rand::{Rng, self};
392+
use std::__rand::{Rng, thread_rng, ThreadRng};
393393
use std::u32;
394394

395395
use test::{Bencher, black_box};
396396

397397
const BENCH_BITS : usize = 1 << 14;
398398

399-
fn rng() -> rand::IsaacRng {
400-
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
401-
rand::SeedableRng::from_seed(seed)
399+
fn rng() -> ThreadRng {
400+
thread_rng()
402401
}
403402

404403
#[bench]

src/libcollectionstest/bit/vec.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,14 @@ fn test_bit_vec_extend() {
633633
mod bench {
634634
use std::collections::BitVec;
635635
use std::u32;
636-
use std::rand::{Rng, self};
636+
use std::__rand::{Rng, thread_rng, ThreadRng};
637637

638638
use test::{Bencher, black_box};
639639

640640
const BENCH_BITS : usize = 1 << 14;
641641

642-
fn rng() -> rand::IsaacRng {
643-
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
644-
rand::SeedableRng::from_seed(seed)
642+
fn rng() -> ThreadRng {
643+
thread_rng()
645644
}
646645

647646
#[bench]

src/libcollectionstest/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn test_entry(){
251251

252252
mod bench {
253253
use std::collections::BTreeMap;
254-
use std::rand::{Rng, weak_rng};
254+
use std::__rand::{Rng, thread_rng};
255255

256256
use test::{Bencher, black_box};
257257

@@ -269,7 +269,7 @@ mod bench {
269269

270270
fn bench_iter(b: &mut Bencher, size: i32) {
271271
let mut map = BTreeMap::<i32, i32>::new();
272-
let mut rng = weak_rng();
272+
let mut rng = thread_rng();
273273

274274
for _ in 0..size {
275275
map.insert(rng.gen(), rng.gen());

src/libcollectionstest/slice.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::cmp::Ordering::{Equal, Greater, Less};
1212
use std::default::Default;
1313
use std::iter::RandomAccessIterator;
1414
use std::mem;
15-
use std::rand::{Rng, thread_rng};
15+
use std::__rand::{Rng, thread_rng};
1616
use std::rc::Rc;
1717
use std::slice::ElementSwaps;
1818

@@ -1296,7 +1296,7 @@ fn test_to_vec() {
12961296
mod bench {
12971297
use std::iter::repeat;
12981298
use std::{mem, ptr};
1299-
use std::rand::{Rng, weak_rng};
1299+
use std::__rand::{Rng, thread_rng};
13001300

13011301
use test::{Bencher, black_box};
13021302

@@ -1465,7 +1465,7 @@ mod bench {
14651465

14661466
#[bench]
14671467
fn random_inserts(b: &mut Bencher) {
1468-
let mut rng = weak_rng();
1468+
let mut rng = thread_rng();
14691469
b.iter(|| {
14701470
let mut v: Vec<_> = repeat((0, 0)).take(30).collect();
14711471
for _ in 0..100 {
@@ -1477,7 +1477,7 @@ mod bench {
14771477
}
14781478
#[bench]
14791479
fn random_removes(b: &mut Bencher) {
1480-
let mut rng = weak_rng();
1480+
let mut rng = thread_rng();
14811481
b.iter(|| {
14821482
let mut v: Vec<_> = repeat((0, 0)).take(130).collect();
14831483
for _ in 0..100 {
@@ -1489,7 +1489,7 @@ mod bench {
14891489

14901490
#[bench]
14911491
fn sort_random_small(b: &mut Bencher) {
1492-
let mut rng = weak_rng();
1492+
let mut rng = thread_rng();
14931493
b.iter(|| {
14941494
let mut v: Vec<_> = rng.gen_iter::<u64>().take(5).collect();
14951495
v.sort();
@@ -1499,7 +1499,7 @@ mod bench {
14991499

15001500
#[bench]
15011501
fn sort_random_medium(b: &mut Bencher) {
1502-
let mut rng = weak_rng();
1502+
let mut rng = thread_rng();
15031503
b.iter(|| {
15041504
let mut v: Vec<_> = rng.gen_iter::<u64>().take(100).collect();
15051505
v.sort();
@@ -1509,7 +1509,7 @@ mod bench {
15091509

15101510
#[bench]
15111511
fn sort_random_large(b: &mut Bencher) {
1512-
let mut rng = weak_rng();
1512+
let mut rng = thread_rng();
15131513
b.iter(|| {
15141514
let mut v: Vec<_> = rng.gen_iter::<u64>().take(10000).collect();
15151515
v.sort();
@@ -1530,7 +1530,7 @@ mod bench {
15301530

15311531
#[bench]
15321532
fn sort_big_random_small(b: &mut Bencher) {
1533-
let mut rng = weak_rng();
1533+
let mut rng = thread_rng();
15341534
b.iter(|| {
15351535
let mut v = rng.gen_iter::<BigSortable>().take(5)
15361536
.collect::<Vec<BigSortable>>();
@@ -1541,7 +1541,7 @@ mod bench {
15411541

15421542
#[bench]
15431543
fn sort_big_random_medium(b: &mut Bencher) {
1544-
let mut rng = weak_rng();
1544+
let mut rng = thread_rng();
15451545
b.iter(|| {
15461546
let mut v = rng.gen_iter::<BigSortable>().take(100)
15471547
.collect::<Vec<BigSortable>>();
@@ -1552,7 +1552,7 @@ mod bench {
15521552

15531553
#[bench]
15541554
fn sort_big_random_large(b: &mut Bencher) {
1555-
let mut rng = weak_rng();
1555+
let mut rng = thread_rng();
15561556
b.iter(|| {
15571557
let mut v = rng.gen_iter::<BigSortable>().take(10000)
15581558
.collect::<Vec<BigSortable>>();

0 commit comments

Comments
 (0)