diff options
| author | Brian Anderson <banderson@mozilla.com> | 2015-01-27 09:38:30 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2015-01-27 15:05:04 -0800 |
| commit | 71223050538939ed758fcd3b9114f71abff20bb2 (patch) | |
| tree | 43ddd18223904fa86601f1a0e16ebcbaddead270 /src/libstd | |
| parent | 3c172392cf0c86ffd1d7b39d3f44de98f77afc44 (diff) | |
| parent | 777435990e0e91df6b72ce80c9b6fa485eeb5daa (diff) | |
| download | rust-71223050538939ed758fcd3b9114f71abff20bb2.tar.gz rust-71223050538939ed758fcd3b9114f71abff20bb2.zip | |
Merge remote-tracking branch 'rust-lang/master'
Conflicts: src/libcore/cell.rs src/librustc_driver/test.rs src/libstd/old_io/net/tcp.rs src/libstd/old_io/process.rs
Diffstat (limited to 'src/libstd')
57 files changed, 600 insertions, 575 deletions
diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 028973a1cf1..c184d3f4661 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -14,12 +14,12 @@ use prelude::v1::*; use any::Any; use cell::RefCell; -use io::IoResult; +use old_io::IoResult; use rt::{backtrace, unwind}; use rt::util::{Stderr, Stdio}; use thread::Thread; -// Defined in this module instead of io::stdio so that the unwinding +// Defined in this module instead of old_io::stdio so that the unwinding thread_local! { pub static LOCAL_STDERR: RefCell<Option<Box<Writer + Send>>> = { RefCell::new(None) @@ -27,7 +27,7 @@ thread_local! { } impl Writer for Stdio { - fn write(&mut self, bytes: &[u8]) -> IoResult<()> { + fn write_all(&mut self, bytes: &[u8]) -> IoResult<()> { let _ = self.write_bytes(bytes); Ok(()) } diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index 6f2e011d595..4ab43e875cd 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -238,7 +238,7 @@ //! //! ```ignore //! format! // described above -//! write! // first argument is a &mut io::Writer, the destination +//! write! // first argument is a &mut old_io::Writer, the destination //! writeln! // same as write but appends a newline //! print! // the format string is printed to the standard output //! println! // same as print but appends a newline @@ -255,10 +255,8 @@ //! //! ```rust //! # #![allow(unused_must_use)] -//! use std::io; -//! //! let mut w = Vec::new(); -//! write!(&mut w as &mut io::Writer, "Hello {}!", "world"); +//! write!(&mut w, "Hello {}!", "world"); //! ``` //! //! #### `print!` @@ -282,15 +280,15 @@ //! //! ``` //! use std::fmt; -//! use std::io; +//! use std::old_io; //! //! fmt::format(format_args!("this returns {}", "String")); //! -//! let some_writer: &mut io::Writer = &mut io::stdout(); -//! write!(some_writer, "{}", format_args!("print with a {}", "macro")); +//! let mut some_writer = old_io::stdout(); +//! write!(&mut some_writer, "{}", format_args!("print with a {}", "macro")); //! //! fn my_fmt_fn(args: fmt::Arguments) { -//! write!(&mut io::stdout(), "{}", args); +//! write!(&mut old_io::stdout(), "{}", args); //! } //! my_fmt_fn(format_args!("or a {} too", "function")); //! ``` diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 4827bc2b3c8..3a745389e1e 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -79,7 +79,8 @@ //! memory types, including [`atomic`](sync/atomic/index.html). //! //! Common types of I/O, including files, TCP, UDP, pipes, Unix domain sockets, -//! timers, and process spawning, are defined in the [`io`](io/index.html) module. +//! timers, and process spawning, are defined in the +//! [`old_io`](old_io/index.html) module. //! //! Rust's I/O and concurrency depends on a small runtime interface //! that lives, along with its support code, in mod [`rt`](rt/index.html). @@ -247,7 +248,7 @@ pub mod thread_local; pub mod dynamic_lib; pub mod ffi; pub mod fmt; -pub mod io; +pub mod old_io; pub mod os; pub mod path; pub mod rand; @@ -292,7 +293,7 @@ mod std { pub use sync; // used for select!() pub use error; // used for try!() pub use fmt; // used for any formatting strings - pub use io; // used for println!() + pub use old_io; // used for println!() pub use option; // used for bitflags!{} pub use rt; // used for panic!() pub use vec; // used for vec![] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 5d1f2aa9b1e..9c3285a9d08 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -81,14 +81,14 @@ macro_rules! format { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! print { - ($($arg:tt)*) => ($crate::io::stdio::print_args(format_args!($($arg)*))) + ($($arg:tt)*) => ($crate::old_io::stdio::print_args(format_args!($($arg)*))) } /// Macro for printing to a task's stdout handle. /// -/// Each task can override its stdout handle via `std::io::stdio::set_stdout`. +/// Each task can override its stdout handle via `std::old_io::stdio::set_stdout`. /// The syntax of this macro is the same as that used for `format!`. For more -/// information, see `std::fmt` and `std::io::stdio`. +/// information, see `std::fmt` and `std::old_io::stdio`. /// /// # Example /// @@ -99,7 +99,7 @@ macro_rules! print { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! println { - ($($arg:tt)*) => ($crate::io::stdio::println_args(format_args!($($arg)*))) + ($($arg:tt)*) => ($crate::old_io::stdio::println_args(format_args!($($arg)*))) } /// Helper macro for unwrapping `Result` values while returning early with an diff --git a/src/libstd/io/buffered.rs b/src/libstd/old_io/buffered.rs index 1c1c73cddd1..1590598c0b8 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/old_io/buffered.rs @@ -14,7 +14,7 @@ use cmp; use fmt; -use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult}; +use old_io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult}; use iter::{IteratorExt, ExactSizeIterator, repeat}; use ops::Drop; use option::Option; @@ -34,7 +34,7 @@ use vec::Vec; /// # Example /// /// ```rust -/// use std::io::{BufferedReader, File}; +/// use std::old_io::{BufferedReader, File}; /// /// let file = File::open(&Path::new("message.txt")); /// let mut reader = BufferedReader::new(file); @@ -137,7 +137,7 @@ impl<R: Reader> Reader for BufferedReader<R> { /// # Example /// /// ```rust -/// use std::io::{BufferedWriter, File}; +/// use std::old_io::{BufferedWriter, File}; /// /// let file = File::create(&Path::new("message.txt")).unwrap(); /// let mut writer = BufferedWriter::new(file); @@ -184,7 +184,7 @@ impl<W: Writer> BufferedWriter<W> { fn flush_buf(&mut self) -> IoResult<()> { if self.pos != 0 { - let ret = self.inner.as_mut().unwrap().write(&self.buf[..self.pos]); + let ret = self.inner.as_mut().unwrap().write_all(&self.buf[..self.pos]); self.pos = 0; ret } else { @@ -213,13 +213,13 @@ impl<W: Writer> BufferedWriter<W> { } impl<W: Writer> Writer for BufferedWriter<W> { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { if self.pos + buf.len() > self.buf.len() { try!(self.flush_buf()); } if buf.len() > self.buf.len() { - self.inner.as_mut().unwrap().write(buf) + self.inner.as_mut().unwrap().write_all(buf) } else { let dst = &mut self.buf[self.pos..]; slice::bytes::copy_memory(dst, buf); @@ -281,15 +281,15 @@ impl<W: Writer> LineBufferedWriter<W> { } impl<W: Writer> Writer for LineBufferedWriter<W> { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { match buf.iter().rposition(|&b| b == b'\n') { Some(i) => { - try!(self.inner.write(&buf[..i + 1])); + try!(self.inner.write_all(&buf[..i + 1])); try!(self.inner.flush()); - try!(self.inner.write(&buf[i + 1..])); + try!(self.inner.write_all(&buf[i + 1..])); Ok(()) } - None => self.inner.write(buf), + None => self.inner.write_all(buf), } } @@ -324,12 +324,12 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::{BufferedStream, File}; +/// use std::old_io::{BufferedStream, File}; /// /// let file = File::open(&Path::new("message.txt")); /// let mut stream = BufferedStream::new(file); /// -/// stream.write("hello, world".as_bytes()); +/// stream.write_all("hello, world".as_bytes()); /// stream.flush(); /// /// let mut buf = [0; 100]; @@ -412,8 +412,8 @@ impl<S: Stream> Reader for BufferedStream<S> { } impl<S: Stream> Writer for BufferedStream<S> { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { - self.inner.inner.get_mut().write(buf) + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { + self.inner.inner.get_mut().write_all(buf) } fn flush(&mut self) -> IoResult<()> { self.inner.inner.get_mut().flush() @@ -423,7 +423,7 @@ impl<S: Stream> Writer for BufferedStream<S> { #[cfg(test)] mod test { extern crate test; - use io; + use old_io; use prelude::v1::*; use super::*; use super::super::{IoResult, EndOfFile}; @@ -437,13 +437,13 @@ mod test { pub struct NullStream; impl Reader for NullStream { - fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { - Err(io::standard_error(io::EndOfFile)) + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + Err(old_io::standard_error(old_io::EndOfFile)) } } impl Writer for NullStream { - fn write(&mut self, _: &[u8]) -> io::IoResult<()> { Ok(()) } + fn write_all(&mut self, _: &[u8]) -> old_io::IoResult<()> { Ok(()) } } /// A dummy reader intended at testing short-reads propagation. @@ -452,9 +452,9 @@ mod test { } impl Reader for ShortReader { - fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { if self.lengths.is_empty() { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } else { Ok(self.lengths.remove(0)) } @@ -503,34 +503,34 @@ mod test { let inner = Vec::new(); let mut writer = BufferedWriter::with_capacity(2, inner); - writer.write(&[0, 1]).unwrap(); + writer.write_all(&[0, 1]).unwrap(); let b: &[_] = &[]; assert_eq!(&writer.get_ref()[], b); - writer.write(&[2]).unwrap(); + writer.write_all(&[2]).unwrap(); let b: &[_] = &[0, 1]; assert_eq!(&writer.get_ref()[], b); - writer.write(&[3]).unwrap(); + writer.write_all(&[3]).unwrap(); assert_eq!(&writer.get_ref()[], b); writer.flush().unwrap(); let a: &[_] = &[0, 1, 2, 3]; assert_eq!(a, &writer.get_ref()[]); - writer.write(&[4]).unwrap(); - writer.write(&[5]).unwrap(); + writer.write_all(&[4]).unwrap(); + writer.write_all(&[5]).unwrap(); assert_eq!(a, &writer.get_ref()[]); - writer.write(&[6]).unwrap(); + writer.write_all(&[6]).unwrap(); let a: &[_] = &[0, 1, 2, 3, 4, 5]; assert_eq!(a, &writer.get_ref()[]); - writer.write(&[7, 8]).unwrap(); + writer.write_all(&[7, 8]).unwrap(); let a: &[_] = &[0, 1, 2, 3, 4, 5, 6]; assert_eq!(a, &writer.get_ref()[]); - writer.write(&[9, 10, 11]).unwrap(); + writer.write_all(&[9, 10, 11]).unwrap(); let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; assert_eq!(a, &writer.get_ref()[]); @@ -541,7 +541,7 @@ mod test { #[test] fn test_buffered_writer_inner_flushes() { let mut w = BufferedWriter::with_capacity(3, Vec::new()); - w.write(&[0, 1]).unwrap(); + w.write_all(&[0, 1]).unwrap(); let a: &[_] = &[]; assert_eq!(a, &w.get_ref()[]); let w = w.into_inner(); @@ -555,20 +555,20 @@ mod test { fn test_buffered_stream() { struct S; - impl io::Writer for S { - fn write(&mut self, _: &[u8]) -> io::IoResult<()> { Ok(()) } + impl old_io::Writer for S { + fn write_all(&mut self, _: &[u8]) -> old_io::IoResult<()> { Ok(()) } } - impl io::Reader for S { - fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { - Err(io::standard_error(io::EndOfFile)) + impl old_io::Reader for S { + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + Err(old_io::standard_error(old_io::EndOfFile)) } } let mut stream = BufferedStream::new(S); let mut buf = []; assert!(stream.read(&mut buf).is_err()); - stream.write(&buf).unwrap(); + stream.write_all(&buf).unwrap(); stream.flush().unwrap(); } @@ -586,21 +586,21 @@ mod test { #[test] fn test_line_buffer() { let mut writer = LineBufferedWriter::new(Vec::new()); - writer.write(&[0]).unwrap(); + writer.write_all(&[0]).unwrap(); let b: &[_] = &[]; assert_eq!(&writer.get_ref()[], b); - writer.write(&[1]).unwrap(); + writer.write_all(&[1]).unwrap(); assert_eq!(&writer.get_ref()[], b); writer.flush().unwrap(); let b: &[_] = &[0, 1]; assert_eq!(&writer.get_ref()[], b); - writer.write(&[0, b'\n', 1, b'\n', 2]).unwrap(); + writer.write_all(&[0, b'\n', 1, b'\n', 2]).unwrap(); let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n']; assert_eq!(&writer.get_ref()[], b); writer.flush().unwrap(); let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2]; assert_eq!(&writer.get_ref()[], b); - writer.write(&[3, b'\n']).unwrap(); + writer.write_all(&[3, b'\n']).unwrap(); let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2, 3, b'\n']; assert_eq!(&writer.get_ref()[], b); } @@ -663,8 +663,8 @@ mod test { struct FailFlushWriter; impl Writer for FailFlushWriter { - fn write(&mut self, _buf: &[u8]) -> IoResult<()> { Ok(()) } - fn flush(&mut self) -> IoResult<()> { Err(io::standard_error(EndOfFile)) } + fn write_all(&mut self, _buf: &[u8]) -> IoResult<()> { Ok(()) } + fn flush(&mut self) -> IoResult<()> { Err(old_io::standard_error(EndOfFile)) } } let writer = FailFlushWriter; diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/old_io/comm_adapters.rs index d3d49d41a67..feb2ef6f4f3 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/old_io/comm_adapters.rs @@ -11,7 +11,7 @@ use clone::Clone; use cmp; use sync::mpsc::{Sender, Receiver}; -use io; +use old_io; use option::Option::{None, Some}; use result::Result::{Ok, Err}; use slice::{bytes, SliceExt}; @@ -24,7 +24,7 @@ use vec::Vec; /// /// ``` /// use std::sync::mpsc::channel; -/// use std::io::ChanReader; +/// use std::old_io::ChanReader; /// /// let (tx, rx) = channel(); /// # drop(tx); @@ -70,7 +70,7 @@ impl Buffer for ChanReader { } } if self.closed { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } else { Ok(&self.buf[self.pos..]) } @@ -102,7 +102,7 @@ impl Reader for ChanReader { } } if self.closed && num_read == 0 { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } else { Ok(num_read) } @@ -116,7 +116,7 @@ impl Reader for ChanReader { /// ``` /// # #![allow(unused_must_use)] /// use std::sync::mpsc::channel; -/// use std::io::ChanWriter; +/// use std::old_io::ChanWriter; /// /// let (tx, rx) = channel(); /// # drop(rx); @@ -142,10 +142,10 @@ impl Clone for ChanWriter { } impl Writer for ChanWriter { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.tx.send(buf.to_vec()).map_err(|_| { - io::IoError { - kind: io::BrokenPipe, + old_io::IoError { + kind: old_io::BrokenPipe, desc: "Pipe closed", detail: None } @@ -160,7 +160,7 @@ mod test { use sync::mpsc::channel; use super::*; - use io; + use old_io; use thread::Thread; #[test] @@ -193,14 +193,14 @@ mod test { match reader.read(buf.as_mut_slice()) { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => assert_eq!(e.kind, old_io::EndOfFile), } assert_eq!(a, buf); // Ensure it continues to panic in the same way. match reader.read(buf.as_mut_slice()) { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => assert_eq!(e.kind, old_io::EndOfFile), } assert_eq!(a, buf); } @@ -223,7 +223,7 @@ mod test { assert_eq!(Ok("how are you?".to_string()), reader.read_line()); match reader.read_line() { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => assert_eq!(e.kind, old_io::EndOfFile), } } @@ -242,7 +242,7 @@ mod test { match writer.write_u8(1) { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::BrokenPipe), + Err(e) => assert_eq!(e.kind, old_io::BrokenPipe), } } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/old_io/extensions.rs index af08eea210e..826271a9f83 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/old_io/extensions.rs @@ -15,8 +15,8 @@ // FIXME: Not sure how this should be structured // FIXME: Iteration should probably be considered separately -use io::{IoError, IoResult, Reader}; -use io; +use old_io::{IoError, IoResult, Reader}; +use old_io; use iter::Iterator; use num::Int; use ops::FnOnce; @@ -59,7 +59,7 @@ impl<'r, R: Reader> Iterator for Bytes<'r, R> { fn next(&mut self) -> Option<IoResult<u8>> { match self.reader.read_byte() { Ok(x) => Some(Ok(x)), - Err(IoError { kind: io::EndOfFile, .. }) => None, + Err(IoError { kind: old_io::EndOfFile, .. }) => None, Err(e) => Some(Err(e)) } } @@ -178,15 +178,15 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { #[cfg(test)] mod test { use prelude::v1::*; - use io; - use io::{MemReader, BytesReader}; + use old_io; + use old_io::{MemReader, BytesReader}; struct InitialZeroByteReader { count: int, } impl Reader for InitialZeroByteReader { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { if self.count == 0 { self.count = 1; Ok(0) @@ -200,16 +200,16 @@ mod test { struct EofReader; impl Reader for EofReader { - fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { - Err(io::standard_error(io::EndOfFile)) + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + Err(old_io::standard_error(old_io::EndOfFile)) } } struct ErroringReader; impl Reader for ErroringReader { - fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> { - Err(io::standard_error(io::InvalidInput)) + fn read(&mut self, _: &mut [u8]) -> old_io::IoResult<uint> { + Err(old_io::standard_error(old_io::InvalidInput)) } } @@ -218,7 +218,7 @@ mod test { } impl Reader for PartialReader { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { if self.count == 0 { self.count = 1; buf[0] = 10; @@ -237,13 +237,13 @@ mod test { } impl Reader for ErroringLaterReader { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { if self.count == 0 { self.count = 1; buf[0] = 10; Ok(1) } else { - Err(io::standard_error(io::InvalidInput)) + Err(old_io::standard_error(old_io::InvalidInput)) } } } @@ -253,7 +253,7 @@ mod test { } impl Reader for ThreeChunkReader { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { if self.count == 0 { self.count = 1; buf[0] = 10; @@ -265,7 +265,7 @@ mod test { buf[1] = 13; Ok(2) } else { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } } } diff --git a/src/libstd/io/fs.rs b/src/libstd/old_io/fs.rs index cc36c5640d0..a1ac5d2eab0 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/old_io/fs.rs @@ -18,21 +18,21 @@ //! At the top-level of the module are a set of freestanding functions, associated //! with various filesystem operations. They all operate on `Path` objects. //! -//! All operations in this module, including those as part of `File` et al -//! block the task during execution. In the event of failure, all functions/methods +//! All operations in this module, including those as part of `File` et al block +//! the task during execution. In the event of failure, all functions/methods //! will return an `IoResult` type with an `Err` value. //! //! Also included in this module is an implementation block on the `Path` object -//! defined in `std::path::Path`. The impl adds useful methods about inspecting the -//! metadata of a file. This includes getting the `stat` information, reading off -//! particular bits of it, etc. +//! defined in `std::path::Path`. The impl adds useful methods about inspecting +//! the metadata of a file. This includes getting the `stat` information, +//! reading off particular bits of it, etc. //! //! # Example //! //! ```rust //! # #![allow(unused_must_use)] -//! use std::io::fs::PathExtensions; -//! use std::io::{File, fs}; +//! use std::old_io::fs::PathExtensions; +//! use std::old_io::{File, fs}; //! //! let path = Path::new("foo.txt"); //! @@ -51,13 +51,13 @@ //! ``` use clone::Clone; -use io::standard_error; -use io::{FilePermission, Write, Open, FileAccess, FileMode, FileType}; -use io::{IoResult, IoError, InvalidInput}; -use io::{FileStat, SeekStyle, Seek, Writer, Reader}; -use io::{Read, Truncate, ReadWrite, Append}; -use io::UpdateIoError; -use io; +use old_io::standard_error; +use old_io::{FilePermission, Write, Open, FileAccess, FileMode, FileType}; +use old_io::{IoResult, IoError, InvalidInput}; +use old_io::{FileStat, SeekStyle, Seek, Writer, Reader}; +use old_io::{Read, Truncate, ReadWrite, Append}; +use old_io::UpdateIoError; +use old_io; use iter::{Iterator, Extend}; use option::Option; use option::Option::{Some, None}; @@ -101,7 +101,7 @@ impl File { /// # Example /// /// ```rust,should_fail - /// use std::io::{File, Open, ReadWrite}; + /// use std::old_io::{File, Open, ReadWrite}; /// /// let p = Path::new("/some/file/path.txt"); /// @@ -170,7 +170,7 @@ impl File { /// # Example /// /// ```rust - /// use std::io::File; + /// use std::old_io::File; /// /// let contents = File::open(&Path::new("foo.txt")).read_to_end(); /// ``` @@ -188,12 +188,12 @@ impl File { /// /// ```rust /// # #![allow(unused_must_use)] - /// use std::io::File; + /// use std::old_io::File; /// /// let mut f = File::create(&Path::new("foo.txt")); /// f.write(b"This is a sample file"); /// # drop(f); - /// # ::std::io::fs::unlink(&Path::new("foo.txt")); + /// # ::std::old_io::fs::unlink(&Path::new("foo.txt")); /// ``` pub fn create(path: &Path) -> IoResult<File> { File::open_mode(path, Truncate, Write) @@ -265,7 +265,7 @@ impl File { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::fs; +/// use std::old_io::fs; /// /// let p = Path::new("/some/file/path.txt"); /// fs::unlink(&p); @@ -293,7 +293,7 @@ pub fn unlink(path: &Path) -> IoResult<()> { /// # Example /// /// ```rust -/// use std::io::fs; +/// use std::old_io::fs; /// /// let p = Path::new("/some/file/path.txt"); /// match fs::stat(&p) { @@ -333,7 +333,7 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::fs; +/// use std::old_io::fs; /// /// fs::rename(&Path::new("foo"), &Path::new("bar")); /// ``` @@ -359,7 +359,7 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::fs; +/// use std::old_io::fs; /// /// fs::copy(&Path::new("foo.txt"), &Path::new("bar.txt")); /// ``` @@ -386,7 +386,7 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { if !from.is_file() { return update_err(Err(IoError { - kind: io::MismatchedFileTypeForOperation, + kind: old_io::MismatchedFileTypeForOperation, desc: "the source path is not an existing file", detail: None }), from, to) @@ -407,13 +407,13 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io; -/// use std::io::fs; +/// use std::old_io; +/// use std::old_io::fs; /// -/// fs::chmod(&Path::new("file.txt"), io::USER_FILE); -/// fs::chmod(&Path::new("file.txt"), io::USER_READ | io::USER_WRITE); -/// fs::chmod(&Path::new("dir"), io::USER_DIR); -/// fs::chmod(&Path::new("file.exe"), io::USER_EXEC); +/// fs::chmod(&Path::new("file.txt"), old_io::USER_FILE); +/// fs::chmod(&Path::new("file.txt"), old_io::USER_READ | old_io::USER_WRITE); +/// fs::chmod(&Path::new("dir"), old_io::USER_DIR); +/// fs::chmod(&Path::new("file.exe"), old_io::USER_EXEC); /// ``` /// /// # Error @@ -421,7 +421,7 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> { /// This function will return an error if the provided `path` doesn't exist, if /// the process lacks permissions to change the attributes of the file, or if /// some other I/O error is encountered. -pub fn chmod(path: &Path, mode: io::FilePermission) -> IoResult<()> { +pub fn chmod(path: &Path, mode: old_io::FilePermission) -> IoResult<()> { fs_imp::chmod(path, mode.bits() as uint) .update_err("couldn't chmod path", |e| format!("{}; path={}; mode={:?}", e, path.display(), mode)) @@ -469,11 +469,11 @@ pub fn readlink(path: &Path) -> IoResult<Path> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io; -/// use std::io::fs; +/// use std::old_io; +/// use std::old_io::fs; /// /// let p = Path::new("/some/dir"); -/// fs::mkdir(&p, io::USER_RWX); +/// fs::mkdir(&p, old_io::USER_RWX); /// ``` /// /// # Error @@ -492,7 +492,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::fs; +/// use std::old_io::fs; /// /// let p = Path::new("/some/dir"); /// fs::rmdir(&p); @@ -513,12 +513,12 @@ pub fn rmdir(path: &Path) -> IoResult<()> { /// # Example /// /// ```rust -/// use std::io::fs::PathExtensions; -/// use std::io::fs; -/// use std::io; +/// use std::old_io::fs::PathExtensions; +/// use std::old_io::fs; +/// use std::old_io; /// /// // one possible implementation of fs::walk_dir only visiting files -/// fn visit_dirs<F>(dir: &Path, cb: &mut F) -> io::IoResult<()> where +/// fn visit_dirs<F>(dir: &Path, cb: &mut F) -> old_io::IoResult<()> where /// F: FnMut(&Path), /// { /// if dir.is_dir() { @@ -532,7 +532,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> { /// } /// Ok(()) /// } else { -/// Err(io::standard_error(io::InvalidInput)) +/// Err(old_io::standard_error(old_io::InvalidInput)) /// } /// } /// ``` @@ -664,7 +664,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> { // (eg: deleted by someone else since readdir) match update_err(unlink(&child), path) { Ok(()) => (), - Err(ref e) if e.kind == io::FileNotFound => (), + Err(ref e) if e.kind == old_io::FileNotFound => (), Err(e) => return Err(e) } } @@ -675,7 +675,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> { let result = update_err(rmdir(&rm_stack.pop().unwrap()), path); match result { Ok(()) => (), - Err(ref e) if e.kind == io::FileNotFound => (), + Err(ref e) if e.kind == old_io::FileNotFound => (), Err(e) => return Err(e) } } @@ -709,7 +709,7 @@ impl Reader for File { Ok(read) => { self.last_nread = read as int; match read { - 0 => update_err(Err(standard_error(io::EndOfFile)), self), + 0 => update_err(Err(standard_error(old_io::EndOfFile)), self), _ => Ok(read as uint) } }, @@ -719,7 +719,7 @@ impl Reader for File { } impl Writer for File { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.fd.write(buf) .update_err("couldn't write to file", |e| format!("{}; path={}", e, self.path.display())) @@ -824,10 +824,10 @@ fn access_string(access: FileAccess) -> &'static str { #[allow(unused_mut)] mod test { use prelude::v1::*; - use io::{SeekSet, SeekCur, SeekEnd, Read, Open, ReadWrite, FileType}; - use io; + use old_io::{SeekSet, SeekCur, SeekEnd, Read, Open, ReadWrite, FileType}; + use old_io; use str; - use io::fs::*; + use old_io::fs::*; macro_rules! check { ($e:expr) => ( match $e { @@ -863,7 +863,7 @@ mod test { // Gee, seeing how we're testing the fs module I sure hope that we // at least implement this correctly! let TempDir(ref p) = *self; - check!(io::fs::rmdir_recursive(p)); + check!(old_io::fs::rmdir_recursive(p)); } } @@ -871,7 +871,7 @@ mod test { use os; use rand; let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>())); - check!(io::fs::mkdir(&ret, io::USER_RWX)); + check!(old_io::fs::mkdir(&ret, old_io::USER_RWX)); TempDir(ret) } @@ -1055,7 +1055,7 @@ mod test { fn file_test_stat_is_correct_on_is_dir() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_stat_correct_on_is_dir"); - check!(mkdir(filename, io::USER_RWX)); + check!(mkdir(filename, old_io::USER_RWX)); let stat_res_fn = check!(stat(filename)); assert!(stat_res_fn.kind == FileType::Directory); let stat_res_meth = check!(filename.stat()); @@ -1067,7 +1067,7 @@ mod test { fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() { let tmpdir = tmpdir(); let dir = &tmpdir.join("fileinfo_false_on_dir"); - check!(mkdir(dir, io::USER_RWX)); + check!(mkdir(dir, old_io::USER_RWX)); assert!(dir.is_file() == false); check!(rmdir(dir)); } @@ -1087,7 +1087,7 @@ mod test { let tmpdir = tmpdir(); let dir = &tmpdir.join("before_and_after_dir"); assert!(!dir.exists()); - check!(mkdir(dir, io::USER_RWX)); + check!(mkdir(dir, old_io::USER_RWX)); assert!(dir.exists()); assert!(dir.is_dir()); check!(rmdir(dir)); @@ -1099,7 +1099,7 @@ mod test { use str; let tmpdir = tmpdir(); let dir = &tmpdir.join("di_readdir"); - check!(mkdir(dir, io::USER_RWX)); + check!(mkdir(dir, old_io::USER_RWX)); let prefix = "foo"; for n in range(0i,3) { let f = dir.join(format!("{}.txt", n)); @@ -1130,14 +1130,14 @@ mod test { fn file_test_walk_dir() { let tmpdir = tmpdir(); let dir = &tmpdir.join("walk_dir"); - check!(mkdir(dir, io::USER_RWX)); + check!(mkdir(dir, old_io::USER_RWX)); let dir1 = &dir.join("01/02/03"); - check!(mkdir_recursive(dir1, io::USER_RWX)); + check!(mkdir_recursive(dir1, old_io::USER_RWX)); check!(File::create(&dir1.join("04"))); let dir2 = &dir.join("11/12/13"); - check!(mkdir_recursive(dir2, io::USER_RWX)); + check!(mkdir_recursive(dir2, old_io::USER_RWX)); check!(File::create(&dir2.join("14"))); let mut files = check!(walk_dir(dir)); @@ -1155,12 +1155,12 @@ mod test { #[test] fn mkdir_path_already_exists_error() { - use io::{IoError, PathAlreadyExists}; + use old_io::{IoError, PathAlreadyExists}; let tmpdir = tmpdir(); let dir = &tmpdir.join("mkdir_error_twice"); - check!(mkdir(dir, io::USER_RWX)); - match mkdir(dir, io::USER_RWX) { + check!(mkdir(dir, old_io::USER_RWX)); + match mkdir(dir, old_io::USER_RWX) { Err(IoError{kind:PathAlreadyExists,..}) => (), _ => assert!(false) }; @@ -1170,7 +1170,7 @@ mod test { fn recursive_mkdir() { let tmpdir = tmpdir(); let dir = tmpdir.join("d1/d2"); - check!(mkdir_recursive(&dir, io::USER_RWX)); + check!(mkdir_recursive(&dir, old_io::USER_RWX)); assert!(dir.is_dir()) } @@ -1180,10 +1180,10 @@ mod test { let dir = tmpdir.join("d1"); let file = dir.join("f1"); - check!(mkdir_recursive(&dir, io::USER_RWX)); + check!(mkdir_recursive(&dir, old_io::USER_RWX)); check!(File::create(&file)); - let result = mkdir_recursive(&file, io::USER_RWX); + let result = mkdir_recursive(&file, old_io::USER_RWX); error!(result, "couldn't recursively mkdir"); error!(result, "couldn't create directory"); @@ -1193,7 +1193,7 @@ mod test { #[test] fn recursive_mkdir_slash() { - check!(mkdir_recursive(&Path::new("/"), io::USER_RWX)); + check!(mkdir_recursive(&Path::new("/"), old_io::USER_RWX)); } // FIXME(#12795) depends on lstat to work on windows @@ -1206,8 +1206,8 @@ mod test { let dtt = dt.join("t"); let d2 = tmpdir.join("d2"); let canary = d2.join("do_not_delete"); - check!(mkdir_recursive(&dtt, io::USER_RWX)); - check!(mkdir_recursive(&d2, io::USER_RWX)); + check!(mkdir_recursive(&dtt, old_io::USER_RWX)); + check!(mkdir_recursive(&d2, old_io::USER_RWX)); check!(File::create(&canary).write(b"foo")); check!(symlink(&d2, &dt.join("d2"))); check!(rmdir_recursive(&d1)); @@ -1225,7 +1225,7 @@ mod test { let mut dirpath = tmpdir.path().clone(); dirpath.push(format!("test-가一ー你好")); - check!(mkdir(&dirpath, io::USER_RWX)); + check!(mkdir(&dirpath, old_io::USER_RWX)); assert!(dirpath.is_dir()); let mut filepath = dirpath; @@ -1243,7 +1243,7 @@ mod test { let tmpdir = tmpdir(); let unicode = tmpdir.path(); let unicode = unicode.join(format!("test-각丁ー再见")); - check!(mkdir(&unicode, io::USER_RWX)); + check!(mkdir(&unicode, old_io::USER_RWX)); assert!(unicode.exists()); assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists()); } @@ -1324,12 +1324,12 @@ mod test { let out = tmpdir.join("out.txt"); check!(File::create(&input)); - check!(chmod(&input, io::USER_READ)); + check!(chmod(&input, old_io::USER_READ)); check!(copy(&input, &out)); - assert!(!check!(out.stat()).perm.intersects(io::USER_WRITE)); + assert!(!check!(out.stat()).perm.intersects(old_io::USER_WRITE)); - check!(chmod(&input, io::USER_FILE)); - check!(chmod(&out, io::USER_FILE)); + check!(chmod(&input, old_io::USER_FILE)); + check!(chmod(&out, old_io::USER_FILE)); } #[cfg(not(windows))] // FIXME(#10264) operation not permitted? @@ -1405,16 +1405,16 @@ mod test { let file = tmpdir.join("in.txt"); check!(File::create(&file)); - assert!(check!(stat(&file)).perm.contains(io::USER_WRITE)); - check!(chmod(&file, io::USER_READ)); - assert!(!check!(stat(&file)).perm.contains(io::USER_WRITE)); + assert!(check!(stat(&file)).perm.contains(old_io::USER_WRITE)); + check!(chmod(&file, old_io::USER_READ)); + assert!(!check!(stat(&file)).perm.contains(old_io::USER_WRITE)); - match chmod(&tmpdir.join("foo"), io::USER_RWX) { + match chmod(&tmpdir.join("foo"), old_io::USER_RWX) { Ok(..) => panic!("wanted a panic"), Err(..) => {} } - check!(chmod(&file, io::USER_FILE)); + check!(chmod(&file, old_io::USER_FILE)); } #[test] @@ -1422,7 +1422,7 @@ mod test { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); - let mut file = check!(File::open_mode(&path, io::Open, io::ReadWrite)); + let mut file = check!(File::open_mode(&path, old_io::Open, old_io::ReadWrite)); check!(file.fsync()); check!(file.datasync()); check!(file.write(b"foo")); @@ -1436,7 +1436,7 @@ mod test { let tmpdir = tmpdir(); let path = tmpdir.join("in.txt"); - let mut file = check!(File::open_mode(&path, io::Open, io::ReadWrite)); + let mut file = check!(File::open_mode(&path, old_io::Open, old_io::ReadWrite)); check!(file.write(b"foo")); check!(file.fsync()); @@ -1467,41 +1467,41 @@ mod test { fn open_flavors() { let tmpdir = tmpdir(); - match File::open_mode(&tmpdir.join("a"), io::Open, io::Read) { + match File::open_mode(&tmpdir.join("a"), old_io::Open, old_io::Read) { Ok(..) => panic!(), Err(..) => {} } // Perform each one twice to make sure that it succeeds the second time // (where the file exists) - check!(File::open_mode(&tmpdir.join("b"), io::Open, io::Write)); + check!(File::open_mode(&tmpdir.join("b"), old_io::Open, old_io::Write)); assert!(tmpdir.join("b").exists()); - check!(File::open_mode(&tmpdir.join("b"), io::Open, io::Write)); + check!(File::open_mode(&tmpdir.join("b"), old_io::Open, old_io::Write)); - check!(File::open_mode(&tmpdir.join("c"), io::Open, io::ReadWrite)); + check!(File::open_mode(&tmpdir.join("c"), old_io::Open, old_io::ReadWrite)); assert!(tmpdir.join("c").exists()); - check!(File::open_mode(&tmpdir.join("c"), io::Open, io::ReadWrite)); + check!(File::open_mode(&tmpdir.join("c"), old_io::Open, old_io::ReadWrite)); - check!(File::open_mode(&tmpdir.join("d"), io::Append, io::Write)); + check!(File::open_mode(&tmpdir.join("d"), old_io::Append, old_io::Write)); assert!(tmpdir.join("d").exists()); - check!(File::open_mode(&tmpdir.join("d"), io::Append, io::Write)); + check!(File::open_mode(&tmpdir.join("d"), old_io::Append, old_io::Write)); - check!(File::open_mode(&tmpdir.join("e"), io::Append, io::ReadWrite)); + check!(File::open_mode(&tmpdir.join("e"), old_io::Append, old_io::ReadWrite)); assert!(tmpdir.join("e").exists()); - check!(File::open_mode(&tmpdir.join("e"), io::Append, io::ReadWrite)); + check!(File::open_mode(&tmpdir.join("e"), old_io::Append, old_io::ReadWrite)); - check!(File::open_mode(&tmpdir.join("f"), io::Truncate, io::Write)); + check!(File::open_mode(&tmpdir.join("f"), old_io::Truncate, old_io::Write)); assert!(tmpdir.join("f").exists()); - check!(File::open_mode(&tmpdir.join("f"), io::Truncate, io::Write)); + check!(File::open_mode(&tmpdir.join("f"), old_io::Truncate, old_io::Write)); - check!(File::open_mode(&tmpdir.join("g"), io::Truncate, io::ReadWrite)); + check!(File::open_mode(&tmpdir.join("g"), old_io::Truncate, old_io::ReadWrite)); assert!(tmpdir.join("g").exists()); - check!(File::open_mode(&tmpdir.join("g"), io::Truncate, io::ReadWrite)); + check!(File::open_mode(&tmpdir.join("g"), old_io::Truncate, old_io::ReadWrite)); check!(File::create(&tmpdir.join("h")).write("foo".as_bytes())); - check!(File::open_mode(&tmpdir.join("h"), io::Open, io::Read)); + check!(File::open_mode(&tmpdir.join("h"), old_io::Open, old_io::Read)); { - let mut f = check!(File::open_mode(&tmpdir.join("h"), io::Open, - io::Read)); + let mut f = check!(File::open_mode(&tmpdir.join("h"), old_io::Open, + old_io::Read)); match f.write("wut".as_bytes()) { Ok(..) => panic!(), Err(..) => {} } @@ -1509,15 +1509,15 @@ mod test { assert!(check!(stat(&tmpdir.join("h"))).size == 3, "write/stat failed"); { - let mut f = check!(File::open_mode(&tmpdir.join("h"), io::Append, - io::Write)); + let mut f = check!(File::open_mode(&tmpdir.join("h"), old_io::Append, + old_io::Write)); check!(f.write("bar".as_bytes())); } assert!(check!(stat(&tmpdir.join("h"))).size == 6, "append didn't append"); { - let mut f = check!(File::open_mode(&tmpdir.join("h"), io::Truncate, - io::Write)); + let mut f = check!(File::open_mode(&tmpdir.join("h"), old_io::Truncate, + old_io::Write)); check!(f.write("bar".as_bytes())); } assert!(check!(stat(&tmpdir.join("h"))).size == 3, @@ -1529,8 +1529,9 @@ mod test { let tmpdir = tmpdir(); let path = tmpdir.join("a"); check!(File::create(&path)); - // These numbers have to be bigger than the time in the day to account for timezones - // Windows in particular will fail in certain timezones with small enough values + // These numbers have to be bigger than the time in the day to account + // for timezones Windows in particular will fail in certain timezones + // with small enough values check!(change_file_times(&path, 100000, 200000)); assert_eq!(check!(path.stat()).accessed, 100000); assert_eq!(check!(path.stat()).modified, 200000); @@ -1565,7 +1566,7 @@ mod test { let tmpdir = tmpdir(); let path = tmpdir.join("file"); check!(File::create(&path)); - check!(chmod(&path, io::USER_READ)); + check!(chmod(&path, old_io::USER_READ)); check!(unlink(&path)); } } diff --git a/src/libstd/io/mem.rs b/src/libstd/old_io/mem.rs index 8c0de781994..254daf3202a 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/old_io/mem.rs @@ -15,8 +15,8 @@ use cmp::min; use option::Option::None; use result::Result::{Err, Ok}; -use io; -use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult}; +use old_io; +use old_io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult}; use slice::{self, AsSlice, SliceExt}; use vec::Vec; @@ -25,14 +25,14 @@ const BUF_CAPACITY: uint = 128; fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> { // compute offset as signed and clamp to prevent overflow let pos = match seek { - io::SeekSet => 0, - io::SeekEnd => end, - io::SeekCur => cur, + old_io::SeekSet => 0, + old_io::SeekEnd => end, + old_io::SeekCur => cur, } as i64; if offset + pos < 0 { Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "invalid seek to a negative offset", detail: None }) @@ -43,7 +43,7 @@ fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> impl Writer for Vec<u8> { #[inline] - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.push_all(buf); Ok(()) } @@ -55,7 +55,7 @@ impl Writer for Vec<u8> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::MemWriter; +/// use std::old_io::MemWriter; /// /// let mut w = MemWriter::new(); /// w.write(&[0, 1, 2]); @@ -101,7 +101,7 @@ impl MemWriter { impl Writer for MemWriter { #[inline] - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.buf.push_all(buf); Ok(()) } @@ -113,7 +113,7 @@ impl Writer for MemWriter { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::MemReader; +/// use std::old_io::MemReader; /// /// let mut r = MemReader::new(vec!(0, 1, 2)); /// @@ -157,7 +157,7 @@ impl MemReader { impl Reader for MemReader { #[inline] fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { - if self.eof() { return Err(io::standard_error(io::EndOfFile)) } + if self.eof() { return Err(old_io::standard_error(old_io::EndOfFile)) } let write_len = min(buf.len(), self.buf.len() - self.pos); { @@ -191,7 +191,7 @@ impl Buffer for MemReader { if self.pos < self.buf.len() { Ok(&self.buf[self.pos..]) } else { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } } @@ -202,7 +202,7 @@ impl Buffer for MemReader { impl<'a> Reader for &'a [u8] { #[inline] fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { - if self.is_empty() { return Err(io::standard_error(io::EndOfFile)); } + if self.is_empty() { return Err(old_io::standard_error(old_io::EndOfFile)); } let write_len = min(buf.len(), self.len()); { @@ -221,7 +221,7 @@ impl<'a> Buffer for &'a [u8] { #[inline] fn fill_buf(&mut self) -> IoResult<&[u8]> { if self.is_empty() { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } else { Ok(*self) } @@ -243,7 +243,7 @@ impl<'a> Buffer for &'a [u8] { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::BufWriter; +/// use std::old_io::BufWriter; /// /// let mut buf = [0; 4]; /// { @@ -271,12 +271,12 @@ impl<'a> BufWriter<'a> { impl<'a> Writer for BufWriter<'a> { #[inline] - fn write(&mut self, src: &[u8]) -> IoResult<()> { + fn write_all(&mut self, src: &[u8]) -> IoResult<()> { let dst = &mut self.buf[self.pos..]; let dst_len = dst.len(); if dst_len == 0 { - return Err(io::standard_error(io::EndOfFile)); + return Err(old_io::standard_error(old_io::EndOfFile)); } let src_len = src.len(); @@ -292,7 +292,7 @@ impl<'a> Writer for BufWriter<'a> { self.pos += dst_len; - Err(io::standard_error(io::ShortWrite(dst_len))) + Err(old_io::standard_error(old_io::ShortWrite(dst_len))) } } } @@ -315,7 +315,7 @@ impl<'a> Seek for BufWriter<'a> { /// /// ```rust /// # #![allow(unused_must_use)] -/// use std::io::BufReader; +/// use std::old_io::BufReader; /// /// let buf = [0, 1, 2, 3]; /// let mut r = BufReader::new(&buf); @@ -347,7 +347,7 @@ impl<'a> BufReader<'a> { impl<'a> Reader for BufReader<'a> { #[inline] fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { - if self.eof() { return Err(io::standard_error(io::EndOfFile)) } + if self.eof() { return Err(old_io::standard_error(old_io::EndOfFile)) } let write_len = min(buf.len(), self.buf.len() - self.pos); { @@ -381,7 +381,7 @@ impl<'a> Buffer for BufReader<'a> { if self.pos < self.buf.len() { Ok(&self.buf[self.pos..]) } else { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } } @@ -392,10 +392,10 @@ impl<'a> Buffer for BufReader<'a> { #[cfg(test)] mod test { extern crate "test" as test_crate; - use io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek}; + use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek}; use prelude::v1::{Ok, Err, range, Vec, Buffer, AsSlice, SliceExt}; use prelude::v1::IteratorExt; - use io; + use old_io; use iter::repeat; use self::test_crate::Bencher; use super::*; @@ -434,8 +434,8 @@ mod test { writer.write(&[]).unwrap(); assert_eq!(writer.tell(), Ok(8)); - assert_eq!(writer.write(&[8, 9]).err().unwrap().kind, io::ShortWrite(1)); - assert_eq!(writer.write(&[10]).err().unwrap().kind, io::EndOfFile); + assert_eq!(writer.write(&[8, 9]).err().unwrap().kind, old_io::ShortWrite(1)); + assert_eq!(writer.write(&[10]).err().unwrap().kind, old_io::EndOfFile); } let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8]; assert_eq!(buf, b); @@ -478,7 +478,7 @@ mod test { match writer.write(&[0, 0]) { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::ShortWrite(1)), + Err(e) => assert_eq!(e.kind, old_io::ShortWrite(1)), } } diff --git a/src/libstd/io/mod.rs b/src/libstd/old_io/mod.rs index cc7f9f5b892..6c5ce129a33 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/old_io/mod.rs @@ -18,6 +18,24 @@ //! I/O, including files, networking, timers, and processes //! +//! > **Warning**: This module is currently called `old_io` for a reason! The +//! > module is currently being redesigned in a number of RFCs. For more details +//! > follow the RFC repository in connection with [RFC 517][base] or follow +//! > some of these sub-RFCs +//! > +//! > * [String handling][osstr] +//! > * [Core I/O support][core] +//! > * [Deadlines][deadlines] +//! > * [std::env][env] +//! > * [std::process][process] +//! +//! [base]: https://github.com/rust-lang/rfcs/blob/master/text/0517-io-os-reform.md +//! [osstr]: https://github.com/rust-lang/rfcs/pull/575 +//! [core]: https://github.com/rust-lang/rfcs/pull/576 +//! [deadlines]: https://github.com/rust-lang/rfcs/pull/577 +//! [env]: https://github.com/rust-lang/rfcs/pull/578 +//! [process]: https://github.com/rust-lang/rfcs/pull/579 +//! //! `std::io` provides Rust's basic I/O types, //! for reading and writing to files, TCP, UDP, //! and other types of sockets and pipes, @@ -30,7 +48,7 @@ //! * Read lines from stdin //! //! ```rust -//! use std::io; +//! use std::old_io as io; //! //! for line in io::stdin().lock().lines() { //! print!("{}", line.unwrap()); @@ -40,7 +58,7 @@ //! * Read a complete file //! //! ```rust -//! use std::io::File; +//! use std::old_io::File; //! //! let contents = File::open(&Path::new("message.txt")).read_to_end(); //! ``` @@ -49,19 +67,19 @@ //! //! ```rust //! # #![allow(unused_must_use)] -//! use std::io::File; +//! use std::old_io::File; //! //! let mut file = File::create(&Path::new("message.txt")); -//! file.write(b"hello, file!\n"); +//! file.write_all(b"hello, file!\n"); //! # drop(file); -//! # ::std::io::fs::unlink(&Path::new("message.txt")); +//! # ::std::old_io::fs::unlink(&Path::new("message.txt")); //! ``` //! //! * Iterate over the lines of a file //! //! ```rust,no_run -//! use std::io::BufferedReader; -//! use std::io::File; +//! use std::old_io::BufferedReader; +//! use std::old_io::File; //! //! let path = Path::new("message.txt"); //! let mut file = BufferedReader::new(File::open(&path)); @@ -73,8 +91,8 @@ //! * Pull the lines of a file into a vector of strings //! //! ```rust,no_run -//! use std::io::BufferedReader; -//! use std::io::File; +//! use std::old_io::BufferedReader; +//! use std::old_io::File; //! //! let path = Path::new("message.txt"); //! let mut file = BufferedReader::new(File::open(&path)); @@ -85,14 +103,14 @@ //! //! ```rust //! # #![allow(unused_must_use)] -//! use std::io::TcpStream; +//! use std::old_io::TcpStream; //! //! # // connection doesn't fail if a server is running on 8080 //! # // locally, we still want to be type checking this code, so lets //! # // just stop it running (#11576) //! # if false { //! let mut socket = TcpStream::connect("127.0.0.1:8080").unwrap(); -//! socket.write(b"GET / HTTP/1.0\n\n"); +//! socket.write_all(b"GET / HTTP/1.0\n\n"); //! let response = socket.read_to_end(); //! # } //! ``` @@ -103,8 +121,8 @@ //! # fn main() { } //! # fn foo() { //! # #![allow(dead_code)] -//! use std::io::{TcpListener, TcpStream}; -//! use std::io::{Acceptor, Listener}; +//! use std::old_io::{TcpListener, TcpStream}; +//! use std::old_io::{Acceptor, Listener}; //! use std::thread::Thread; //! //! let listener = TcpListener::bind("127.0.0.1:80"); @@ -156,7 +174,7 @@ //! to be 'unwrapped' before use. //! //! These features combine in the API to allow for expressions like -//! `File::create(&Path::new("diary.txt")).write(b"Met a girl.\n")` +//! `File::create(&Path::new("diary.txt")).write_all(b"Met a girl.\n")` //! without having to worry about whether "diary.txt" exists or whether //! the write succeeds. As written, if either `new` or `write_line` //! encounters an error then the result of the entire expression will @@ -166,14 +184,14 @@ //! //! ```rust //! # #![allow(unused_must_use)] -//! use std::io::File; +//! use std::old_io::File; //! -//! match File::create(&Path::new("diary.txt")).write(b"Met a girl.\n") { +//! match File::create(&Path::new("diary.txt")).write_all(b"Met a girl.\n") { //! Ok(()) => (), // succeeded //! Err(e) => println!("failed to write to my diary: {}", e), //! } //! -//! # ::std::io::fs::unlink(&Path::new("diary.txt")); +//! # ::std::old_io::fs::unlink(&Path::new("diary.txt")); //! ``` //! //! So what actually happens if `create` encounters an error? @@ -199,7 +217,7 @@ //! If you wanted to read several `u32`s from a file and return their product: //! //! ```rust -//! use std::io::{File, IoResult}; +//! use std::old_io::{File, IoResult}; //! //! fn file_product(p: &Path) -> IoResult<u32> { //! let mut f = File::open(p); @@ -925,9 +943,9 @@ unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) - /// # Examples /// /// ``` -/// use std::io; -/// use std::io::ByRefReader; -/// use std::io::util::LimitReader; +/// use std::old_io as io; +/// use std::old_io::ByRefReader; +/// use std::old_io::util::LimitReader; /// /// fn process_input<R: Reader>(r: R) {} /// @@ -979,7 +997,12 @@ pub trait Writer { /// `Err`. Note that it is considered an error if the entire buffer could /// not be written, and if an error is returned then it is unknown how much /// data (if any) was actually written. - fn write(&mut self, buf: &[u8]) -> IoResult<()>; + fn write_all(&mut self, buf: &[u8]) -> IoResult<()>; + + /// Deprecated, this method was renamed to `write_all` + #[unstable(feature = "io")] + #[deprecated(since = "1.0.0", reason = "renamed to `write_all`")] + fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write_all(buf) } /// Flush this output stream, ensuring that all intermediately buffered /// contents reach their destination. @@ -1008,7 +1031,7 @@ pub trait Writer { impl<'a, T: ?Sized + Writer> fmt::Writer for Adaptor<'a, T> { fn write_str(&mut self, s: &str) -> fmt::Result { - match self.inner.write(s.as_bytes()) { + match self.inner.write_all(s.as_bytes()) { Ok(()) => Ok(()), Err(e) => { self.error = Err(e); @@ -1034,7 +1057,7 @@ pub trait Writer { /// converted byte-array instead. #[inline] fn write_str(&mut self, s: &str) -> IoResult<()> { - self.write(s.as_bytes()) + self.write_all(s.as_bytes()) } /// Writes a string into this sink, and then writes a literal newline (`\n`) @@ -1046,7 +1069,7 @@ pub trait Writer { /// that the `write` method is used specifically instead. #[inline] fn write_line(&mut self, s: &str) -> IoResult<()> { - self.write_str(s).and_then(|()| self.write(&[b'\n'])) + self.write_str(s).and_then(|()| self.write_all(&[b'\n'])) } /// Write a single char, encoded as UTF-8. @@ -1054,7 +1077,7 @@ pub trait Writer { fn write_char(&mut self, c: char) -> IoResult<()> { let mut buf = [0u8; 4]; let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0); - self.write(&buf[..n]) + self.write_all(&buf[..n]) } /// Write the result of passing n through `int::to_str_bytes`. @@ -1072,61 +1095,61 @@ pub trait Writer { /// Write a little-endian uint (number of bytes depends on system). #[inline] fn write_le_uint(&mut self, n: uint) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, uint::BYTES, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, uint::BYTES, |v| self.write_all(v)) } /// Write a little-endian int (number of bytes depends on system). #[inline] fn write_le_int(&mut self, n: int) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, int::BYTES, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, int::BYTES, |v| self.write_all(v)) } /// Write a big-endian uint (number of bytes depends on system). #[inline] fn write_be_uint(&mut self, n: uint) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, uint::BYTES, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, uint::BYTES, |v| self.write_all(v)) } /// Write a big-endian int (number of bytes depends on system). #[inline] fn write_be_int(&mut self, n: int) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, int::BYTES, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, int::BYTES, |v| self.write_all(v)) } /// Write a big-endian u64 (8 bytes). #[inline] fn write_be_u64(&mut self, n: u64) -> IoResult<()> { - extensions::u64_to_be_bytes(n, 8u, |v| self.write(v)) + extensions::u64_to_be_bytes(n, 8u, |v| self.write_all(v)) } /// Write a big-endian u32 (4 bytes). #[inline] fn write_be_u32(&mut self, n: u32) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, 4u, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, 4u, |v| self.write_all(v)) } /// Write a big-endian u16 (2 bytes). #[inline] fn write_be_u16(&mut self, n: u16) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, 2u, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, 2u, |v| self.write_all(v)) } /// Write a big-endian i64 (8 bytes). #[inline] fn write_be_i64(&mut self, n: i64) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, 8u, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, 8u, |v| self.write_all(v)) } /// Write a big-endian i32 (4 bytes). #[inline] fn write_be_i32(&mut self, n: i32) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, 4u, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, 4u, |v| self.write_all(v)) } /// Write a big-endian i16 (2 bytes). #[inline] fn write_be_i16(&mut self, n: i16) -> IoResult<()> { - extensions::u64_to_be_bytes(n as u64, 2u, |v| self.write(v)) + extensions::u64_to_be_bytes(n as u64, 2u, |v| self.write_all(v)) } /// Write a big-endian IEEE754 double-precision floating-point (8 bytes). @@ -1148,37 +1171,37 @@ pub trait Writer { /// Write a little-endian u64 (8 bytes). #[inline] fn write_le_u64(&mut self, n: u64) -> IoResult<()> { - extensions::u64_to_le_bytes(n, 8u, |v| self.write(v)) + extensions::u64_to_le_bytes(n, 8u, |v| self.write_all(v)) } /// Write a little-endian u32 (4 bytes). #[inline] fn write_le_u32(&mut self, n: u32) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, 4u, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, 4u, |v| self.write_all(v)) } /// Write a little-endian u16 (2 bytes). #[inline] fn write_le_u16(&mut self, n: u16) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, 2u, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, 2u, |v| self.write_all(v)) } /// Write a little-endian i64 (8 bytes). #[inline] fn write_le_i64(&mut self, n: i64) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, 8u, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, 8u, |v| self.write_all(v)) } /// Write a little-endian i32 (4 bytes). #[inline] fn write_le_i32(&mut self, n: i32) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, 4u, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, 4u, |v| self.write_all(v)) } /// Write a little-endian i16 (2 bytes). #[inline] fn write_le_i16(&mut self, n: i16) -> IoResult<()> { - extensions::u64_to_le_bytes(n as u64, 2u, |v| self.write(v)) + extensions::u64_to_le_bytes(n as u64, 2u, |v| self.write_all(v)) } /// Write a little-endian IEEE754 double-precision floating-point @@ -1202,13 +1225,13 @@ pub trait Writer { /// Write a u8 (1 byte). #[inline] fn write_u8(&mut self, n: u8) -> IoResult<()> { - self.write(&[n]) + self.write_all(&[n]) } /// Write an i8 (1 byte). #[inline] fn write_i8(&mut self, n: i8) -> IoResult<()> { - self.write(&[n as u8]) + self.write_all(&[n as u8]) } } @@ -1230,8 +1253,8 @@ impl<T: Writer> ByRefWriter for T { impl<'a> Writer for Box<Writer+'a> { #[inline] - fn write(&mut self, buf: &[u8]) -> IoResult<()> { - (&mut **self).write(buf) + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { + (&mut **self).write_all(buf) } #[inline] @@ -1242,7 +1265,7 @@ impl<'a> Writer for Box<Writer+'a> { impl<'a> Writer for &'a mut (Writer+'a) { #[inline] - fn write(&mut self, buf: &[u8]) -> IoResult<()> { (**self).write(buf) } + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { (**self).write_all(buf) } #[inline] fn flush(&mut self) -> IoResult<()> { (**self).flush() } @@ -1254,8 +1277,8 @@ impl<'a> Writer for &'a mut (Writer+'a) { /// # Example /// /// ``` -/// use std::io::util::TeeReader; -/// use std::io::{stdin, ByRefWriter}; +/// use std::old_io::util::TeeReader; +/// use std::old_io::{stdin, ByRefWriter}; /// /// fn process_input<R: Reader>(r: R) {} /// @@ -1277,7 +1300,7 @@ pub struct RefWriter<'a, W:'a> { impl<'a, W: Writer> Writer for RefWriter<'a, W> { #[inline] - fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.inner.write(buf) } + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.inner.write_all(buf) } #[inline] fn flush(&mut self) -> IoResult<()> { self.inner.flush() } @@ -1379,7 +1402,7 @@ pub trait Buffer: Reader { /// # Example /// /// ```rust - /// use std::io::BufReader; + /// use std::old_io::BufReader; /// /// let mut reader = BufReader::new(b"hello\nworld"); /// assert_eq!("hello\n", &*reader.read_line().unwrap()); @@ -1601,7 +1624,7 @@ impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> { /// # Example /// /// ``` -/// use std::io; +/// use std::old_io as io; /// /// let eof = io::standard_error(io::EndOfFile); /// let einval = io::standard_error(io::InvalidInput); @@ -1690,7 +1713,7 @@ pub enum FileType { /// /// ```no_run /// -/// use std::io::fs::PathExtensions; +/// use std::old_io::fs::PathExtensions; /// /// let info = match Path::new("foo.txt").stat() { /// Ok(stat) => stat, diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/old_io/net/addrinfo.rs index 7825a4e16e1..9800cc6829e 100644 --- a/src/libstd/io/net/addrinfo.rs +++ b/src/libstd/old_io/net/addrinfo.rs @@ -20,8 +20,8 @@ pub use self::Flag::*; pub use self::Protocol::*; use iter::IteratorExt; -use io::{IoResult}; -use io::net::ip::{SocketAddr, IpAddr}; +use old_io::{IoResult}; +use old_io::net::ip::{SocketAddr, IpAddr}; use option::Option; use option::Option::{Some, None}; use string::String; @@ -114,7 +114,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>) mod test { use prelude::v1::*; use super::*; - use io::net::ip::*; + use old_io::net::ip::*; #[test] fn dns_smoke_test() { diff --git a/src/libstd/io/net/ip.rs b/src/libstd/old_io/net/ip.rs index 7e7603c826e..e60b455aecd 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/old_io/net/ip.rs @@ -19,8 +19,8 @@ pub use self::IpAddr::*; use boxed::Box; use fmt; -use io::{self, IoResult, IoError}; -use io::net; +use old_io::{self, IoResult, IoError}; +use old_io::net; use iter::{Iterator, IteratorExt}; use ops::{FnOnce, FnMut}; use option::Option; @@ -406,9 +406,9 @@ impl FromStr for SocketAddr { /// ```rust,no_run /// # #![allow(unused_must_use)] /// -/// use std::io::{TcpStream, TcpListener}; -/// use std::io::net::udp::UdpSocket; -/// use std::io::net::ip::{Ipv4Addr, SocketAddr}; +/// use std::old_io::{TcpStream, TcpListener}; +/// use std::old_io::net::udp::UdpSocket; +/// use std::old_io::net::ip::{Ipv4Addr, SocketAddr}; /// /// fn main() { /// // The following lines are equivalent modulo possible "localhost" name resolution @@ -438,7 +438,7 @@ pub trait ToSocketAddr { fn to_socket_addr(&self) -> IoResult<SocketAddr> { self.to_socket_addr_all() .and_then(|v| v.into_iter().next().ok_or_else(|| IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "no address available", detail: None })) @@ -481,7 +481,7 @@ fn parse_and_resolve_socket_addr(s: &str) -> IoResult<Vec<SocketAddr>> { match $e { Some(r) => r, None => return Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: $msg, detail: None }) @@ -526,7 +526,7 @@ impl<'a> ToSocketAddr for &'a str { parse_and_resolve_socket_addr(*self) .and_then(|v| v.into_iter().next() .ok_or_else(|| IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "no address available", detail: None }) diff --git a/src/libstd/io/net/mod.rs b/src/libstd/old_io/net/mod.rs index 2056933e6df..d8394aa8b6a 100644 --- a/src/libstd/io/net/mod.rs +++ b/src/libstd/old_io/net/mod.rs @@ -10,7 +10,7 @@ //! Networking I/O -use io::{IoError, IoResult, InvalidInput}; +use old_io::{IoError, IoResult, InvalidInput}; use ops::FnMut; use option::Option::None; use result::Result::{Ok, Err}; diff --git a/src/libstd/io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs index ac7e9ce5dde..71b77adcd96 100644 --- a/src/libstd/io/net/pipe.rs +++ b/src/libstd/old_io/net/pipe.rs @@ -24,7 +24,7 @@ use prelude::v1::*; use ffi::CString; use path::BytesContainer; -use io::{Listener, Acceptor, IoResult, TimedOut, standard_error}; +use old_io::{Listener, Acceptor, IoResult, TimedOut, standard_error}; use sys::pipe::UnixAcceptor as UnixAcceptorImp; use sys::pipe::UnixListener as UnixListenerImp; use sys::pipe::UnixStream as UnixStreamImp; @@ -48,7 +48,7 @@ impl UnixStream { /// /// ```rust /// # #![allow(unused_must_use)] - /// use std::io::net::pipe::UnixStream; + /// use std::old_io::net::pipe::UnixStream; /// /// let server = Path::new("path/to/my/socket"); /// let mut stream = UnixStream::connect(&server); @@ -146,7 +146,7 @@ impl Reader for UnixStream { } impl Writer for UnixStream { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.inner.write(buf) } } @@ -173,8 +173,8 @@ impl UnixListener { /// /// ``` /// # fn foo() { - /// use std::io::net::pipe::UnixListener; - /// use std::io::{Listener, Acceptor}; + /// use std::old_io::net::pipe::UnixListener; + /// use std::old_io::{Listener, Acceptor}; /// /// let server = Path::new("/path/to/my/socket"); /// let stream = UnixListener::bind(&server); @@ -275,11 +275,11 @@ impl sys_common::AsInner<UnixAcceptorImp> for UnixAcceptor { mod tests { use prelude::v1::*; - use io::fs::PathExtensions; - use io::{EndOfFile, TimedOut, ShortWrite, IoError, ConnectionReset}; - use io::{NotConnected, BrokenPipe, FileNotFound, InvalidInput, OtherIoError}; - use io::{PermissionDenied, Acceptor, Listener}; - use io::test::*; + use old_io::fs::PathExtensions; + use old_io::{EndOfFile, TimedOut, ShortWrite, IoError, ConnectionReset}; + use old_io::{NotConnected, BrokenPipe, FileNotFound, InvalidInput, OtherIoError}; + use old_io::{PermissionDenied, Acceptor, Listener}; + use old_io::test::*; use super::*; use sync::mpsc::channel; use thread::Thread; diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/old_io/net/tcp.rs index d5feb5977fb..1e76bb3ab0d 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/old_io/net/tcp.rs @@ -18,11 +18,11 @@ //! listener (socket server) implements the `Listener` and `Acceptor` traits. use clone::Clone; -use io::IoResult; +use old_io::IoResult; use result::Result::Err; -use io::net::ip::{SocketAddr, ToSocketAddr}; -use io::{Reader, Writer, Listener, Acceptor}; -use io::{standard_error, TimedOut}; +use old_io::net::ip::{SocketAddr, ToSocketAddr}; +use old_io::{Reader, Writer, Listener, Acceptor}; +use old_io::{standard_error, TimedOut}; use option::Option; use option::Option::{None, Some}; use time::Duration; @@ -41,7 +41,7 @@ use sys_common; /// # Example /// /// ```no_run -/// use std::io::TcpStream; +/// use std::old_io::TcpStream; /// /// { /// let mut stream = TcpStream::connect("127.0.0.1:34254"); @@ -134,8 +134,8 @@ impl TcpStream { /// /// ```no_run /// # #![allow(unused_must_use)] - /// use std::io::timer; - /// use std::io::TcpStream; + /// use std::old_io::timer; + /// use std::old_io::TcpStream; /// use std::time::Duration; /// use std::thread::Thread; /// @@ -262,7 +262,7 @@ impl Reader for TcpStream { } impl Writer for TcpStream { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.inner.write(buf) } } @@ -280,8 +280,8 @@ impl sys_common::AsInner<TcpStreamImp> for TcpStream { /// /// ``` /// # fn foo() { -/// use std::io::{TcpListener, TcpStream}; -/// use std::io::{Acceptor, Listener}; +/// use std::old_io::{TcpListener, TcpStream}; +/// use std::old_io::{Acceptor, Listener}; /// use std::thread::Thread; /// /// let listener = TcpListener::bind("127.0.0.1:80").unwrap(); @@ -376,8 +376,8 @@ impl TcpAcceptor { /// # Example /// /// ```no_run - /// use std::io::TcpListener; - /// use std::io::{Listener, Acceptor, TimedOut}; + /// use std::old_io::TcpListener; + /// use std::old_io::{Listener, Acceptor, TimedOut}; /// /// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap(); /// @@ -420,7 +420,7 @@ impl TcpAcceptor { /// # Example /// /// ``` - /// use std::io::{TcpListener, Listener, Acceptor, EndOfFile}; + /// use std::old_io::{TcpListener, Listener, Acceptor, EndOfFile}; /// use std::thread::Thread; /// /// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap(); @@ -488,13 +488,13 @@ mod test { use sync::mpsc::channel; use thread::Thread; - use io::net::tcp::*; - use io::net::ip::*; - use io::test::*; - use io::{EndOfFile, TimedOut, ShortWrite, IoError}; - use io::{ConnectionRefused, BrokenPipe, ConnectionAborted}; - use io::{ConnectionReset, NotConnected, PermissionDenied, OtherIoError}; - use io::{Acceptor, Listener}; + use old_io::net::tcp::*; + use old_io::net::ip::*; + use old_io::test::*; + use old_io::{EndOfFile, TimedOut, ShortWrite, IoError}; + use old_io::{ConnectionRefused, BrokenPipe, ConnectionAborted}; + use old_io::{ConnectionReset, NotConnected, PermissionDenied, OtherIoError}; + use old_io::{Acceptor, Listener}; // FIXME #11530 this fails on android because tests are run as root #[cfg_attr(any(windows, target_os = "android"), ignore)] diff --git a/src/libstd/io/net/udp.rs b/src/libstd/old_io/net/udp.rs index 6e336168b16..9055a089eec 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/old_io/net/udp.rs @@ -16,8 +16,8 @@ //! datagram protocol. use clone::Clone; -use io::net::ip::{SocketAddr, IpAddr, ToSocketAddr}; -use io::IoResult; +use old_io::net::ip::{SocketAddr, IpAddr, ToSocketAddr}; +use old_io::IoResult; use option::Option; use sys::udp::UdpSocket as UdpSocketImp; use sys_common; @@ -34,8 +34,8 @@ use sys_common; /// # #![allow(unused_must_use)] /// #![feature(slicing_syntax)] /// -/// use std::io::net::udp::UdpSocket; -/// use std::io::net::ip::{Ipv4Addr, SocketAddr}; +/// use std::old_io::net::udp::UdpSocket; +/// use std::old_io::net::ip::{Ipv4Addr, SocketAddr}; /// fn main() { /// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 }; /// let mut socket = match UdpSocket::bind(addr) { @@ -183,9 +183,9 @@ mod test { use prelude::v1::*; use sync::mpsc::channel; - use io::net::ip::*; - use io::test::*; - use io::{IoError, TimedOut, PermissionDenied, ShortWrite}; + use old_io::net::ip::*; + use old_io::test::*; + use old_io::{IoError, TimedOut, PermissionDenied, ShortWrite}; use super::*; use thread::Thread; diff --git a/src/libstd/io/pipe.rs b/src/libstd/old_io/pipe.rs index 09dcafb0218..5843b1ba1b1 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/old_io/pipe.rs @@ -17,7 +17,7 @@ use prelude::v1::*; -use io::IoResult; +use old_io::IoResult; use libc; use sync::Arc; @@ -49,7 +49,7 @@ impl PipeStream { /// # #![allow(unused_must_use)] /// extern crate libc; /// - /// use std::io::pipe::PipeStream; + /// use std::old_io::pipe::PipeStream; /// /// fn main() { /// let mut pipe = PipeStream::open(libc::STDERR_FILENO); @@ -105,7 +105,7 @@ impl Reader for PipeStream { } impl Writer for PipeStream { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { self.inner.write(buf) } } @@ -120,7 +120,7 @@ mod test { #[test] fn partial_read() { use os; - use io::pipe::PipeStream; + use old_io::pipe::PipeStream; let os::Pipe { reader, writer } = unsafe { os::pipe().unwrap() }; let out = PipeStream::open(writer); diff --git a/src/libstd/io/process.rs b/src/libstd/old_io/process.rs index a406d3c2788..78910882467 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/old_io/process.rs @@ -20,9 +20,9 @@ use prelude::v1::*; use collections::HashMap; use ffi::CString; use fmt; -use io::pipe::{PipeStream, PipePair}; -use io::{IoResult, IoError}; -use io; +use old_io::pipe::{PipeStream, PipePair}; +use old_io::{IoResult, IoError}; +use old_io; use libc; use os; use path::BytesContainer; @@ -57,7 +57,7 @@ use thread::Thread; /// # Example /// /// ```should_fail -/// use std::io::Command; +/// use std::old_io::Command; /// /// let mut child = match Command::new("/bin/cat").arg("file.txt").spawn() { /// Ok(child) => child, @@ -158,7 +158,7 @@ pub type EnvMap = HashMap<EnvKey, CString>; /// to be changed (for example, by adding arguments) prior to spawning: /// /// ``` -/// use std::io::Command; +/// use std::old_io::Command; /// /// let mut process = match Command::new("sh").arg("-c").arg("echo hello").spawn() { /// Ok(p) => p, @@ -358,7 +358,7 @@ impl Command { /// # Example /// /// ``` - /// use std::io::Command; + /// use std::old_io::Command; /// /// let output = match Command::new("cat").arg("foot.txt").output() { /// Ok(output) => output, @@ -379,7 +379,7 @@ impl Command { /// # Example /// /// ``` - /// use std::io::Command; + /// use std::old_io::Command; /// /// let status = match Command::new("ls").status() { /// Ok(status) => status, @@ -582,7 +582,7 @@ impl Process { // newer process that happens to have the same (re-used) id if self.exit_code.is_some() { return Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "invalid argument: can't kill an exited process", detail: None, }) @@ -652,8 +652,8 @@ impl Process { /// # Example /// /// ```no_run - /// use std::io::{Command, IoResult}; - /// use std::io::process::ProcessExit; + /// use std::old_io::{Command, IoResult}; + /// use std::old_io::process::ProcessExit; /// /// fn run_gracefully(prog: &str) -> IoResult<ProcessExit> { /// let mut p = try!(Command::new("long-running-process").spawn()); @@ -697,7 +697,7 @@ impl Process { /// fail. pub fn wait_with_output(mut self) -> IoResult<ProcessOutput> { drop(self.stdin.take()); - fn read(stream: Option<io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> { + fn read(stream: Option<old_io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> { let (tx, rx) = channel(); match stream { Some(stream) => { @@ -751,12 +751,12 @@ impl Drop for Process { #[cfg(test)] mod tests { - use io::{Truncate, Write, TimedOut, timer, process, FileNotFound}; + use old_io::{Truncate, Write, TimedOut, timer, process, FileNotFound}; use prelude::v1::{Ok, Err, range, drop, Some, None, Vec}; use prelude::v1::{Path, String, Reader, Writer, Clone}; use prelude::v1::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath}; - use io::fs::PathExtensions; - use io::timer::*; + use old_io::fs::PathExtensions; + use old_io::timer::*; use rt::running_on_valgrind; use str; use super::{CreatePipe}; @@ -1078,13 +1078,13 @@ mod tests { #[test] fn test_override_env() { use os; - let mut new_env = vec![("RUN_TEST_NEW_ENV", "123")]; // In some build environments (such as chrooted Nix builds), `env` can // only be found in the explicitly-provided PATH env variable, not in // default places such as /bin or /usr/bin. So we need to pass through // PATH to our sub-process. let path_val: String; + let mut new_env = vec![("RUN_TEST_NEW_ENV", "123")]; match os::getenv("PATH") { None => {} Some(val) => { diff --git a/src/libstd/io/result.rs b/src/libstd/old_io/result.rs index c1474650f1e..96b979860ae 100644 --- a/src/libstd/io/result.rs +++ b/src/libstd/old_io/result.rs @@ -19,9 +19,9 @@ use result::Result::{Ok, Err}; use super::{Reader, Writer, Listener, Acceptor, Seek, SeekStyle, IoResult}; impl<W: Writer> Writer for IoResult<W> { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { match *self { - Ok(ref mut writer) => writer.write(buf), + Ok(ref mut writer) => writer.write_all(buf), Err(ref e) => Err((*e).clone()) } } @@ -80,34 +80,34 @@ impl<T, A: Acceptor<T>> Acceptor<T> for IoResult<A> { mod test { use prelude::v1::*; use super::super::mem::*; - use io; + use old_io; #[test] fn test_option_writer() { - let mut writer: io::IoResult<Vec<u8>> = Ok(Vec::new()); - writer.write(&[0, 1, 2]).unwrap(); + let mut writer: old_io::IoResult<Vec<u8>> = Ok(Vec::new()); + writer.write_all(&[0, 1, 2]).unwrap(); writer.flush().unwrap(); assert_eq!(writer.unwrap(), vec!(0, 1, 2)); } #[test] fn test_option_writer_error() { - let mut writer: io::IoResult<Vec<u8>> = - Err(io::standard_error(io::EndOfFile)); + let mut writer: old_io::IoResult<Vec<u8>> = + Err(old_io::standard_error(old_io::EndOfFile)); - match writer.write(&[0, 0, 0]) { + match writer.write_all(&[0, 0, 0]) { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => assert_eq!(e.kind, old_io::EndOfFile), } match writer.flush() { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => assert_eq!(e.kind, old_io::EndOfFile), } } #[test] fn test_option_reader() { - let mut reader: io::IoResult<MemReader> = + let mut reader: old_io::IoResult<MemReader> = Ok(MemReader::new(vec!(0, 1, 2, 3))); let mut buf = [0, 0]; reader.read(&mut buf).unwrap(); @@ -117,13 +117,13 @@ mod test { #[test] fn test_option_reader_error() { - let mut reader: io::IoResult<MemReader> = - Err(io::standard_error(io::EndOfFile)); + let mut reader: old_io::IoResult<MemReader> = + Err(old_io::standard_error(old_io::EndOfFile)); let mut buf = []; match reader.read(&mut buf) { Ok(..) => panic!(), - Err(e) => assert_eq!(e.kind, io::EndOfFile), + Err(e) => assert_eq!(e.kind, old_io::EndOfFile), } } } diff --git a/src/libstd/io/stdio.rs b/src/libstd/old_io/stdio.rs index a5664b9f013..70400619bea 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/old_io/stdio.rs @@ -19,10 +19,10 @@ //! //! ```rust //! # #![allow(unused_must_use)] -//! use std::io; +//! use std::old_io; //! -//! let mut out = io::stdout(); -//! out.write(b"Hello, world!"); +//! let mut out = old_io::stdout(); +//! out.write_all(b"Hello, world!"); //! ``` use self::StdSource::*; @@ -32,7 +32,7 @@ use cell::RefCell; use clone::Clone; use failure::LOCAL_STDERR; use fmt; -use io::{Reader, Writer, IoResult, IoError, OtherIoError, Buffer, +use old_io::{Reader, Writer, IoResult, IoError, OtherIoError, Buffer, standard_error, EndOfFile, LineBufferedWriter, BufferedReader}; use marker::{Sync, Send}; use libc; @@ -141,9 +141,9 @@ impl StdinReader { /// # Examples /// /// ```rust - /// use std::io; + /// use std::old_io; /// - /// for line in io::stdin().lock().lines() { + /// for line in old_io::stdin().lock().lines() { /// println!("{}", line.unwrap()); /// } /// ``` @@ -370,14 +370,14 @@ pub fn flush() { /// Prints a string to the stdout of the current process. No newline is emitted /// after the string is printed. pub fn print(s: &str) { - with_task_stdout(|io| io.write(s.as_bytes())) + with_task_stdout(|io| io.write_all(s.as_bytes())) } /// Prints a string to the stdout of the current process. A literal /// `\n` character is printed to the console after the string. pub fn println(s: &str) { with_task_stdout(|io| { - io.write(s.as_bytes()).and_then(|()| io.write(&[b'\n'])) + io.write_all(s.as_bytes()).and_then(|()| io.write_all(&[b'\n'])) }) } @@ -498,7 +498,7 @@ impl StdWriter { } impl Writer for StdWriter { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { // As with stdin on windows, stdout often can't handle writes of large // sizes. For an example, see #14940. For this reason, chunk the output // buffer on windows, but on unix we can just write the whole buffer all @@ -539,7 +539,7 @@ mod tests { #[test] fn capture_stdout() { - use io::{ChanReader, ChanWriter}; + use old_io::{ChanReader, ChanWriter}; let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); @@ -552,7 +552,7 @@ mod tests { #[test] fn capture_stderr() { - use io::{ChanReader, ChanWriter, Reader}; + use old_io::{ChanReader, ChanWriter, Reader}; let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); diff --git a/src/libstd/io/tempfile.rs b/src/libstd/old_io/tempfile.rs index 394686be814..029fef7c197 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/old_io/tempfile.rs @@ -10,8 +10,8 @@ //! Temporary files and directories -use io::{fs, IoError, IoErrorKind, IoResult}; -use io; +use old_io::{fs, IoError, IoErrorKind, IoResult}; +use old_io; use iter::{IteratorExt, range}; use ops::Drop; use option::Option; @@ -29,7 +29,7 @@ use string::String; /// # Examples /// /// ```no_run -/// use std::io::TempDir; +/// use std::old_io::TempDir; /// /// { /// // create a temporary directory @@ -113,7 +113,7 @@ impl TempDir { suffix }; let path = tmpdir.join(leaf); - match fs::mkdir(&path, io::USER_RWX) { + match fs::mkdir(&path, old_io::USER_RWX) { Ok(_) => return Ok(TempDir { path: Some(path), disarmed: false }), Err(IoError{kind:IoErrorKind::PathAlreadyExists,..}) => (), Err(e) => return Err(e) diff --git a/src/libstd/io/test.rs b/src/libstd/old_io/test.rs index 6de466eb20b..f49e2397d42 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/old_io/test.rs @@ -14,7 +14,7 @@ use prelude::v1::*; use libc; use os; -use std::io::net::ip::*; +use std::old_io::net::ip::*; use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; /// Get a port number, starting at 9600, for use in tests diff --git a/src/libstd/io/timer.rs b/src/libstd/old_io/timer.rs index 68ae7d0ff20..7e15c9ad7fc 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/old_io/timer.rs @@ -17,7 +17,7 @@ use sync::mpsc::{Receiver, Sender, channel}; use time::Duration; -use io::IoResult; +use old_io::IoResult; use sys::timer::Callback; use sys::timer::Timer as TimerImp; @@ -31,7 +31,7 @@ use sys::timer::Timer as TimerImp; /// /// ``` /// # fn foo() { -/// use std::io::Timer; +/// use std::old_io::Timer; /// use std::time::Duration; /// /// let mut timer = Timer::new().unwrap(); @@ -50,11 +50,11 @@ use sys::timer::Timer as TimerImp; /// ``` /// /// If only sleeping is necessary, then a convenience API is provided through -/// the `io::timer` module. +/// the `old_io::timer` module. /// /// ``` /// # fn foo() { -/// use std::io::timer; +/// use std::old_io::timer; /// use std::time::Duration; /// /// // Put this task to sleep for 5 seconds @@ -115,7 +115,7 @@ impl Timer { /// # Example /// /// ```rust - /// use std::io::Timer; + /// use std::old_io::Timer; /// use std::time::Duration; /// /// let mut timer = Timer::new().unwrap(); @@ -128,7 +128,7 @@ impl Timer { /// ``` /// /// ```rust - /// use std::io::Timer; + /// use std::old_io::Timer; /// use std::time::Duration; /// /// // Incorrect, method chaining-style: @@ -167,7 +167,7 @@ impl Timer { /// # Example /// /// ```rust - /// use std::io::Timer; + /// use std::old_io::Timer; /// use std::time::Duration; /// /// let mut timer = Timer::new().unwrap(); @@ -186,7 +186,7 @@ impl Timer { /// ``` /// /// ```rust - /// use std::io::Timer; + /// use std::old_io::Timer; /// use std::time::Duration; /// /// // Incorrect, method chaining-style. diff --git a/src/libstd/io/util.rs b/src/libstd/old_io/util.rs index e4bf38a9ef5..4b6d9b08141 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/old_io/util.rs @@ -12,7 +12,7 @@ use prelude::v1::*; use cmp; -use io; +use old_io; use slice::bytes::MutableByteVector; /// Wraps a `Reader`, limiting the number of bytes that can be read from it. @@ -42,9 +42,9 @@ impl<R: Reader> LimitReader<R> { } impl<R: Reader> Reader for LimitReader<R> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { if self.limit == 0 { - return Err(io::standard_error(io::EndOfFile)); + return Err(old_io::standard_error(old_io::EndOfFile)); } let len = cmp::min(self.limit, buf.len()); @@ -58,11 +58,11 @@ impl<R: Reader> Reader for LimitReader<R> { } impl<R: Buffer> Buffer for LimitReader<R> { - fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> { + fn fill_buf<'a>(&'a mut self) -> old_io::IoResult<&'a [u8]> { let amt = try!(self.inner.fill_buf()); let buf = &amt[..cmp::min(amt.len(), self.limit)]; if buf.len() == 0 { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } else { Ok(buf) } @@ -83,7 +83,7 @@ pub struct NullWriter; impl Writer for NullWriter { #[inline] - fn write(&mut self, _buf: &[u8]) -> io::IoResult<()> { Ok(()) } + fn write_all(&mut self, _buf: &[u8]) -> old_io::IoResult<()> { Ok(()) } } /// A `Reader` which returns an infinite stream of 0 bytes, like /dev/zero. @@ -92,14 +92,14 @@ pub struct ZeroReader; impl Reader for ZeroReader { #[inline] - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { buf.set_memory(0); Ok(buf.len()) } } impl Buffer for ZeroReader { - fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> { + fn fill_buf<'a>(&'a mut self) -> old_io::IoResult<&'a [u8]> { static DATA: [u8; 64] = [0; 64]; Ok(DATA.as_slice()) } @@ -113,14 +113,14 @@ pub struct NullReader; impl Reader for NullReader { #[inline] - fn read(&mut self, _buf: &mut [u8]) -> io::IoResult<uint> { - Err(io::standard_error(io::EndOfFile)) + fn read(&mut self, _buf: &mut [u8]) -> old_io::IoResult<uint> { + Err(old_io::standard_error(old_io::EndOfFile)) } } impl Buffer for NullReader { - fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> { - Err(io::standard_error(io::EndOfFile)) + fn fill_buf<'a>(&'a mut self) -> old_io::IoResult<&'a [u8]> { + Err(old_io::standard_error(old_io::EndOfFile)) } fn consume(&mut self, _amt: uint) {} } @@ -143,15 +143,15 @@ impl<W> MultiWriter<W> where W: Writer { impl<W> Writer for MultiWriter<W> where W: Writer { #[inline] - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { for writer in self.writers.iter_mut() { - try!(writer.write(buf)); + try!(writer.write_all(buf)); } Ok(()) } #[inline] - fn flush(&mut self) -> io::IoResult<()> { + fn flush(&mut self) -> old_io::IoResult<()> { for writer in self.writers.iter_mut() { try!(writer.flush()); } @@ -176,13 +176,13 @@ impl<R: Reader, I: Iterator<Item=R>> ChainedReader<I, R> { } impl<R: Reader, I: Iterator<Item=R>> Reader for ChainedReader<I, R> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { loop { let err = match self.cur_reader { Some(ref mut r) => { match r.read(buf) { Ok(len) => return Ok(len), - Err(ref e) if e.kind == io::EndOfFile => None, + Err(ref e) if e.kind == old_io::EndOfFile => None, Err(e) => Some(e), } } @@ -194,7 +194,7 @@ impl<R: Reader, I: Iterator<Item=R>> Reader for ChainedReader<I, R> { None => {} } } - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } } @@ -221,23 +221,23 @@ impl<R: Reader, W: Writer> TeeReader<R, W> { } impl<R: Reader, W: Writer> Reader for TeeReader<R, W> { - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { self.reader.read(buf).and_then(|len| { - self.writer.write(&mut buf[..len]).map(|()| len) + self.writer.write_all(&mut buf[..len]).map(|()| len) }) } } /// Copies all data from a `Reader` to a `Writer`. -pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> { +pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> old_io::IoResult<()> { let mut buf = [0; super::DEFAULT_BUF_SIZE]; loop { let len = match r.read(&mut buf) { Ok(len) => len, - Err(ref e) if e.kind == io::EndOfFile => return Ok(()), + Err(ref e) if e.kind == old_io::EndOfFile => return Ok(()), Err(e) => return Err(e), }; - try!(w.write(&buf[..len])); + try!(w.write_all(&buf[..len])); } } @@ -257,14 +257,14 @@ impl<T: Iterator<Item=u8>> IterReader<T> { impl<T: Iterator<Item=u8>> Reader for IterReader<T> { #[inline] - fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> { + fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> { let mut len = 0; for (slot, elt) in buf.iter_mut().zip(self.iter.by_ref()) { *slot = elt; len += 1; } if len == 0 && buf.len() != 0 { - Err(io::standard_error(io::EndOfFile)) + Err(old_io::standard_error(old_io::EndOfFile)) } else { Ok(len) } @@ -275,8 +275,8 @@ impl<T: Iterator<Item=u8>> Reader for IterReader<T> { mod test { use prelude::v1::*; - use io::{MemReader, ByRefReader}; - use io; + use old_io::{MemReader, ByRefReader}; + use old_io; use super::*; #[test] @@ -321,7 +321,7 @@ mod test { fn test_null_writer() { let mut s = NullWriter; let buf = vec![0, 0, 0]; - s.write(buf.as_slice()).unwrap(); + s.write_all(buf.as_slice()).unwrap(); s.flush().unwrap(); } @@ -347,12 +347,12 @@ mod test { struct TestWriter; impl Writer for TestWriter { - fn write(&mut self, _buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, _buf: &[u8]) -> old_io::IoResult<()> { unsafe { writes += 1 } Ok(()) } - fn flush(&mut self) -> io::IoResult<()> { + fn flush(&mut self) -> old_io::IoResult<()> { unsafe { flushes += 1 } Ok(()) } @@ -360,7 +360,7 @@ mod test { let mut multi = MultiWriter::new(vec!(box TestWriter as Box<Writer>, box TestWriter as Box<Writer>)); - multi.write(&[1, 2, 3]).unwrap(); + multi.write_all(&[1, 2, 3]).unwrap(); assert_eq!(2, unsafe { writes }); assert_eq!(0, unsafe { flushes }); multi.flush().unwrap(); @@ -400,7 +400,7 @@ mod test { let mut r = LimitReader::new(r.by_ref(), 3); assert_eq!(r.read_line(), Ok("012".to_string())); assert_eq!(r.limit(), 0); - assert_eq!(r.read_line().err().unwrap().kind, io::EndOfFile); + assert_eq!(r.read_line().err().unwrap().kind, old_io::EndOfFile); } { let mut r = LimitReader::new(r.by_ref(), 9); @@ -432,7 +432,7 @@ mod test { assert_eq!(len, 2); assert!(buf == [6, 7, 5]); - assert_eq!(r.read(&mut buf).unwrap_err().kind, io::EndOfFile); + assert_eq!(r.read(&mut buf).unwrap_err().kind, old_io::EndOfFile); } #[test] diff --git a/src/libstd/os.rs b/src/libstd/os.rs index d81e2b3aa4b..cd37a355e1d 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -10,17 +10,19 @@ //! Higher-level interfaces to libc::* functions and operating system services. //! -//! In general these take and return rust types, use rust idioms (enums, closures, vectors) rather -//! than C idioms, and do more extensive safety checks. +//! In general these take and return rust types, use rust idioms (enums, +//! closures, vectors) rather than C idioms, and do more extensive safety +//! checks. //! -//! This module is not meant to only contain 1:1 mappings to libc entries; any os-interface code -//! that is reasonably useful and broadly applicable can go here. Including utility routines that -//! merely build on other os code. +//! This module is not meant to only contain 1:1 mappings to libc entries; any +//! os-interface code that is reasonably useful and broadly applicable can go +//! here. Including utility routines that merely build on other os code. //! -//! We assume the general case is that users do not care, and do not want to be made to care, which -//! operating system they are on. While they may want to special case various special cases -- and -//! so we will not _hide_ the facts of which OS the user is on -- they should be given the -//! opportunity to write OS-ignorant code by default. +//! We assume the general case is that users do not care, and do not want to be +//! made to care, which operating system they are on. While they may want to +//! special case various special cases -- and so we will not _hide_ the facts of +//! which OS the user is on -- they should be given the opportunity to write +//! OS-ignorant code by default. #![unstable(feature = "os")] @@ -35,7 +37,7 @@ use self::MapError::*; use clone::Clone; use error::{FromError, Error}; use fmt; -use io::{IoResult, IoError}; +use old_io::{IoResult, IoError}; use iter::{Iterator, IteratorExt}; use marker::{Copy, Send}; use libc::{c_void, c_int, c_char}; @@ -374,7 +376,7 @@ pub struct Pipe { /// This function is also unsafe as there is no destructor associated with the /// `Pipe` structure will return. If it is not arranged for the returned file /// descriptors to be closed, the file descriptors will leak. For safe handling -/// of this scenario, use `std::io::PipeStream` instead. +/// of this scenario, use `std::old_io::PipeStream` instead. pub unsafe fn pipe() -> IoResult<Pipe> { let (reader, writer) = try!(sys::os::pipe()); Ok(Pipe { @@ -1635,10 +1637,10 @@ mod tests { fn memory_map_file() { use libc; use os::*; - use io::fs::{File, unlink}; - use io::SeekStyle::SeekSet; - use io::FileMode::Open; - use io::FileAccess::ReadWrite; + use old_io::fs::{File, unlink}; + use old_io::SeekStyle::SeekSet; + use old_io::FileMode::Open; + use old_io::FileAccess::ReadWrite; #[cfg(not(windows))] fn get_fd(file: &File) -> libc::c_int { diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index e4a662f8463..b42353e964c 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -49,7 +49,7 @@ //! ## Example //! //! ```rust -//! use std::io::fs::PathExtensions; +//! use std::old_io::fs::PathExtensions; //! //! let mut path = Path::new("/tmp/path"); //! println!("path: {}", path.display()); diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 07fdd1a830f..39138e14803 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -14,7 +14,7 @@ use clone::Clone; use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd}; use fmt; use hash; -use io::Writer; +use old_io::Writer; use iter::{AdditiveIterator, Extend}; use iter::{Iterator, IteratorExt, Map}; use marker::Sized; diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index ebded1f0855..34faa65af75 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -20,7 +20,7 @@ use clone::Clone; use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd}; use fmt; use hash; -use io::Writer; +use old_io::Writer; use iter::{AdditiveIterator, Extend}; use iter::{Iterator, IteratorExt, Map, repeat}; use mem; diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 51cf173ca94..51c9f9de83c 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -62,6 +62,6 @@ // NB: remove when path reform lands #[doc(no_inline)] pub use path::{Path, GenericPath}; // NB: remove when I/O reform lands -#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude}; +#[doc(no_inline)] pub use old_io::{Buffer, Writer, Reader, Seek, BufferPrelude}; // NB: remove when range syntax lands #[doc(no_inline)] pub use iter::range; diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 5844cc85c31..8f5d0e22c88 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -223,7 +223,7 @@ use cell::RefCell; use clone::Clone; -use io::IoResult; +use old_io::IoResult; use iter::{Iterator, IteratorExt}; use mem; use rc::Rc; diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index bafbde2511d..547c8131486 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -19,7 +19,7 @@ mod imp { use self::OsRngInner::*; - use io::{IoResult, File}; + use old_io::{IoResult, File}; use path::Path; use rand::Rng; use rand::reader::ReaderRng; @@ -187,7 +187,7 @@ mod imp { mod imp { extern crate libc; - use io::{IoResult}; + use old_io::{IoResult}; use marker::Sync; use mem; use os; @@ -259,7 +259,7 @@ mod imp { mod imp { extern crate libc; - use io::{IoResult, IoError}; + use old_io::{IoResult, IoError}; use mem; use ops::Drop; use os; diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index 177b7380831..afacfeeaa30 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -10,7 +10,7 @@ //! A wrapper around any Reader to treat it as an RNG. -use io::Reader; +use old_io::Reader; use rand::Rng; use result::Result::{Ok, Err}; use slice::SliceExt; @@ -26,7 +26,7 @@ use slice::SliceExt; /// /// ```rust /// use std::rand::{reader, Rng}; -/// use std::io::MemReader; +/// use std::old_io::MemReader; /// /// let mut rng = reader::ReaderRng::new(MemReader::new(vec!(1,2,3,4,5,6,7,8))); /// println!("{:x}", rng.gen::<uint>()); @@ -77,7 +77,7 @@ mod test { use prelude::v1::*; use super::ReaderRng; - use io::MemReader; + use old_io::MemReader; use num::Int; use rand::Rng; diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 92316fe26b4..322c6137984 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -120,7 +120,7 @@ //! //! ```no_run //! use std::sync::mpsc::channel; -//! use std::io::timer::Timer; +//! use std::old_io::timer::Timer; //! use std::time::Duration; //! //! let (tx, rx) = channel::<int>(); @@ -144,7 +144,7 @@ //! //! ```no_run //! use std::sync::mpsc::channel; -//! use std::io::timer::Timer; +//! use std::old_io::timer::Timer; //! use std::time::Duration; //! //! let (tx, rx) = channel::<int>(); diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index d069d9ee3b8..9b53ebf70a0 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -10,7 +10,7 @@ use prelude::v1::*; -use io::IoResult; +use old_io::IoResult; #[cfg(target_pointer_width = "64")] pub const HEX_WIDTH: uint = 18; diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index 272cf9bd0c0..ae01586c703 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -11,7 +11,7 @@ #![allow(missing_docs)] #![allow(dead_code)] -use io::{self, IoError, IoResult}; +use old_io::{self, IoError, IoResult}; use prelude::v1::*; use sys::{last_error, retry}; use ffi::CString; @@ -35,7 +35,7 @@ pub mod wtf8; pub fn eof() -> IoError { IoError { - kind: io::EndOfFile, + kind: old_io::EndOfFile, desc: "end of file", detail: None, } @@ -43,7 +43,7 @@ pub fn eof() -> IoError { pub fn timeout(desc: &'static str) -> IoError { IoError { - kind: io::TimedOut, + kind: old_io::TimedOut, desc: desc, detail: None, } @@ -51,7 +51,7 @@ pub fn timeout(desc: &'static str) -> IoError { pub fn short_write(n: uint, desc: &'static str) -> IoError { IoError { - kind: if n == 0 { io::TimedOut } else { io::ShortWrite(n) }, + kind: if n == 0 { old_io::TimedOut } else { old_io::ShortWrite(n) }, desc: desc, detail: None, } @@ -59,7 +59,7 @@ pub fn short_write(n: uint, desc: &'static str) -> IoError { pub fn unimpl() -> IoError { IoError { - kind: io::IoUnavailable, + kind: old_io::IoUnavailable, desc: "operations not yet supported", detail: None, } diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 4cf891ac498..e42db42dc60 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -14,9 +14,9 @@ use self::InAddr::*; use ffi::CString; use ffi; -use io::net::addrinfo; -use io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr}; -use io::{IoResult, IoError}; +use old_io::net::addrinfo; +use old_io::net::ip::{SocketAddr, IpAddr, Ipv4Addr, Ipv6Addr}; +use old_io::{IoResult, IoError}; use libc::{self, c_char, c_int}; use mem; use num::Int; @@ -28,7 +28,7 @@ use sys::{self, retry, c, sock_t, last_error, last_net_error, last_gai_error, cl use sync::{Arc, Mutex, MutexGuard}; use sys_common::{self, keep_going, short_write, timeout}; use cmp; -use io; +use old_io; // FIXME: move uses of Arc and deadline tracking to std::io @@ -208,7 +208,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, } _ => { Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "invalid argument", detail: None, }) @@ -458,7 +458,7 @@ pub fn write<T, L, W>(fd: sock_t, // As with read(), first wait for the socket to be ready for // the I/O operation. match await(&[fd], deadline, Writable) { - Err(ref e) if e.kind == io::EndOfFile && written > 0 => { + Err(ref e) if e.kind == old_io::EndOfFile && written > 0 => { assert!(deadline.is_some()); return Err(short_write(written, "short write")) } diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index cb2edf50ebd..ca1a16d8e17 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -86,7 +86,7 @@ use prelude::v1::*; use ffi; -use io::IoResult; +use old_io::IoResult; use libc; use mem; use str; @@ -136,7 +136,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> { #[inline(never)] // if we know this is a function call, we can skip it when // tracing pub fn write(w: &mut Writer) -> IoResult<()> { - use io::IoError; + use old_io::IoError; struct Context<'a> { idx: int, @@ -375,7 +375,7 @@ fn output(w: &mut Writer, idx: int, addr: *mut libc::c_void, Some(string) => try!(demangle(w, string)), None => try!(write!(w, "<unknown>")), } - w.write(&['\n' as u8]) + w.write_all(&['\n' as u8]) } /// Unwind library interface used for backtraces diff --git a/src/libstd/sys/unix/ext.rs b/src/libstd/sys/unix/ext.rs index 3cff5be071c..4a82b2807e7 100644 --- a/src/libstd/sys/unix/ext.rs +++ b/src/libstd/sys/unix/ext.rs @@ -18,7 +18,7 @@ //! ```rust,ignore //! #![feature(globs)] //! -//! use std::io::fs::File; +//! use std::old_io::fs::File; //! use std::os::unix::prelude::*; //! //! fn main() { @@ -37,7 +37,7 @@ use sys_common::{AsInner, IntoInner, FromInner}; use ffi::{OsStr, OsString}; use libc; -use io; +use old_io; /// Raw file descriptors. pub type Fd = libc::c_int; @@ -48,55 +48,55 @@ pub trait AsRawFd { fn as_raw_fd(&self) -> Fd; } -impl AsRawFd for io::fs::File { +impl AsRawFd for old_io::fs::File { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::pipe::PipeStream { +impl AsRawFd for old_io::pipe::PipeStream { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::pipe::UnixStream { +impl AsRawFd for old_io::net::pipe::UnixStream { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::pipe::UnixListener { +impl AsRawFd for old_io::net::pipe::UnixListener { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::pipe::UnixAcceptor { +impl AsRawFd for old_io::net::pipe::UnixAcceptor { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::tcp::TcpStream { +impl AsRawFd for old_io::net::tcp::TcpStream { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::tcp::TcpListener { +impl AsRawFd for old_io::net::tcp::TcpListener { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::tcp::TcpAcceptor { +impl AsRawFd for old_io::net::tcp::TcpAcceptor { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } } -impl AsRawFd for io::net::udp::UdpSocket { +impl AsRawFd for old_io::net::udp::UdpSocket { fn as_raw_fd(&self) -> Fd { self.as_inner().fd() } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index dd478347f81..66ae018cb36 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -13,10 +13,10 @@ use prelude::v1::*; use ffi::{self, CString}; -use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; -use io::{IoResult, FileStat, SeekStyle}; -use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; -use io; +use old_io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; +use old_io::{IoResult, FileStat, SeekStyle}; +use old_io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; +use old_io; use libc::{self, c_int, c_void}; use mem; use ptr; @@ -304,12 +304,12 @@ fn mkstat(stat: &libc::stat) -> FileStat { FileStat { size: stat.st_size as u64, kind: match (stat.st_mode as libc::mode_t) & libc::S_IFMT { - libc::S_IFREG => io::FileType::RegularFile, - libc::S_IFDIR => io::FileType::Directory, - libc::S_IFIFO => io::FileType::NamedPipe, - libc::S_IFBLK => io::FileType::BlockSpecial, - libc::S_IFLNK => io::FileType::Symlink, - _ => io::FileType::Unknown, + libc::S_IFREG => old_io::FileType::RegularFile, + libc::S_IFDIR => old_io::FileType::Directory, + libc::S_IFIFO => old_io::FileType::NamedPipe, + libc::S_IFBLK => old_io::FileType::BlockSpecial, + libc::S_IFLNK => old_io::FileType::Symlink, + _ => old_io::FileType::Unknown, }, perm: FilePermission::from_bits_truncate(stat.st_mode as u32), created: mktime(stat.st_ctime as u64, stat.st_ctime_nsec as u64), diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 5493bc20a87..f2f2e7436bf 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -18,7 +18,7 @@ use prelude::v1::*; use ffi; -use io::{self, IoResult, IoError}; +use old_io::{self, IoResult, IoError}; use libc; use num::{Int, SignedInt}; use num; @@ -94,35 +94,35 @@ pub fn last_gai_error(s: libc::c_int) -> IoError { pub fn decode_error(errno: i32) -> IoError { // FIXME: this should probably be a bit more descriptive... let (kind, desc) = match errno { - libc::EOF => (io::EndOfFile, "end of file"), - libc::ECONNREFUSED => (io::ConnectionRefused, "connection refused"), - libc::ECONNRESET => (io::ConnectionReset, "connection reset"), + libc::EOF => (old_io::EndOfFile, "end of file"), + libc::ECONNREFUSED => (old_io::ConnectionRefused, "connection refused"), + libc::ECONNRESET => (old_io::ConnectionReset, "connection reset"), libc::EPERM | libc::EACCES => - (io::PermissionDenied, "permission denied"), - libc::EPIPE => (io::BrokenPipe, "broken pipe"), - libc::ENOTCONN => (io::NotConnected, "not connected"), - libc::ECONNABORTED => (io::ConnectionAborted, "connection aborted"), - libc::EADDRNOTAVAIL => (io::ConnectionRefused, "address not available"), - libc::EADDRINUSE => (io::ConnectionRefused, "address in use"), - libc::ENOENT => (io::FileNotFound, "no such file or directory"), - libc::EISDIR => (io::InvalidInput, "illegal operation on a directory"), - libc::ENOSYS => (io::IoUnavailable, "function not implemented"), - libc::EINVAL => (io::InvalidInput, "invalid argument"), + (old_io::PermissionDenied, "permission denied"), + libc::EPIPE => (old_io::BrokenPipe, "broken pipe"), + libc::ENOTCONN => (old_io::NotConnected, "not connected"), + libc::ECONNABORTED => (old_io::ConnectionAborted, "connection aborted"), + libc::EADDRNOTAVAIL => (old_io::ConnectionRefused, "address not available"), + libc::EADDRINUSE => (old_io::ConnectionRefused, "address in use"), + libc::ENOENT => (old_io::FileNotFound, "no such file or directory"), + libc::EISDIR => (old_io::InvalidInput, "illegal operation on a directory"), + libc::ENOSYS => (old_io::IoUnavailable, "function not implemented"), + libc::EINVAL => (old_io::InvalidInput, "invalid argument"), libc::ENOTTY => - (io::MismatchedFileTypeForOperation, + (old_io::MismatchedFileTypeForOperation, "file descriptor is not a TTY"), - libc::ETIMEDOUT => (io::TimedOut, "operation timed out"), - libc::ECANCELED => (io::TimedOut, "operation aborted"), + libc::ETIMEDOUT => (old_io::TimedOut, "operation timed out"), + libc::ECANCELED => (old_io::TimedOut, "operation aborted"), libc::consts::os::posix88::EEXIST => - (io::PathAlreadyExists, "path already exists"), + (old_io::PathAlreadyExists, "path already exists"), // These two constants can have the same value on some systems, // but different values on others, so we can't use a match // clause x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => - (io::ResourceUnavailable, "resource temporarily unavailable"), + (old_io::ResourceUnavailable, "resource temporarily unavailable"), - _ => (io::OtherIoError, "unknown error") + _ => (old_io::OtherIoError, "unknown error") }; IoError { kind: kind, desc: desc, detail: None } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 2c25af055ee..5d5cda03f01 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -15,7 +15,7 @@ use prelude::v1::*; use error::{FromError, Error}; use ffi::{self, CString}; use fmt; -use io::{IoError, IoResult}; +use old_io::{IoError, IoResult}; use libc::{self, c_int, c_char, c_void}; use os::TMPBUF_SZ; use os; @@ -198,7 +198,7 @@ pub fn load_self() -> Option<Vec<u8>> { pub fn load_self() -> Option<Vec<u8>> { use std::io; - match io::fs::readlink(&Path::new("/proc/curproc/file")) { + match old_io::fs::readlink(&Path::new("/proc/curproc/file")) { Ok(path) => Some(path.into_vec()), Err(..) => None } @@ -206,9 +206,9 @@ pub fn load_self() -> Option<Vec<u8>> { #[cfg(any(target_os = "linux", target_os = "android"))] pub fn load_self() -> Option<Vec<u8>> { - use std::io; + use old_io; - match io::fs::readlink(&Path::new("/proc/self/exe")) { + match old_io::fs::readlink(&Path::new("/proc/self/exe")) { Ok(path) => Some(path.into_vec()), Err(..) => None } diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index 158a1ce2204..16274a2ab08 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -15,7 +15,7 @@ use libc; use mem; use sync::{Arc, Mutex}; use sync::atomic::{AtomicBool, Ordering}; -use io::{self, IoResult, IoError}; +use old_io::{self, IoResult, IoError}; use sys::{self, timer, retry, c, set_nonblocking, wouldblock}; use sys::fs::{fd_t, FileDesc}; @@ -41,7 +41,7 @@ fn addr_to_sockaddr_un(addr: &CString, let len = addr.len(); if len > s.sun_path.len() - 1 { return Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "invalid argument: path must be smaller than SUN_LEN", detail: None, }) diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 2b4d168d881..6e12432649f 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -15,8 +15,8 @@ use collections::HashMap; use collections::hash_map::Hasher; use ffi::CString; use hash::Hash; -use io::process::{ProcessExit, ExitStatus, ExitSignal}; -use io::{self, IoResult, IoError, EndOfFile}; +use old_io::process::{ProcessExit, ExitStatus, ExitSignal}; +use old_io::{self, IoResult, IoError, EndOfFile}; use libc::{self, pid_t, c_void, c_int}; use mem; use os; diff --git a/src/libstd/sys/unix/tcp.rs b/src/libstd/sys/unix/tcp.rs index 59eebd3f28e..c8f9d318482 100644 --- a/src/libstd/sys/unix/tcp.rs +++ b/src/libstd/sys/unix/tcp.rs @@ -10,8 +10,8 @@ use prelude::v1::*; -use io::net::ip; -use io::IoResult; +use old_io::net::ip; +use old_io::IoResult; use libc; use mem; use ptr; diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index c0c231a9e73..6a4e47f58ce 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -49,7 +49,7 @@ use prelude::v1::*; use self::Req::*; -use io::IoResult; +use old_io::IoResult; use libc; use mem; use os; diff --git a/src/libstd/sys/unix/tty.rs b/src/libstd/sys/unix/tty.rs index d20469f5106..d414f70152d 100644 --- a/src/libstd/sys/unix/tty.rs +++ b/src/libstd/sys/unix/tty.rs @@ -12,7 +12,7 @@ use prelude::v1::*; use sys::fs::FileDesc; use libc::{self, c_int, c_ulong, funcs}; -use io::{self, IoResult, IoError}; +use old_io::{self, IoResult, IoError}; use sys::c; use sys_common; @@ -33,7 +33,7 @@ impl TTY { Ok(TTY { fd: FileDesc::new(fd, true) }) } else { Err(IoError { - kind: io::MismatchedFileTypeForOperation, + kind: old_io::MismatchedFileTypeForOperation, desc: "file descriptor is not a TTY", detail: None, }) @@ -67,7 +67,7 @@ impl TTY { let mut size = winsize { ws_row: 0, ws_col: 0, ws_xpixel: 0, ws_ypixel: 0 }; if c::ioctl(self.fd.fd(), TIOCGWINSZ, &mut size) == -1 { Err(IoError { - kind: io::OtherIoError, + kind: old_io::OtherIoError, desc: "Size of terminal could not be determined", detail: None, }) diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index cba7d81937a..a186465f234 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -25,7 +25,7 @@ use dynamic_lib::DynamicLibrary; use ffi; use core::ops::Index; use intrinsics; -use io::{IoResult, Writer}; +use old_io::{IoResult, Writer}; use libc; use mem; use ops::Drop; @@ -363,10 +363,10 @@ pub fn write(w: &mut Writer) -> IoResult<()> { let bytes = unsafe { ffi::c_str_to_bytes(&ptr) }; match str::from_utf8(bytes) { Ok(s) => try!(demangle(w, s)), - Err(..) => try!(w.write(&bytes[..bytes.len()-1])), + Err(..) => try!(w.write_all(&bytes[..bytes.len()-1])), } } - try!(w.write(&['\n' as u8])); + try!(w.write_all(&['\n' as u8])); } Ok(()) diff --git a/src/libstd/sys/windows/ext.rs b/src/libstd/sys/windows/ext.rs index 2f45cb78cda..a3bbf5c5fe7 100644 --- a/src/libstd/sys/windows/ext.rs +++ b/src/libstd/sys/windows/ext.rs @@ -23,7 +23,7 @@ use sys_common::{AsInner, FromInner}; use ffi::{OsStr, OsString}; use libc; -use io; +use old_io; /// Raw HANDLEs. pub type Handle = libc::HANDLE; @@ -37,31 +37,31 @@ pub trait AsRawHandle { fn as_raw_handle(&self) -> Handle; } -impl AsRawHandle for io::fs::File { +impl AsRawHandle for old_io::fs::File { fn as_raw_handle(&self) -> Handle { self.as_inner().handle() } } -impl AsRawHandle for io::pipe::PipeStream { +impl AsRawHandle for old_io::pipe::PipeStream { fn as_raw_handle(&self) -> Handle { self.as_inner().handle() } } -impl AsRawHandle for io::net::pipe::UnixStream { +impl AsRawHandle for old_io::net::pipe::UnixStream { fn as_raw_handle(&self) -> Handle { self.as_inner().handle() } } -impl AsRawHandle for io::net::pipe::UnixListener { +impl AsRawHandle for old_io::net::pipe::UnixListener { fn as_raw_handle(&self) -> Handle { self.as_inner().handle() } } -impl AsRawHandle for io::net::pipe::UnixAcceptor { +impl AsRawHandle for old_io::net::pipe::UnixAcceptor { fn as_raw_handle(&self) -> Handle { self.as_inner().handle() } @@ -72,25 +72,25 @@ pub trait AsRawSocket { fn as_raw_socket(&self) -> Socket; } -impl AsRawSocket for io::net::tcp::TcpStream { +impl AsRawSocket for old_io::net::tcp::TcpStream { fn as_raw_socket(&self) -> Socket { self.as_inner().fd() } } -impl AsRawSocket for io::net::tcp::TcpListener { +impl AsRawSocket for old_io::net::tcp::TcpListener { fn as_raw_socket(&self) -> Socket { self.as_inner().socket() } } -impl AsRawSocket for io::net::tcp::TcpAcceptor { +impl AsRawSocket for old_io::net::tcp::TcpAcceptor { fn as_raw_socket(&self) -> Socket { self.as_inner().socket() } } -impl AsRawSocket for io::net::udp::UdpSocket { +impl AsRawSocket for old_io::net::udp::UdpSocket { fn as_raw_socket(&self) -> Socket { self.as_inner().fd() } diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index cb8ef7eb66b..d9d1a374651 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -18,16 +18,16 @@ use sys::os::fill_utf16_buf_and_decode; use path; use ptr; use str; -use io; +use old_io; use prelude::v1::*; use sys; use sys::os; use sys_common::{keep_going, eof, mkerr_libc}; -use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; -use io::{IoResult, IoError, FileStat, SeekStyle}; -use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; +use old_io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; +use old_io::{IoResult, IoError, FileStat, SeekStyle}; +use old_io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; pub type fd_t = libc::c_int; @@ -130,7 +130,7 @@ impl FileDesc { return ret; } - pub fn fstat(&self) -> IoResult<io::FileStat> { + pub fn fstat(&self) -> IoResult<old_io::FileStat> { let mut stat: libc::stat = unsafe { mem::zeroed() }; match unsafe { libc::fstat(self.fd(), &mut stat) } { 0 => Ok(mkstat(&stat)), @@ -268,7 +268,7 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> { Err(..) => { assert!(libc::FindClose(find_handle) != 0); return Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "path was not valid UTF-16", detail: Some(format!("path was not valid UTF-16: {:?}", filename)), }) @@ -303,14 +303,14 @@ pub fn unlink(p: &Path) -> IoResult<()> { // however, it cannot. To keep the two platforms in line with // respect to their behavior, catch this case on windows, attempt to // change it to read-write, and then remove the file. - if e.kind == io::PermissionDenied { + if e.kind == old_io::PermissionDenied { let stat = match stat(p) { Ok(stat) => stat, Err(..) => return Err(e), }; - if stat.perm.intersects(io::USER_WRITE) { return Err(e) } + if stat.perm.intersects(old_io::USER_WRITE) { return Err(e) } - match chmod(p, (stat.perm | io::USER_WRITE).bits() as uint) { + match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as uint) { Ok(()) => do_unlink(&p_utf16), Err(..) => { // Try to put it back as we found it @@ -406,12 +406,12 @@ fn mkstat(stat: &libc::stat) -> FileStat { FileStat { size: stat.st_size as u64, kind: match (stat.st_mode as libc::c_int) & libc::S_IFMT { - libc::S_IFREG => io::FileType::RegularFile, - libc::S_IFDIR => io::FileType::Directory, - libc::S_IFIFO => io::FileType::NamedPipe, - libc::S_IFBLK => io::FileType::BlockSpecial, - libc::S_IFLNK => io::FileType::Symlink, - _ => io::FileType::Unknown, + libc::S_IFREG => old_io::FileType::RegularFile, + libc::S_IFDIR => old_io::FileType::Directory, + libc::S_IFIFO => old_io::FileType::NamedPipe, + libc::S_IFBLK => old_io::FileType::BlockSpecial, + libc::S_IFLNK => old_io::FileType::Symlink, + _ => old_io::FileType::Unknown, }, perm: FilePermission::from_bits_truncate(stat.st_mode as u32), created: stat.st_ctime as u64, diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 876159623ac..e8b65c9b64e 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -22,7 +22,7 @@ use prelude::v1::*; use num; use mem; -use io::{self, IoResult, IoError}; +use old_io::{self, IoResult, IoError}; use sync::{Once, ONCE_INIT}; macro_rules! helper_init { (static $name:ident: Helper<$m:ty>) => ( @@ -99,43 +99,43 @@ pub fn last_gai_error(_errno: i32) -> IoError { /// Convert an `errno` value into a high-level error variant and description. pub fn decode_error(errno: i32) -> IoError { let (kind, desc) = match errno { - libc::EOF => (io::EndOfFile, "end of file"), - libc::ERROR_NO_DATA => (io::BrokenPipe, "the pipe is being closed"), - libc::ERROR_FILE_NOT_FOUND => (io::FileNotFound, "file not found"), - libc::ERROR_INVALID_NAME => (io::InvalidInput, "invalid file name"), - libc::WSAECONNREFUSED => (io::ConnectionRefused, "connection refused"), - libc::WSAECONNRESET => (io::ConnectionReset, "connection reset"), + libc::EOF => (old_io::EndOfFile, "end of file"), + libc::ERROR_NO_DATA => (old_io::BrokenPipe, "the pipe is being closed"), + libc::ERROR_FILE_NOT_FOUND => (old_io::FileNotFound, "file not found"), + libc::ERROR_INVALID_NAME => (old_io::InvalidInput, "invalid file name"), + libc::WSAECONNREFUSED => (old_io::ConnectionRefused, "connection refused"), + libc::WSAECONNRESET => (old_io::ConnectionReset, "connection reset"), libc::ERROR_ACCESS_DENIED | libc::WSAEACCES => - (io::PermissionDenied, "permission denied"), + (old_io::PermissionDenied, "permission denied"), libc::WSAEWOULDBLOCK => { - (io::ResourceUnavailable, "resource temporarily unavailable") + (old_io::ResourceUnavailable, "resource temporarily unavailable") } - libc::WSAENOTCONN => (io::NotConnected, "not connected"), - libc::WSAECONNABORTED => (io::ConnectionAborted, "connection aborted"), - libc::WSAEADDRNOTAVAIL => (io::ConnectionRefused, "address not available"), - libc::WSAEADDRINUSE => (io::ConnectionRefused, "address in use"), - libc::ERROR_BROKEN_PIPE => (io::EndOfFile, "the pipe has ended"), + libc::WSAENOTCONN => (old_io::NotConnected, "not connected"), + libc::WSAECONNABORTED => (old_io::ConnectionAborted, "connection aborted"), + libc::WSAEADDRNOTAVAIL => (old_io::ConnectionRefused, "address not available"), + libc::WSAEADDRINUSE => (old_io::ConnectionRefused, "address in use"), + libc::ERROR_BROKEN_PIPE => (old_io::EndOfFile, "the pipe has ended"), libc::ERROR_OPERATION_ABORTED => - (io::TimedOut, "operation timed out"), - libc::WSAEINVAL => (io::InvalidInput, "invalid argument"), + (old_io::TimedOut, "operation timed out"), + libc::WSAEINVAL => (old_io::InvalidInput, "invalid argument"), libc::ERROR_CALL_NOT_IMPLEMENTED => - (io::IoUnavailable, "function not implemented"), + (old_io::IoUnavailable, "function not implemented"), libc::ERROR_INVALID_HANDLE => - (io::MismatchedFileTypeForOperation, + (old_io::MismatchedFileTypeForOperation, "invalid handle provided to function"), libc::ERROR_NOTHING_TO_TERMINATE => - (io::InvalidInput, "no process to kill"), + (old_io::InvalidInput, "no process to kill"), libc::ERROR_ALREADY_EXISTS => - (io::PathAlreadyExists, "path already exists"), + (old_io::PathAlreadyExists, "path already exists"), // libuv maps this error code to EISDIR. we do too. if it is found // to be incorrect, we can add in some more machinery to only // return this message when ERROR_INVALID_FUNCTION after certain // Windows calls. - libc::ERROR_INVALID_FUNCTION => (io::InvalidInput, + libc::ERROR_INVALID_FUNCTION => (old_io::InvalidInput, "illegal operation on a directory"), - _ => (io::OtherIoError, "unknown error") + _ => (old_io::OtherIoError, "unknown error") }; IoError { kind: kind, desc: desc, detail: None } } @@ -185,7 +185,7 @@ pub fn init_net() { pub fn unimpl() -> IoError { IoError { - kind: io::IoUnavailable, + kind: old_io::IoUnavailable, desc: "operation is not implemented", detail: None, } @@ -199,7 +199,7 @@ pub fn to_utf16(s: Option<&str>) -> IoResult<Vec<u16>> { s }), None => Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "valid unicode input required", detail: None }) diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 36dc9b2afe4..a82259ad5ec 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -16,7 +16,7 @@ use prelude::v1::*; use fmt; -use io::{IoResult, IoError}; +use old_io::{IoResult, IoError}; use iter::repeat; use libc::{c_int, c_void}; use libc; @@ -162,7 +162,7 @@ pub fn fill_utf16_buf_and_decode<F>(mut f: F) -> Option<String> where pub fn getcwd() -> IoResult<Path> { use libc::DWORD; use libc::GetCurrentDirectoryW; - use io::OtherIoError; + use old_io::OtherIoError; let mut buf = [0 as u16; BUF_BYTES]; unsafe { diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 9996909f2f5..dc9fb3253ff 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -88,7 +88,7 @@ use prelude::v1::*; use libc; use ffi::CString; -use io::{self, IoError, IoResult}; +use old_io::{self, IoError, IoResult}; use mem; use ptr; use str; @@ -202,7 +202,7 @@ pub fn await(handle: libc::HANDLE, deadline: u64, fn epipe() -> IoError { IoError { - kind: io::EndOfFile, + kind: old_io::EndOfFile, desc: "the pipe has ended", detail: None, } @@ -485,7 +485,7 @@ impl UnixStream { let amt = offset + bytes_written as uint; return if amt > 0 { Err(IoError { - kind: io::ShortWrite(amt), + kind: old_io::ShortWrite(amt), desc: "short write during write", detail: None, }) diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 1b837385d1e..43f9e805db1 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -14,10 +14,10 @@ use collections; use ffi::CString; use hash::Hash; use collections::hash_map::Hasher; -use io::fs::PathExtensions; -use io::process::{ProcessExit, ExitStatus, ExitSignal}; -use io::{IoResult, IoError}; -use io; +use old_io::fs::PathExtensions; +use old_io::process::{ProcessExit, ExitStatus, ExitSignal}; +use old_io::{IoResult, IoError}; +use old_io; use libc::{pid_t, c_void, c_int}; use libc; use mem; @@ -84,7 +84,7 @@ impl Process { Err(super::last_error()) } else if status != libc::STILL_ACTIVE { Err(IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "no process to kill", detail: None, }) @@ -97,7 +97,7 @@ impl Process { super::mkerr_winbool(ret) } _ => Err(IoError { - kind: io::IoUnavailable, + kind: old_io::IoUnavailable, desc: "unsupported signal on windows", detail: None, }) @@ -133,7 +133,7 @@ impl Process { if cfg.gid().is_some() || cfg.uid().is_some() { return Err(IoError { - kind: io::IoUnavailable, + kind: old_io::IoUnavailable, desc: "unsupported gid/uid requested on windows", detail: None, }) diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index 77139b52efa..b7e27fb37f0 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use io::net::ip; -use io::IoResult; +use old_io::net::ip; +use old_io::IoResult; use libc; use mem; use ptr; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 12b4e56bf52..34f3c418c55 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -26,7 +26,7 @@ use prelude::v1::*; use libc; use ptr; -use io::IoResult; +use old_io::IoResult; use sync::mpsc::{channel, Sender, Receiver, TryRecvError}; use sys::c; use sys::fs::FileDesc; diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index f9e1f0d3ed0..6ecabfa9853 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -27,7 +27,7 @@ use prelude::v1::*; -use io::{self, IoError, IoResult, MemReader}; +use old_io::{self, IoError, IoResult, MemReader}; use iter::repeat; use libc::types::os::arch::extra::LPCVOID; use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID}; @@ -44,7 +44,7 @@ use super::c::{GetConsoleScreenBufferInfo}; fn invalid_encoding() -> IoError { IoError { - kind: io::InvalidInput, + kind: old_io::InvalidInput, desc: "text was not valid unicode", detail: None, } @@ -83,7 +83,7 @@ impl TTY { }) } else { Err(IoError { - kind: io::MismatchedFileTypeForOperation, + kind: old_io::MismatchedFileTypeForOperation, desc: "invalid handle provided to function", detail: None, }) diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index 09f50059936..c19ec8ea25c 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -158,7 +158,7 @@ use sync::{Mutex, Condvar, Arc}; use str::Str; use string::String; use rt::{self, unwind}; -use io::{Writer, stdio}; +use old_io::{Writer, stdio}; use thunk::Thunk; use sys::thread as imp; @@ -516,7 +516,7 @@ mod test { use sync::mpsc::{channel, Sender}; use boxed::BoxAny; use result; - use std::io::{ChanReader, ChanWriter}; + use std::old_io::{ChanReader, ChanWriter}; use super::{Thread, Builder}; use thunk::Thunk; |
