From 58e2337cf13484d1a61f2fe8ebfa2a54c50a505b Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Wed, 2 Nov 2016 22:40:38 -0700 Subject: [PATCH] Update to 2016-10-28 --- Cargo.toml | 2 +- mapping.rs | 9 + ...0c149b4b92aafc5f8d2e48a4265c5d865a1d.patch | 1477 +++++++++++++++++ ...ddddd6195f7283a94b472b2f14cbed9d95fc.patch | 1477 +++++++++++++++++ ...d6652ac212a7e30cb64017914ea1d5687767.patch | 1477 +++++++++++++++++ 5 files changed, 4441 insertions(+), 1 deletion(-) create mode 100644 patches/32820c149b4b92aafc5f8d2e48a4265c5d865a1d.patch create mode 100644 patches/67aaddddd6195f7283a94b472b2f14cbed9d95fc.patch create mode 100644 patches/8f10d6652ac212a7e30cb64017914ea1d5687767.patch diff --git a/Cargo.toml b/Cargo.toml index fd5a39b..2302fd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "core_io" -version = "0.1.20161011" +version = "0.1.20161028" authors = ["The Rust Project Developers", "Jethro Beekman"] license = "MIT/Apache-2.0" description = """ diff --git a/mapping.rs b/mapping.rs index 5173c13..6c1079f 100644 --- a/mapping.rs +++ b/mapping.rs @@ -163,3 +163,12 @@ -Mapping("f1f40f850e2546c2c187514e3d61d17544ba433f","117cbb879e6ef498ea04e08bd80688bf2fc4a183") -Mapping("f883b0bbab6c433eb7b7042b605b4339022c563a","fda473f00fa07b9a8246b104396f9922e54bff16") -Mapping("feeca945738ffc6d252ae0fbb2f35723e4eb95a6","92400cf8dcf411ce7e70ab2960639977d46d5b01") +-Mapping("098d22845933814a92497cbfaa8eb4a9a36b117f","8f10d6652ac212a7e30cb64017914ea1d5687767") +-Mapping("6dc035ed911672c6a1f7afc9eed15fb08e574e5b","67aaddddd6195f7283a94b472b2f14cbed9d95fc") +-Mapping("e0111758eb4f215db4ec26f809ef3edf5dfb66f5","67aaddddd6195f7283a94b472b2f14cbed9d95fc") +-Mapping("16eeeac783d2ede28e09f2a433c612dea309fe33","67aaddddd6195f7283a94b472b2f14cbed9d95fc") +-Mapping("f094206851e72e70528790cc9c70a745184ff7b0","32820c149b4b92aafc5f8d2e48a4265c5d865a1d") +-Mapping("3caf63cc00f5cec580954bdb117f4fa756cc757d","32820c149b4b92aafc5f8d2e48a4265c5d865a1d") +-Mapping("aef18be1bc4e03617177c5e9df1164ce3df49ba2","32820c149b4b92aafc5f8d2e48a4265c5d865a1d") +-Mapping("c59cb71d976ceabf00c7da0224a795fab530601e","32820c149b4b92aafc5f8d2e48a4265c5d865a1d") +-Mapping("3f4408347d2109803edbf53c89c8bce575de4b67","32820c149b4b92aafc5f8d2e48a4265c5d865a1d") diff --git a/patches/32820c149b4b92aafc5f8d2e48a4265c5d865a1d.patch b/patches/32820c149b4b92aafc5f8d2e48a4265c5d865a1d.patch new file mode 100644 index 0000000..c6899e2 --- /dev/null +++ b/patches/32820c149b4b92aafc5f8d2e48a4265c5d865a1d.patch @@ -0,0 +1,1477 @@ +diff --git a/buffered.rs b/buffered.rs +index 44dd4e9..20ab840 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + BufReader { + inner: inner, +@@ -118,7 +115,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -139,7 +135,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -160,11 +155,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -182,7 +175,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -199,7 +191,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -209,7 +200,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -302,7 +292,6 @@ impl Seek for BufReader { + /// [`Write`]: ../../std/io/trait.Write.html + /// [`write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -337,7 +326,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -351,7 +339,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -369,7 +356,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -418,7 +404,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -436,7 +421,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -454,7 +438,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -463,7 +446,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -483,7 +465,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -493,7 +474,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -503,7 +483,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -542,7 +521,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -575,23 +553,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -646,7 +614,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + } +@@ -666,7 +633,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -687,7 +653,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { inner: BufWriter::with_capacity(cap, inner) } + } +@@ -708,7 +673,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -731,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -753,7 +716,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { inner: buf }, e) +@@ -761,7 +723,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + match memchr::memrchr(b'\n', buf) { +@@ -780,7 +741,6 @@ impl Write for LineWriter { + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index ca9452f..4f68be4 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -98,7 +98,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -116,7 +115,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -132,7 +130,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -151,7 +148,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -173,7 +169,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -193,11 +188,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let pos = match style { +@@ -216,25 +209,27 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature = "collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -246,7 +241,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -276,8 +271,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index ddf0030..748b830 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,10 +8,15 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -43,7 +48,6 @@ use sys; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -55,20 +59,22 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + + enum Repr { + Os(i32), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -80,47 +86,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -130,10 +123,8 @@ pub enum ErrorKind { + /// + /// For example, a function that reads a file into a string will error with + /// `InvalidData` if the file's contents are not valid UTF-8. +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to `write` returned `Ok(0)`. +@@ -141,15 +132,12 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it wrote a + /// particular number of bytes but only a smaller number of bytes could be + /// written. +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -158,15 +146,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -190,14 +173,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -206,24 +188,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -249,7 +213,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -280,7 +243,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -313,11 +275,10 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -383,11 +344,10 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -416,8 +376,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Custom(c) => Some(c.error) +@@ -442,10 +401,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + } + } +@@ -455,63 +413,23 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) => match self.kind() { +- ErrorKind::NotFound => "entity not found", +- ErrorKind::PermissionDenied => "permission denied", +- ErrorKind::ConnectionRefused => "connection refused", +- ErrorKind::ConnectionReset => "connection reset", +- ErrorKind::ConnectionAborted => "connection aborted", +- ErrorKind::NotConnected => "not connected", +- ErrorKind::AddrInUse => "address in use", +- ErrorKind::AddrNotAvailable => "address not available", +- ErrorKind::BrokenPipe => "broken pipe", +- ErrorKind::AlreadyExists => "entity already exists", +- ErrorKind::WouldBlock => "operation would block", +- ErrorKind::InvalidInput => "invalid input parameter", +- ErrorKind::InvalidData => "invalid data", +- ErrorKind::TimedOut => "timed out", +- ErrorKind::WriteZero => "write zero", +- ErrorKind::Interrupted => "operation interrupted", +- ErrorKind::Other => "other os error", +- ErrorKind::UnexpectedEof => "unexpected end of file", +- ErrorKind::__Nonexhaustive => unreachable!() +- }, +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index cd05e6b..d048379 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,26 +8,31 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -38,7 +43,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -56,12 +60,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -80,18 +83,20 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -102,7 +107,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -120,12 +125,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -147,7 +152,6 @@ impl BufRead for Box { + // ============================================================================= + // In-memory buffer implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -171,7 +175,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -180,7 +184,6 @@ impl<'a> BufRead for &'a [u8] { + fn consume(&mut self, amt: usize) { *self = &self[amt..]; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -204,7 +207,7 @@ impl<'a> Write for &'a mut [u8] { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 37c3f70..7232bd1 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -252,42 +252,32 @@ + //! [`io::Result`]: type.Result.html + //! [`try!`]: ../macro.try.html + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use rustc_unicode::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::iter::{Iterator}; ++use core::marker::Sized; ++#[cfg(feature="collections")] use core::ops::{Drop, FnOnce}; ++use core::option::Option::{self, Some, None}; ++use core::result::Result::{Ok, Err}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "libstd_io_internals", issue = "0")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + + const DEFAULT_BUF_SIZE: usize = 8 * 1024; + +@@ -309,6 +299,7 @@ const DEFAULT_BUF_SIZE: usize = 8 * 1024; + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -340,6 +331,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every + // time is 4,500 times (!) slower than this if the reader has a very small + // amount of data to return. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut len = start_len; +@@ -422,7 +414,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -472,7 +463,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Read all bytes until EOF in this source, placing them into `buf`. +@@ -514,7 +504,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -552,7 +542,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -613,7 +603,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -665,7 +654,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -695,7 +683,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -732,10 +719,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -770,7 +753,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -804,7 +786,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } +@@ -840,7 +821,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -880,7 +860,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -906,7 +885,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -933,7 +911,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -985,7 +962,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1041,7 +1017,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1071,7 +1046,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1087,7 +1061,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1097,29 +1070,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1199,7 +1169,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1244,7 +1214,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1266,7 +1235,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf()`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1308,7 +1276,6 @@ pub trait BufRead: Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1355,7 +1322,6 @@ pub trait BufRead: Read { + /// buffer.clear(); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1392,7 +1358,6 @@ pub trait BufRead: Read { + /// println!("{:?}", content.unwrap()); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1420,7 +1385,6 @@ pub trait BufRead: Read { + /// println!("{}", line.unwrap()); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1432,14 +1396,12 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain()`] for more details. + /// + /// [`chain()`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, + done_first: bool, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1452,7 +1414,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1479,7 +1441,6 @@ impl BufRead for Chain { + /// Please see the documentation of `take()` for more details. + /// + /// [take]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Take { + inner: T, + limit: u64, +@@ -1511,7 +1472,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Consumes the `Take`, returning the wrapped reader. +@@ -1536,13 +1496,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io_take_into_inner", issue = "23755")] + pub fn into_inner(self) -> T { + self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1557,7 +1515,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1596,12 +1554,10 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes()`] for more details. + /// + /// [`bytes()`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1616,8 +1572,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub struct Chars { + inner: R, + } +@@ -1625,8 +1579,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1636,8 +1588,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1669,25 +1619,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -1706,13 +1637,13 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -1737,12 +1668,12 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 2c68802..93bcfc3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,7 +10,8 @@ + + #![allow(missing_copy_implementations)] + +-use io::{self, Read, Write, ErrorKind, BufRead}; ++use io::{self, Read, Write, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -42,7 +43,6 @@ use io::{self, Read, Write, ErrorKind, BufRead}; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -66,7 +66,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -84,14 +83,12 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Empty { + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } + fn consume(&mut self, _n: usize) {} +@@ -103,7 +100,6 @@ impl BufRead for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -120,10 +116,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + for slot in &mut *buf { +@@ -139,7 +133,6 @@ impl Read for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -156,10 +149,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/patches/67aaddddd6195f7283a94b472b2f14cbed9d95fc.patch b/patches/67aaddddd6195f7283a94b472b2f14cbed9d95fc.patch new file mode 100644 index 0000000..0a34305 --- /dev/null +++ b/patches/67aaddddd6195f7283a94b472b2f14cbed9d95fc.patch @@ -0,0 +1,1477 @@ +diff --git a/buffered.rs b/buffered.rs +index 44dd4e9..20ab840 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + BufReader { + inner: inner, +@@ -118,7 +115,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -139,7 +135,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -160,11 +155,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -182,7 +175,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -199,7 +191,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -209,7 +200,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -302,7 +292,6 @@ impl Seek for BufReader { + /// [`Write`]: ../../std/io/trait.Write.html + /// [`write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -337,7 +326,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -351,7 +339,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -369,7 +356,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -418,7 +404,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -436,7 +421,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -454,7 +438,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -463,7 +446,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -483,7 +465,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -493,7 +474,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -503,7 +483,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -542,7 +521,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -575,23 +553,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -646,7 +614,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + } +@@ -666,7 +633,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -687,7 +653,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { inner: BufWriter::with_capacity(cap, inner) } + } +@@ -708,7 +673,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -731,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -753,7 +716,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { inner: buf }, e) +@@ -761,7 +723,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + match memchr::memrchr(b'\n', buf) { +@@ -780,7 +741,6 @@ impl Write for LineWriter { + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index ae0085f..0f8029d 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -73,7 +74,6 @@ use io::{self, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -92,7 +92,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -110,7 +109,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -126,7 +124,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -145,7 +142,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -167,7 +163,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -187,11 +182,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let pos = match style { +@@ -210,25 +203,27 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature = "collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -240,7 +235,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -270,8 +265,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index ddf0030..748b830 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,10 +8,15 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -43,7 +48,6 @@ use sys; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -55,20 +59,22 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + + enum Repr { + Os(i32), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -80,47 +86,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -130,10 +123,8 @@ pub enum ErrorKind { + /// + /// For example, a function that reads a file into a string will error with + /// `InvalidData` if the file's contents are not valid UTF-8. +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to `write` returned `Ok(0)`. +@@ -141,15 +132,12 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it wrote a + /// particular number of bytes but only a smaller number of bytes could be + /// written. +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -158,15 +146,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -190,14 +173,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -206,24 +188,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -249,7 +213,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -280,7 +243,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -313,11 +275,10 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -383,11 +344,10 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -416,8 +376,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Custom(c) => Some(c.error) +@@ -442,10 +401,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + } + } +@@ -455,63 +413,23 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) => match self.kind() { +- ErrorKind::NotFound => "entity not found", +- ErrorKind::PermissionDenied => "permission denied", +- ErrorKind::ConnectionRefused => "connection refused", +- ErrorKind::ConnectionReset => "connection reset", +- ErrorKind::ConnectionAborted => "connection aborted", +- ErrorKind::NotConnected => "not connected", +- ErrorKind::AddrInUse => "address in use", +- ErrorKind::AddrNotAvailable => "address not available", +- ErrorKind::BrokenPipe => "broken pipe", +- ErrorKind::AlreadyExists => "entity already exists", +- ErrorKind::WouldBlock => "operation would block", +- ErrorKind::InvalidInput => "invalid input parameter", +- ErrorKind::InvalidData => "invalid data", +- ErrorKind::TimedOut => "timed out", +- ErrorKind::WriteZero => "write zero", +- ErrorKind::Interrupted => "operation interrupted", +- ErrorKind::Other => "other os error", +- ErrorKind::UnexpectedEof => "unexpected end of file", +- ErrorKind::__Nonexhaustive => unreachable!() +- }, +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index cd05e6b..d048379 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,26 +8,31 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -38,7 +43,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -56,12 +60,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -80,18 +83,20 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -102,7 +107,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -120,12 +125,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -147,7 +152,6 @@ impl BufRead for Box { + // ============================================================================= + // In-memory buffer implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -171,7 +175,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -180,7 +184,6 @@ impl<'a> BufRead for &'a [u8] { + fn consume(&mut self, amt: usize) { *self = &self[amt..]; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -204,7 +207,7 @@ impl<'a> Write for &'a mut [u8] { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 14d046a..e71dca0 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -252,42 +252,32 @@ + //! [`io::Result`]: type.Result.html + //! [`try!`]: ../macro.try.html + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use rustc_unicode::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::iter::{Iterator}; ++use core::marker::Sized; ++#[cfg(feature="collections")] use core::ops::{Drop, FnOnce}; ++use core::option::Option::{self, Some, None}; ++use core::result::Result::{Ok, Err}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "libstd_io_internals", issue = "0")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + + const DEFAULT_BUF_SIZE: usize = 8 * 1024; + +@@ -309,6 +299,7 @@ const DEFAULT_BUF_SIZE: usize = 8 * 1024; + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -340,6 +331,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every + // time is 4,500 times (!) slower than this if the reader has a very small + // amount of data to return. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut len = start_len; +@@ -422,7 +414,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -472,7 +463,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Read all bytes until EOF in this source, placing them into `buf`. +@@ -514,7 +504,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -552,7 +542,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -613,7 +603,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -665,7 +654,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -695,7 +683,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -732,10 +719,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -770,7 +753,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -804,7 +786,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } +@@ -840,7 +821,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -880,7 +860,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -906,7 +885,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -933,7 +911,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -985,7 +962,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1041,7 +1017,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1071,7 +1046,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1087,7 +1061,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1097,29 +1070,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1199,7 +1169,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1244,7 +1214,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1266,7 +1235,6 @@ pub trait BufRead: Read { + /// + /// Since `consume()` is meant to be used with [`fill_buf()`][fillbuf], + /// that method's example includes an example of `consume()`. +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1305,7 +1273,6 @@ pub trait BufRead: Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1351,7 +1318,6 @@ pub trait BufRead: Read { + /// buffer.clear(); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1384,7 +1350,6 @@ pub trait BufRead: Read { + /// println!("{:?}", content.unwrap()); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1409,7 +1374,6 @@ pub trait BufRead: Read { + /// println!("{}", line.unwrap()); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1421,14 +1385,12 @@ pub trait BufRead: Read { + /// Please see the documentation of `chain()` for more details. + /// + /// [chain]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, + done_first: bool, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1441,7 +1403,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1468,7 +1430,6 @@ impl BufRead for Chain { + /// Please see the documentation of `take()` for more details. + /// + /// [take]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Take { + inner: T, + limit: u64, +@@ -1500,7 +1461,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Consumes the `Take`, returning the wrapped reader. +@@ -1525,13 +1485,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io_take_into_inner", issue = "23755")] + pub fn into_inner(self) -> T { + self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1546,7 +1504,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1585,12 +1543,10 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of `bytes()` for more details. + /// + /// [bytes]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1605,8 +1561,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub struct Chars { + inner: R, + } +@@ -1614,8 +1568,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1625,8 +1577,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1658,25 +1608,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -1695,13 +1626,13 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -1726,12 +1657,12 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 2c68802..93bcfc3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,7 +10,8 @@ + + #![allow(missing_copy_implementations)] + +-use io::{self, Read, Write, ErrorKind, BufRead}; ++use io::{self, Read, Write, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -42,7 +43,6 @@ use io::{self, Read, Write, ErrorKind, BufRead}; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -66,7 +66,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -84,14 +83,12 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Empty { + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } + fn consume(&mut self, _n: usize) {} +@@ -103,7 +100,6 @@ impl BufRead for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -120,10 +116,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + for slot in &mut *buf { +@@ -139,7 +133,6 @@ impl Read for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -156,10 +149,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/patches/8f10d6652ac212a7e30cb64017914ea1d5687767.patch b/patches/8f10d6652ac212a7e30cb64017914ea1d5687767.patch new file mode 100644 index 0000000..dc6fd62 --- /dev/null +++ b/patches/8f10d6652ac212a7e30cb64017914ea1d5687767.patch @@ -0,0 +1,1477 @@ +diff --git a/buffered.rs b/buffered.rs +index 39b64e7..47282c9 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -42,7 +42,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -65,7 +64,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -86,7 +84,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + BufReader { + inner: inner, +@@ -114,7 +111,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -135,7 +131,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -156,11 +151,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -178,7 +171,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -195,7 +187,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -205,7 +196,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -294,7 +284,6 @@ impl Seek for BufReader { + /// By wrapping the stream with a `BufWriter`, these ten writes are all grouped + /// together by the buffer, and will all be written out in one system call when + /// the `stream` is dropped. +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -329,7 +318,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -343,7 +331,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -361,7 +348,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -410,7 +396,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -428,7 +413,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -446,7 +430,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -455,7 +438,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -475,7 +457,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -485,7 +466,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -495,7 +475,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -534,7 +513,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -567,23 +545,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -638,7 +606,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + } +@@ -658,7 +625,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -679,7 +645,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { inner: BufWriter::with_capacity(cap, inner) } + } +@@ -700,7 +665,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -723,7 +687,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -745,7 +708,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { inner: buf }, e) +@@ -753,7 +715,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + match memchr::memrchr(b'\n', buf) { +@@ -772,7 +733,6 @@ impl Write for LineWriter { + fn flush(&mut self) -> io::Result<()> { self.inner.flush() } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index ae0085f..0f8029d 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -73,7 +74,6 @@ use io::{self, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -92,7 +92,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -110,7 +109,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -126,7 +124,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -145,7 +142,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -167,7 +163,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -187,11 +182,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let pos = match style { +@@ -210,25 +203,27 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature = "collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -240,7 +235,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -270,8 +265,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index ddf0030..748b830 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,10 +8,15 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -43,7 +48,6 @@ use sys; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -55,20 +59,22 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + + enum Repr { + Os(i32), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -80,47 +86,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -130,10 +123,8 @@ pub enum ErrorKind { + /// + /// For example, a function that reads a file into a string will error with + /// `InvalidData` if the file's contents are not valid UTF-8. +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to `write` returned `Ok(0)`. +@@ -141,15 +132,12 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it wrote a + /// particular number of bytes but only a smaller number of bytes could be + /// written. +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -158,15 +146,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -190,14 +173,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -206,24 +188,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -249,7 +213,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -280,7 +243,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -313,11 +275,10 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -383,11 +344,10 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -416,8 +376,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Custom(c) => Some(c.error) +@@ -442,10 +401,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + } + } +@@ -455,63 +413,23 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) => match self.kind() { +- ErrorKind::NotFound => "entity not found", +- ErrorKind::PermissionDenied => "permission denied", +- ErrorKind::ConnectionRefused => "connection refused", +- ErrorKind::ConnectionReset => "connection reset", +- ErrorKind::ConnectionAborted => "connection aborted", +- ErrorKind::NotConnected => "not connected", +- ErrorKind::AddrInUse => "address in use", +- ErrorKind::AddrNotAvailable => "address not available", +- ErrorKind::BrokenPipe => "broken pipe", +- ErrorKind::AlreadyExists => "entity already exists", +- ErrorKind::WouldBlock => "operation would block", +- ErrorKind::InvalidInput => "invalid input parameter", +- ErrorKind::InvalidData => "invalid data", +- ErrorKind::TimedOut => "timed out", +- ErrorKind::WriteZero => "write zero", +- ErrorKind::Interrupted => "operation interrupted", +- ErrorKind::Other => "other os error", +- ErrorKind::UnexpectedEof => "unexpected end of file", +- ErrorKind::__Nonexhaustive => unreachable!() +- }, +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index cd05e6b..d048379 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,26 +8,31 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -38,7 +43,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -56,12 +60,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -80,18 +83,20 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -102,7 +107,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -120,12 +125,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -147,7 +152,6 @@ impl BufRead for Box { + // ============================================================================= + // In-memory buffer implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -171,7 +175,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -180,7 +184,6 @@ impl<'a> BufRead for &'a [u8] { + fn consume(&mut self, amt: usize) { *self = &self[amt..]; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -204,7 +207,7 @@ impl<'a> Write for &'a mut [u8] { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 14d046a..e71dca0 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -252,42 +252,32 @@ + //! [`io::Result`]: type.Result.html + //! [`try!`]: ../macro.try.html + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use rustc_unicode::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::iter::{Iterator}; ++use core::marker::Sized; ++#[cfg(feature="collections")] use core::ops::{Drop, FnOnce}; ++use core::option::Option::{self, Some, None}; ++use core::result::Result::{Ok, Err}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "libstd_io_internals", issue = "0")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + + const DEFAULT_BUF_SIZE: usize = 8 * 1024; + +@@ -309,6 +299,7 @@ const DEFAULT_BUF_SIZE: usize = 8 * 1024; + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -340,6 +331,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every + // time is 4,500 times (!) slower than this if the reader has a very small + // amount of data to return. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut len = start_len; +@@ -422,7 +414,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -472,7 +463,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Read all bytes until EOF in this source, placing them into `buf`. +@@ -514,7 +504,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -552,7 +542,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -613,7 +603,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -665,7 +654,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -695,7 +683,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -732,10 +719,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -770,7 +753,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -804,7 +786,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } +@@ -840,7 +821,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -880,7 +860,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -906,7 +885,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -933,7 +911,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -985,7 +962,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1041,7 +1017,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1071,7 +1046,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1087,7 +1061,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1097,29 +1070,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1199,7 +1169,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1244,7 +1214,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1266,7 +1235,6 @@ pub trait BufRead: Read { + /// + /// Since `consume()` is meant to be used with [`fill_buf()`][fillbuf], + /// that method's example includes an example of `consume()`. +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1305,7 +1273,6 @@ pub trait BufRead: Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1351,7 +1318,6 @@ pub trait BufRead: Read { + /// buffer.clear(); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1384,7 +1350,6 @@ pub trait BufRead: Read { + /// println!("{:?}", content.unwrap()); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1409,7 +1374,6 @@ pub trait BufRead: Read { + /// println!("{}", line.unwrap()); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1421,14 +1385,12 @@ pub trait BufRead: Read { + /// Please see the documentation of `chain()` for more details. + /// + /// [chain]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, + done_first: bool, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1441,7 +1403,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1468,7 +1430,6 @@ impl BufRead for Chain { + /// Please see the documentation of `take()` for more details. + /// + /// [take]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Take { + inner: T, + limit: u64, +@@ -1500,7 +1461,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Consumes the `Take`, returning the wrapped reader. +@@ -1525,13 +1485,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io_take_into_inner", issue = "23755")] + pub fn into_inner(self) -> T { + self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1546,7 +1504,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1585,12 +1543,10 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of `bytes()` for more details. + /// + /// [bytes]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1605,8 +1561,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub struct Chars { + inner: R, + } +@@ -1614,8 +1568,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1625,8 +1577,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1658,25 +1608,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -1695,13 +1626,13 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -1726,12 +1657,12 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 2c68802..93bcfc3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,7 +10,8 @@ + + #![allow(missing_copy_implementations)] + +-use io::{self, Read, Write, ErrorKind, BufRead}; ++use io::{self, Read, Write, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -42,7 +43,6 @@ use io::{self, Read, Write, ErrorKind, BufRead}; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -66,7 +66,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -84,14 +83,12 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Empty { + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } + fn consume(&mut self, _n: usize) {} +@@ -103,7 +100,6 @@ impl BufRead for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -120,10 +116,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + for slot in &mut *buf { +@@ -139,7 +133,6 @@ impl Read for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -156,10 +149,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } + fn flush(&mut self) -> io::Result<()> { Ok(()) }