From 981bf5f690d1d7c5cf3e1419ac7a7c86dbc7a4d5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 11 Mar 2015 15:24:14 -0700 Subject: Fallout of std::old_io deprecation --- src/libstd/sys/windows/backtrace.rs | 5 +++-- src/libstd/sys/windows/condvar.rs | 4 ++-- src/libstd/sys/windows/ext.rs | 2 ++ src/libstd/sys/windows/mod.rs | 10 ++++++++++ src/libstd/sys/windows/os.rs | 8 +++++--- src/libstd/sys/windows/pipe.rs | 2 ++ src/libstd/sys/windows/stdio.rs | 10 ++++++++++ src/libstd/sys/windows/timer.rs | 2 ++ src/libstd/sys/windows/tty.rs | 2 ++ 9 files changed, 38 insertions(+), 7 deletions(-) (limited to 'src/libstd/sys/windows') diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index b464ba70911..8638099ca69 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -28,9 +28,10 @@ use prelude::v1::*; use dynamic_lib::DynamicLibrary; +use io; +use io::prelude::*; use ffi::CStr; use intrinsics; -use old_io::IoResult; use libc; use mem; use ptr; @@ -292,7 +293,7 @@ impl Drop for Cleanup { fn drop(&mut self) { (self.SymCleanup)(self.handle); } } -pub fn write(w: &mut Writer) -> IoResult<()> { +pub fn write(w: &mut Write) -> io::Result<()> { // According to windows documentation, all dbghelp functions are // single-threaded. static LOCK: StaticMutex = MUTEX_INIT; diff --git a/src/libstd/sys/windows/condvar.rs b/src/libstd/sys/windows/condvar.rs index 071637e3a93..67552255fdb 100644 --- a/src/libstd/sys/windows/condvar.rs +++ b/src/libstd/sys/windows/condvar.rs @@ -12,7 +12,7 @@ use prelude::v1::*; use cell::UnsafeCell; use libc::{self, DWORD}; -use os; +use sys::os; use sys::mutex::{self, Mutex}; use sys::sync as ffi; use time::Duration; @@ -46,7 +46,7 @@ impl Condvar { 0); if r == 0 { const ERROR_TIMEOUT: DWORD = 0x5B4; - debug_assert_eq!(os::errno() as uint, ERROR_TIMEOUT as uint); + debug_assert_eq!(os::errno() as usize, ERROR_TIMEOUT as usize); false } else { true diff --git a/src/libstd/sys/windows/ext.rs b/src/libstd/sys/windows/ext.rs index 1d63da813c9..dc820a4ce45 100644 --- a/src/libstd/sys/windows/ext.rs +++ b/src/libstd/sys/windows/ext.rs @@ -25,6 +25,7 @@ use net; use sys::os_str::Buf; use sys_common::{AsInner, FromInner, AsInnerMut}; +#[allow(deprecated)] use old_io; /// Raw HANDLEs. @@ -52,6 +53,7 @@ impl AsRawHandle for fs::File { } } +#[allow(deprecated)] impl AsRawHandle for old_io::pipe::PipeStream { fn as_raw_handle(&self) -> Handle { self.as_inner().handle() diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 46085826e60..6b0f6a78c85 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -64,6 +64,7 @@ pub type msglen_t = libc::c_int; pub unsafe fn close_sock(sock: sock_t) { let _ = libc::closesocket(sock); } // windows has zero values as errors +#[allow(deprecated)] fn mkerr_winbool(ret: libc::c_int) -> IoResult<()> { if ret == 0 { Err(last_error()) @@ -72,6 +73,7 @@ fn mkerr_winbool(ret: libc::c_int) -> IoResult<()> { } } +#[allow(deprecated)] pub fn last_error() -> IoError { let errno = os::errno() as i32; let mut err = decode_error(errno); @@ -79,6 +81,7 @@ pub fn last_error() -> IoError { err } +#[allow(deprecated)] pub fn last_net_error() -> IoError { let errno = unsafe { c::WSAGetLastError() as i32 }; let mut err = decode_error(errno); @@ -86,11 +89,13 @@ pub fn last_net_error() -> IoError { err } +#[allow(deprecated)] pub fn last_gai_error(_errno: i32) -> IoError { last_net_error() } /// Convert an `errno` value into a high-level error variant and description. +#[allow(deprecated)] pub fn decode_error(errno: i32) -> IoError { let (kind, desc) = match errno { libc::EOF => (old_io::EndOfFile, "end of file"), @@ -134,6 +139,7 @@ pub fn decode_error(errno: i32) -> IoError { IoError { kind: kind, desc: desc, detail: None } } +#[allow(deprecated)] pub fn decode_error_detailed(errno: i32) -> IoError { let mut err = decode_error(errno); err.detail = Some(os::error_string(errno)); @@ -178,11 +184,13 @@ pub fn ms_to_timeval(ms: u64) -> libc::timeval { } } +#[allow(deprecated)] pub fn wouldblock() -> bool { let err = os::errno(); err == libc::WSAEWOULDBLOCK as i32 } +#[allow(deprecated)] pub fn set_nonblocking(fd: sock_t, nb: bool) { let mut set = nb as libc::c_ulong; if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 { @@ -205,6 +213,7 @@ pub fn init_net() { } } +#[allow(deprecated)] pub fn to_utf16(s: Option<&str>) -> IoResult> { match s { Some(s) => Ok(to_utf16_os(OsStr::from_str(s))), @@ -283,6 +292,7 @@ fn fill_utf16_buf_base(mut f1: F1, f2: F2) -> Result } } +#[allow(deprecated)] fn fill_utf16_buf(f1: F1, f2: F2) -> IoResult where F1: FnMut(*mut u16, libc::DWORD) -> libc::DWORD, F2: FnOnce(&[u16]) -> T diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 89cf8a08a68..ecd538abfb4 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -22,6 +22,7 @@ use io; use libc::types::os::arch::extra::LPWCH; use libc::{self, c_int, c_void}; use mem; +#[allow(deprecated)] use old_io::{IoError, IoResult}; use ops::Range; use path::{self, PathBuf}; @@ -134,7 +135,7 @@ pub fn env() -> Env { let ch = GetEnvironmentStringsW(); if ch as usize == 0 { panic!("failure getting env string from OS: {}", - IoError::last_error()); + io::Error::last_os_error()); } Env { base: ch, cur: ch } } @@ -269,7 +270,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) { unsafe { if libc::SetEnvironmentVariableW(k.as_ptr(), v.as_ptr()) == 0 { - panic!("failed to set env: {}", IoError::last_error()); + panic!("failed to set env: {}", io::Error::last_os_error()); } } } @@ -278,7 +279,7 @@ pub fn unsetenv(n: &OsStr) { let v = super::to_utf16_os(n); unsafe { if libc::SetEnvironmentVariableW(v.as_ptr(), ptr::null()) == 0 { - panic!("failed to unset env: {}", IoError::last_error()); + panic!("failed to unset env: {}", io::Error::last_os_error()); } } } @@ -333,6 +334,7 @@ pub fn page_size() -> usize { } } +#[allow(deprecated)] pub unsafe fn pipe() -> IoResult<(FileDesc, FileDesc)> { // Windows pipes work subtly differently than unix pipes, and their // inheritance has to be handled in a different way that I do not diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 1f228b7d32e..2b03e9e7431 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -84,6 +84,8 @@ //! the test suite passing (the suite is in libstd), and that's good enough for //! me! +#![allow(deprecated)] + use prelude::v1::*; use libc; diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index 72ce8b7c6e3..d1bff0e135d 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -135,6 +135,16 @@ impl Stderr { } } +// FIXME: right now this raw stderr handle is used in a few places because +// std::io::stderr_raw isn't exposed, but once that's exposed this impl +// should go away +impl io::Write for Stderr { + fn write(&mut self, data: &[u8]) -> io::Result { + Stderr::write(self, data) + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } +} + impl NoClose { fn new(handle: libc::HANDLE) -> NoClose { NoClose(Some(Handle::new(handle))) diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index a23a90a9cf8..91a7f694181 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -20,6 +20,8 @@ //! Other than that, the implementation is pretty straightforward in terms of //! the other two implementations of timers with nothing *that* new showing up. +#![allow(deprecated)] + use prelude::v1::*; use self::Req::*; diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 37dce423a68..f542cb2323e 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -25,6 +25,8 @@ //! wrapper that performs encoding/decoding, this implementation should switch //! to working in raw UTF-16, with such a wrapper around it. +#![allow(deprecated)] + use prelude::v1::*; use old_io::{self, IoError, IoResult, MemReader}; -- cgit 1.4.1-3-g733a5