diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-08-11 17:27:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-08-12 14:55:17 -0700 |
| commit | 8d90d3f36871a00023cc1f313f91e351c287ca15 (patch) | |
| tree | 2d9b616a2468117aa3afe1f6b1f910ff3116776b /src/librustc/util | |
| parent | d07d465cf60033e35eba16b9e431471d54c712f4 (diff) | |
| download | rust-8d90d3f36871a00023cc1f313f91e351c287ca15.tar.gz rust-8d90d3f36871a00023cc1f313f91e351c287ca15.zip | |
Remove all unstable deprecated functionality
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
Diffstat (limited to 'src/librustc/util')
| -rw-r--r-- | src/librustc/util/common.rs | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index db0f820e11b..beb95697201 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -75,24 +75,28 @@ pub fn time<T, U, F>(do_it: bool, what: &str, u: U, f: F) -> T where rv } +// Like std::macros::try!, but for Option<>. +macro_rules! option_try( + ($e:expr) => (match $e { Some(e) => e, None => return None }) +); + // Memory reporting #[cfg(unix)] fn get_resident() -> Option<usize> { - get_proc_self_statm_field(1) -} + use std::fs::File; + use std::io::Read; -#[cfg(windows)] -fn get_resident() -> Option<usize> { - get_working_set_size() + let field = 1; + let mut f = option_try!(File::open("/proc/self/statm").ok()); + let mut contents = String::new(); + option_try!(f.read_to_string(&mut contents).ok()); + let s = option_try!(contents.split_whitespace().nth(field)); + let npages = option_try!(s.parse::<usize>().ok()); + Some(npages * 4096) } -// Like std::macros::try!, but for Option<>. -macro_rules! option_try( - ($e:expr) => (match $e { Some(e) => e, None => return None }) -); - #[cfg(windows)] -fn get_working_set_size() -> Option<usize> { +fn get_resident() -> Option<usize> { use libc::{BOOL, DWORD, HANDLE, SIZE_T, GetCurrentProcess}; use std::mem; #[repr(C)] #[allow(non_snake_case)] @@ -123,22 +127,6 @@ fn get_working_set_size() -> Option<usize> { } } -#[cfg_attr(windows, allow(dead_code))] -#[allow(deprecated)] -fn get_proc_self_statm_field(field: usize) -> Option<usize> { - use std::fs::File; - use std::io::Read; - - assert!(cfg!(unix)); - - let mut f = option_try!(File::open("/proc/self/statm").ok()); - let mut contents = String::new(); - option_try!(f.read_to_string(&mut contents).ok()); - let s = option_try!(contents.split_whitespace().nth(field)); - let npages = option_try!(s.parse::<usize>().ok()); - Some(npages * ::std::env::page_size()) -} - pub fn indent<R, F>(op: F) -> R where R: Debug, F: FnOnce() -> R, |
