diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-31 11:34:17 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-31 15:54:44 -0700 |
| commit | 554946c81eeb4fcfceda782f6c5af394ab3fe8d3 (patch) | |
| tree | 26908e2779beed76296fbe7292bdf6af12dd46f7 /src/libstd/sys | |
| parent | e10ee2c8572421c056ea68e6656fee936e0330d8 (diff) | |
| parent | d4a2c941809f303b97d153e06ba07e95cd245f88 (diff) | |
| download | rust-554946c81eeb4fcfceda782f6c5af394ab3fe8d3.tar.gz rust-554946c81eeb4fcfceda782f6c5af394ab3fe8d3.zip | |
rollup merge of #23873: alexcrichton/remove-deprecated
Conflicts: src/libcollectionstest/fmt.rs src/libcollectionstest/lib.rs src/libcollectionstest/str.rs src/libcore/error.rs src/libstd/fs.rs src/libstd/io/cursor.rs src/libstd/os.rs src/libstd/process.rs src/libtest/lib.rs src/test/run-pass-fulldeps/compiler-calls.rs
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/backtrace.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/fs2.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/helper_signal.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 13 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/timer.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/windows/os.rs | 13 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process.rs | 16 |
9 files changed, 37 insertions, 29 deletions
diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index 99a554a835f..ca805ad0242 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -251,7 +251,6 @@ fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, symaddr: *mut libc::c_void) -> io::Result<()> { use env; - use ffi::AsOsStr; use os::unix::prelude::*; use ptr; diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 2569653811f..6b085c8eb7a 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -388,9 +388,7 @@ mod tests { fn test_file_desc() { // Run this test with some pipes so we don't have to mess around with // opening or closing files. - let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() }; - let mut reader = FileDesc::new(reader, true); - let mut writer = FileDesc::new(writer, true); + let (mut reader, mut writer) = unsafe { ::sys::os::pipe().unwrap() }; writer.write(b"test").unwrap(); let mut buf = [0; 4]; diff --git a/src/libstd/sys/unix/fs2.rs b/src/libstd/sys/unix/fs2.rs index c5d3dce2634..314d694f66a 100644 --- a/src/libstd/sys/unix/fs2.rs +++ b/src/libstd/sys/unix/fs2.rs @@ -12,7 +12,7 @@ use core::prelude::*; use io::prelude::*; use os::unix::prelude::*; -use ffi::{CString, CStr, OsString, AsOsStr, OsStr}; +use ffi::{CString, CStr, OsString, OsStr}; use io::{self, Error, SeekFrom}; use libc::{self, c_int, size_t, off_t, c_char, mode_t}; use mem; diff --git a/src/libstd/sys/unix/helper_signal.rs b/src/libstd/sys/unix/helper_signal.rs index 17c8b21f8b3..fe0ede80fc6 100644 --- a/src/libstd/sys/unix/helper_signal.rs +++ b/src/libstd/sys/unix/helper_signal.rs @@ -11,15 +11,15 @@ #![allow(deprecated)] use libc; -use os; +use sys::os; use sys::fs::FileDesc; pub type signal = libc::c_int; pub fn new() -> (signal, signal) { - let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() }; - (reader, writer) + let (a, b) = unsafe { os::pipe().unwrap() }; + (a.unwrap(), b.unwrap()) } pub fn signal(fd: libc::c_int) { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index fab443feebd..af5b40af938 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -16,7 +16,7 @@ use prelude::v1::*; use os::unix::prelude::*; use error::Error as StdError; -use ffi::{CString, CStr, OsString, OsStr, AsOsStr}; +use ffi::{CString, CStr, OsString, OsStr}; use fmt; use io; use iter; @@ -125,7 +125,8 @@ pub fn getcwd() -> io::Result<PathBuf> { } pub fn chdir(p: &path::Path) -> io::Result<()> { - let p = try!(CString::new(p.as_os_str().as_bytes())); + let p: &OsStr = p.as_ref(); + let p = try!(CString::new(p.as_bytes())); unsafe { match libc::chdir(p.as_ptr()) == (0 as c_int) { true => Ok(()), @@ -158,13 +159,13 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError> - where I: Iterator<Item=T>, T: AsOsStr + where I: Iterator<Item=T>, T: AsRef<OsStr> { let mut joined = Vec::new(); let sep = b':'; for (i, path) in paths.enumerate() { - let path = path.as_os_str().as_bytes(); + let path = path.as_ref().as_bytes(); if i > 0 { joined.push(sep) } if path.contains(&sep) { return Err(JoinPathsError) @@ -464,7 +465,7 @@ pub fn page_size() -> usize { } pub fn temp_dir() -> PathBuf { - getenv("TMPDIR".as_os_str()).map(os2path).unwrap_or_else(|| { + getenv("TMPDIR".as_ref()).map(os2path).unwrap_or_else(|| { if cfg!(target_os = "android") { PathBuf::from("/data/local/tmp") } else { @@ -474,7 +475,7 @@ pub fn temp_dir() -> PathBuf { } pub fn home_dir() -> Option<PathBuf> { - return getenv("HOME".as_os_str()).or_else(|| unsafe { + return getenv("HOME".as_ref()).or_else(|| unsafe { fallback() }).map(os2path); diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 0d35ace185d..8095325f83d 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -19,8 +19,9 @@ use hash::Hash; use old_io::process::{ProcessExit, ExitStatus, ExitSignal}; use old_io::{IoResult, EndOfFile}; use libc::{self, pid_t, c_void, c_int}; +use io; use mem; -use os; +use sys::os; use old_path::BytesContainer; use ptr; use sync::mpsc::{channel, Sender, Receiver}; @@ -496,7 +497,8 @@ impl Process { n if n > 0 => { ret = true; } 0 => return true, -1 if wouldblock() => return ret, - n => panic!("bad read {:?} ({:?})", os::last_os_error(), n), + n => panic!("bad read {} ({})", + io::Error::last_os_error(), n), } } } diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index d9a162302fc..9309147b15c 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -54,7 +54,8 @@ use self::Req::*; use old_io::IoResult; use libc; use mem; -use os; +use sys::os; +use io; use ptr; use sync::atomic::{self, Ordering}; use sync::mpsc::{channel, Sender, Receiver, TryRecvError}; @@ -209,7 +210,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) { -1 if os::errno() == libc::EINTR as i32 => {} n => panic!("helper thread failed in select() with error: {} ({})", - n, os::last_os_error()) + n, io::Error::last_os_error()) } } } diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 5cd90b0902b..ef153c7e845 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -16,7 +16,7 @@ use prelude::v1::*; use os::windows::prelude::*; use error::Error as StdError; -use ffi::{OsString, OsStr, AsOsStr}; +use ffi::{OsString, OsStr}; use fmt; use io; use libc::types::os::arch::extra::LPWCH; @@ -199,13 +199,13 @@ impl<'a> Iterator for SplitPaths<'a> { pub struct JoinPathsError; pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError> - where I: Iterator<Item=T>, T: AsOsStr + where I: Iterator<Item=T>, T: AsRef<OsStr> { let mut joined = Vec::new(); let sep = b';' as u16; for (i, path) in paths.enumerate() { - let path = path.as_os_str(); + let path = path.as_ref(); if i > 0 { joined.push(sep) } let v = path.encode_wide().collect::<Vec<u16>>(); if v.contains(&(b'"' as u16)) { @@ -245,7 +245,8 @@ pub fn getcwd() -> io::Result<PathBuf> { } pub fn chdir(p: &path::Path) -> io::Result<()> { - let mut p = p.as_os_str().encode_wide().collect::<Vec<_>>(); + let p: &OsStr = p.as_ref(); + let mut p = p.encode_wide().collect::<Vec<_>>(); p.push(0); unsafe { @@ -361,8 +362,8 @@ pub fn temp_dir() -> PathBuf { } pub fn home_dir() -> Option<PathBuf> { - getenv("HOME".as_os_str()).or_else(|| { - getenv("USERPROFILE".as_os_str()) + getenv("HOME".as_ref()).or_else(|| { + getenv("USERPROFILE".as_ref()) }).map(PathBuf::from).or_else(|| unsafe { let me = c::GetCurrentProcess(); let mut token = ptr::null_mut(); diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 297f6e173ab..2065df4fbe3 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -23,6 +23,7 @@ use mem; use old_io::process::{ProcessExit, ExitStatus}; use old_io::{IoResult, IoError}; use old_io; +use fs::PathExt; use os; use old_path::{BytesContainer, GenericPath}; use ptr; @@ -142,14 +143,19 @@ impl Process { let program = cfg.env().and_then(|env| { for (key, v) in env { if b"PATH" != key.container_as_bytes() { continue } + let v = match ::str::from_utf8(v.container_as_bytes()) { + Ok(s) => s, + Err(..) => continue, + }; // Split the value and test each path to see if the // program exists. - for path in os::split_paths(v.container_as_bytes()) { - let path = path.join(cfg.program().as_bytes()) + for path in ::env::split_paths(v) { + let program = str::from_utf8(cfg.program().as_bytes()).unwrap(); + let path = path.join(program) .with_extension(env::consts::EXE_EXTENSION); if path.exists() { - return Some(CString::from_slice(path.as_vec())) + return Some(CString::new(path.to_str().unwrap()).unwrap()) } } break @@ -482,9 +488,9 @@ mod tests { #[test] fn test_make_command_line() { fn test_wrapper(prog: &str, args: &[&str]) -> String { - make_command_line(&CString::from_slice(prog.as_bytes()), + make_command_line(&CString::new(prog), &args.iter() - .map(|a| CString::from_slice(a.as_bytes())) + .map(|a| CString::new(a)) .collect::<Vec<CString>>()) } |
