Browse Source

Update for 2018-11-07

Jeremy Soller 6 years ago
parent
commit
eb72048307

+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "core_io"
-version = "0.1.20180619"
+version = "0.1.20181107"
 authors = ["The Rust Project Developers", "Jethro Beekman"]
 license = "MIT/Apache-2.0"
 description = """

+ 1 - 0
mapping.rs

@@ -590,3 +590,4 @@
 -Mapping("d6d711dd8f7ad5885294b8e1f0009a23dc1f8b1f","d52acbe37f69a2ebc9d161c479ed628da1cbea4e")
 -Mapping("8503b3ff822c1ed01c89773d30e4e10b886d77a5","02c1862fb55c6ae4198038b1b317bcdd06e395d1")
 -Mapping("5230979794db209de492b3f7cc688020b72bc7c6","b81da278623d9dcda1776008612bd42e1922e9c3")
+-Mapping("15d770400eed9018f18bddf83dd65cb7789280a5","b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d")

+ 1612 - 0
patches/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d.patch

@@ -0,0 +1,1612 @@
+diff --git a/buffered.rs b/buffered.rs
+index e26e6d3..c754cf1 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, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom};
+-use memchr;
++use io::memchr;
+ 
+ /// The `BufReader` struct adds buffering to any reader.
+ ///
+@@ -52,7 +52,6 @@ use memchr;
+ ///     Ok(())
+ /// }
+ /// ```
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub struct BufReader<R> {
+     inner: R,
+     buf: Box<[u8]>,
+@@ -76,7 +75,6 @@ impl<R: Read> BufReader<R> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn new(inner: R) -> BufReader<R> {
+         BufReader::with_capacity(DEFAULT_BUF_SIZE, inner)
+     }
+@@ -97,7 +95,6 @@ impl<R: Read> BufReader<R> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
+         unsafe {
+             let mut buffer = Vec::with_capacity(cap);
+@@ -130,7 +127,6 @@ impl<R: Read> BufReader<R> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn get_ref(&self) -> &R { &self.inner }
+ 
+     /// Gets a mutable reference to the underlying reader.
+@@ -151,7 +147,6 @@ impl<R: Read> BufReader<R> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn get_mut(&mut self) -> &mut R { &mut self.inner }
+ 
+     /// Returns a reference to the internally buffered data.
+@@ -176,7 +171,6 @@ impl<R: Read> BufReader<R> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[unstable(feature = "bufreader_buffer", issue = "45323")]
+     pub fn buffer(&self) -> &[u8] {
+         &self.buf[self.pos..self.cap]
+     }
+@@ -199,7 +193,6 @@ impl<R: Read> BufReader<R> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn into_inner(self) -> R { self.inner }
+ }
+ 
+@@ -208,7 +201,6 @@ impl<R: Seek> BufReader<R> {
+     /// the buffer will not be flushed, allowing for more efficient seeks.
+     /// This method does not return the location of the underlying reader, so the caller
+     /// must track this information themselves if it is required.
+-    #[unstable(feature = "bufreader_seek_relative", issue = "31100")]
+     pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> {
+         let pos = self.pos as u64;
+         if offset < 0 {
+@@ -228,7 +220,6 @@ impl<R: Seek> BufReader<R> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<R: Read> Read for BufReader<R> {
+     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+         // If we don't have any buffered data and we're doing a massive read
+@@ -251,7 +242,6 @@ impl<R: Read> Read for BufReader<R> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<R: Read> BufRead for BufReader<R> {
+     fn fill_buf(&mut self) -> io::Result<&[u8]> {
+         // If we've reached the end of our internal buffer then we need to fetch
+@@ -271,7 +261,6 @@ impl<R: Read> BufRead for BufReader<R> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
+     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+         fmt.debug_struct("BufReader")
+@@ -281,7 +270,6 @@ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<R: Seek> Seek for BufReader<R> {
+     /// Seek to an offset, in bytes, in the underlying reader.
+     ///
+@@ -387,7 +375,6 @@ impl<R: Seek> Seek for BufReader<R> {
+ /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write
+ /// [`TcpStream`]: ../../std/net/struct.TcpStream.html
+ /// [`flush`]: #method.flush
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub struct BufWriter<W: Write> {
+     inner: Option<W>,
+     buf: Vec<u8>,
+@@ -422,7 +409,6 @@ pub struct BufWriter<W: Write> {
+ /// };
+ /// ```
+ #[derive(Debug)]
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub struct IntoInnerError<W>(W, Error);
+ 
+ impl<W: Write> BufWriter<W> {
+@@ -437,7 +423,6 @@ impl<W: Write> BufWriter<W> {
+     ///
+     /// 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<W> {
+         BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner)
+     }
+@@ -455,7 +440,6 @@ impl<W: Write> BufWriter<W> {
+     /// 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<W> {
+         BufWriter {
+             inner: Some(inner),
+@@ -504,7 +488,6 @@ impl<W: Write> BufWriter<W> {
+     /// // 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.
+@@ -522,7 +505,6 @@ impl<W: Write> BufWriter<W> {
+     /// // 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.
+@@ -544,7 +526,6 @@ impl<W: Write> BufWriter<W> {
+     /// // 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<W, IntoInnerError<BufWriter<W>>> {
+         match self.flush_buf() {
+             Err(e) => Err(IntoInnerError(self, e)),
+@@ -553,7 +534,6 @@ impl<W: Write> BufWriter<W> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W: Write> Write for BufWriter<W> {
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+         if self.buf.len() + buf.len() > self.buf.capacity() {
+@@ -573,7 +553,6 @@ impl<W: Write> Write for BufWriter<W> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug {
+     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+         fmt.debug_struct("BufWriter")
+@@ -583,7 +562,6 @@ impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W: Write + Seek> Seek for BufWriter<W> {
+     /// Seek to the offset, in bytes, in the underlying writer.
+     ///
+@@ -593,7 +571,6 @@ impl<W: Write + Seek> Seek for BufWriter<W> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W: Write> Drop for BufWriter<W> {
+     fn drop(&mut self) {
+         if self.inner.is_some() && !self.panicked {
+@@ -632,7 +609,6 @@ impl<W> IntoInnerError<W> {
+     ///     }
+     /// };
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn error(&self) -> &Error { &self.1 }
+ 
+     /// Returns the buffered writer instance which generated the error.
+@@ -665,23 +641,13 @@ impl<W> IntoInnerError<W> {
+     ///     }
+     /// };
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn into_inner(self) -> W { self.0 }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W> From<IntoInnerError<W>> for Error {
+     fn from(iie: IntoInnerError<W>) -> Error { iie.1 }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+-impl<W: Send + fmt::Debug> error::Error for IntoInnerError<W> {
+-    fn description(&self) -> &str {
+-        error::Error::description(self.error())
+-    }
+-}
+-
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W> fmt::Display for IntoInnerError<W> {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         self.error().fmt(f)
+@@ -752,7 +718,6 @@ impl<W> fmt::Display for IntoInnerError<W> {
+ ///     Ok(())
+ /// }
+ /// ```
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub struct LineWriter<W: Write> {
+     inner: BufWriter<W>,
+     need_flush: bool,
+@@ -773,7 +738,6 @@ impl<W: Write> LineWriter<W> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn new(inner: W) -> LineWriter<W> {
+         // Lines typically aren't that long, don't use a giant buffer
+         LineWriter::with_capacity(1024, inner)
+@@ -794,7 +758,6 @@ impl<W: Write> LineWriter<W> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn with_capacity(cap: usize, inner: W) -> LineWriter<W> {
+         LineWriter {
+             inner: BufWriter::with_capacity(cap, inner),
+@@ -818,7 +781,6 @@ impl<W: Write> LineWriter<W> {
+     ///     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.
+@@ -841,7 +803,6 @@ impl<W: Write> LineWriter<W> {
+     ///     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.
+@@ -867,7 +828,6 @@ impl<W: Write> LineWriter<W> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> {
+         self.inner.into_inner().map_err(|IntoInnerError(buf, e)| {
+             IntoInnerError(LineWriter {
+@@ -878,7 +838,6 @@ impl<W: Write> LineWriter<W> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W: Write> Write for LineWriter<W> {
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+         if self.need_flush {
+@@ -923,7 +882,6 @@ impl<W: Write> Write for LineWriter<W> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<W: Write> fmt::Debug for LineWriter<W> 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 14f2015..151c4b8 100644
+--- a/cursor.rs
++++ b/cursor.rs
+@@ -10,8 +10,9 @@
+ 
+ use io::prelude::*;
+ 
++#[cfg(feature="alloc")]
+ use core::convert::TryInto;
+-use cmp;
++use core::cmp;
+ use io::{self, Initializer, SeekFrom, Error, ErrorKind};
+ 
+ /// A `Cursor` wraps an in-memory buffer and provides it with a
+@@ -80,7 +81,6 @@ use io::{self, Initializer, 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<T> {
+     inner: T,
+@@ -103,7 +103,6 @@ impl<T> Cursor<T> {
+     /// # fn force_inference(_: &Cursor<Vec<u8>>) {}
+     /// # force_inference(&buff);
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn new(inner: T) -> Cursor<T> {
+         Cursor { pos: 0, inner: inner }
+     }
+@@ -121,7 +120,6 @@ impl<T> Cursor<T> {
+     ///
+     /// 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.
+@@ -137,7 +135,6 @@ impl<T> Cursor<T> {
+     ///
+     /// 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.
+@@ -156,7 +153,6 @@ impl<T> Cursor<T> {
+     ///
+     /// 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.
+@@ -178,7 +174,6 @@ impl<T> Cursor<T> {
+     /// 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.
+@@ -198,11 +193,9 @@ impl<T> Cursor<T> {
+     /// 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<T> io::Seek for Cursor<T> where T: AsRef<[u8]> {
+     fn seek(&mut self, style: SeekFrom) -> io::Result<u64> {
+         let (base_pos, offset) = match style {
+@@ -223,17 +216,16 @@ impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<T> Read for Cursor<T> where T: AsRef<[u8]> {
+     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+-        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)
+     }
+ 
+     fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
+         let n = buf.len();
+-        Read::read_exact(&mut self.fill_buf()?, buf)?;
++        Read::read_exact(&mut self.get_buf()?, buf)?;
+         self.pos += n as u64;
+         Ok(())
+     }
+@@ -244,12 +236,16 @@ impl<T> Read for Cursor<T> where T: AsRef<[u8]> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+-impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> {
+-    fn fill_buf(&mut self) -> io::Result<&[u8]> {
++impl<T> Cursor<T> 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="alloc")]
++impl<T> BufRead for Cursor<T> 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; }
+ }
+ 
+@@ -262,6 +258,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result<us
+ }
+ 
+ // Resizing write implementation
++#[cfg(feature="alloc")]
+ fn vec_write(pos_mut: &mut u64, vec: &mut Vec<u8>, buf: &[u8]) -> io::Result<usize> {
+     let pos: usize = (*pos_mut).try_into().map_err(|_| {
+         Error::new(ErrorKind::InvalidInput,
+@@ -288,7 +285,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec<u8>, buf: &[u8]) -> io::Result<usi
+     Ok(buf.len())
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a> Write for Cursor<&'a mut [u8]> {
+     #[inline]
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+@@ -297,7 +293,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> {
+     fn flush(&mut self) -> io::Result<()> { Ok(()) }
+ }
+ 
+-#[stable(feature = "cursor_mut_vec", since = "1.25.0")]
++#[cfg(feature="alloc")]
+ impl<'a> Write for Cursor<&'a mut Vec<u8>> {
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+         vec_write(&mut self.pos, self.inner, buf)
+@@ -305,7 +301,7 @@ impl<'a> Write for Cursor<&'a mut Vec<u8>> {
+     fn flush(&mut self) -> io::Result<()> { Ok(()) }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl Write for Cursor<Vec<u8>> {
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+         vec_write(&mut self.pos, &mut self.inner, buf)
+@@ -313,8 +309,8 @@ impl Write for Cursor<Vec<u8>> {
+     fn flush(&mut self) -> io::Result<()> { Ok(()) }
+ }
+ 
+-#[stable(feature = "cursor_box_slice", since = "1.5.0")]
+-impl Write for Cursor<Box<[u8]>> {
++#[cfg(feature="alloc")]
++impl Write for Cursor<::alloc::boxed::Box<[u8]>> {
+     #[inline]
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+         slice_write(&mut self.pos, &mut self.inner, buf)
+diff --git a/error.rs b/error.rs
+index 386de08..9511d1f 100644
+--- a/error.rs
++++ b/error.rs
+@@ -8,11 +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;
+-use convert::From;
++#[cfg(feature="alloc")] use alloc::boxed::Box;
++#[cfg(not(feature="alloc"))] use ::FakeBox as Box;
++use core::fmt;
++use core::marker::{Send, Sync};
++use core::option::Option::{self, Some, None};
++use core::result;
++#[cfg(feature="alloc")] use alloc::string::String;
++#[cfg(not(feature="alloc"))] use ::ErrorString as String;
++use core::convert::From;
+ 
+ /// A specialized [`Result`](../result/enum.Result.html) type for I/O
+ /// operations.
+@@ -48,7 +52,6 @@ use convert::From;
+ ///     Ok(buffer)
+ /// }
+ /// ```
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub type Result<T> = result::Result<T, Error>;
+ 
+ /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and
+@@ -62,12 +65,10 @@ pub type Result<T> = result::Result<T, Error>;
+ /// [`Write`]: ../io/trait.Write.html
+ /// [`Seek`]: ../io/trait.Seek.html
+ /// [`ErrorKind`]: enum.ErrorKind.html
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub struct Error {
+     repr: Repr,
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl fmt::Debug for Error {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         fmt::Debug::fmt(&self.repr, f)
+@@ -77,13 +78,16 @@ impl fmt::Debug for Error {
+ enum Repr {
+     Os(i32),
+     Simple(ErrorKind),
++    #[cfg(feature = "alloc")]
+     Custom(Box<Custom>),
++    #[cfg(not(feature = "alloc"))]
++    Custom(Custom),
+ }
+ 
+ #[derive(Debug)]
+ struct Custom {
+     kind: ErrorKind,
+-    error: Box<dyn error::Error+Send+Sync>,
++    error: String,
+ }
+ 
+ /// A list specifying general categories of I/O error.
+@@ -95,48 +99,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)]
+-#[non_exhaustive]
+ 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.
+     ///
+@@ -148,10 +138,8 @@ pub enum ErrorKind {
+     /// `InvalidData` if the file's contents are not valid UTF-8.
+     ///
+     /// [`InvalidInput`]: #variant.InvalidInput
+-    #[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)`].
+@@ -162,15 +150,12 @@ pub enum ErrorKind {
+     ///
+     /// [`write`]: ../../std/io/trait.Write.html#tymethod.write
+     /// [`Ok(0)`]: ../../std/io/type.Result.html
+-    #[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
+@@ -179,8 +164,12 @@ 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.
++    #[doc(hidden)]
++    __Nonexhaustive,
+ }
+ 
+ impl ErrorKind {
+@@ -204,13 +193,13 @@ impl ErrorKind {
+             ErrorKind::Interrupted => "operation interrupted",
+             ErrorKind::Other => "other os error",
+             ErrorKind::UnexpectedEof => "unexpected end of file",
++            _ => "unknown error",
+         }
+     }
+ }
+ 
+ /// Intended for use for errors not exposed to the user, where allocating onto
+ /// the heap (for normal construction via Error::new) is too costly.
+-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
+ impl From<ErrorKind> for Error {
+     /// Converts an [`ErrorKind`] into an [`Error`].
+     ///
+@@ -252,14 +241,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<E>(kind: ErrorKind, error: E) -> Error
+-        where E: Into<Box<dyn error::Error+Send+Sync>>
++        where E: Into<String>
+     {
+         Self::_new(kind, error.into())
+     }
+ 
+-    fn _new(kind: ErrorKind, error: Box<dyn error::Error+Send+Sync>) -> Error {
++    fn _new(kind: ErrorKind, error: String) -> Error {
+         Error {
+             repr: Repr::Custom(Box::new(Custom {
+                 kind,
+@@ -268,24 +256,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
+@@ -311,7 +281,6 @@ impl Error {
+     /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput);
+     /// # }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn from_raw_os_error(code: i32) -> Error {
+         Error { repr: Repr::Os(code) }
+     }
+@@ -342,7 +311,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<i32> {
+         match self.repr {
+             Repr::Os(i) => Some(i),
+@@ -376,12 +344,11 @@ 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<&(dyn error::Error+Send+Sync+'static)> {
++    pub fn get_ref(&self) -> Option<&String> {
+         match self.repr {
+             Repr::Os(..) => None,
+             Repr::Simple(..) => None,
+-            Repr::Custom(ref c) => Some(&*c.error),
++            Repr::Custom(ref c) => Some(&c.error),
+         }
+     }
+ 
+@@ -447,12 +414,11 @@ 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 (dyn error::Error+Send+Sync+'static)> {
++    pub fn get_mut(&mut self) -> Option<&mut String> {
+         match self.repr {
+             Repr::Os(..) => None,
+             Repr::Simple(..) => None,
+-            Repr::Custom(ref mut c) => Some(&mut *c.error),
++            Repr::Custom(ref mut c) => Some(&mut c.error),
+         }
+     }
+ 
+@@ -481,8 +447,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<Box<dyn error::Error+Send+Sync>> {
++    pub fn into_inner(self) -> Option<String> {
+         match self.repr {
+             Repr::Os(..) => None,
+             Repr::Simple(..) => None,
+@@ -508,10 +473,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,
+             Repr::Simple(kind) => kind,
+         }
+@@ -523,22 +487,18 @@ impl fmt::Debug for Repr {
+         match *self {
+             Repr::Os(code) =>
+                 fmt.debug_struct("Os")
+-                    .field("code", &code)
+-                    .field("kind", &sys::decode_error_kind(code))
+-                    .field("message", &sys::os::error_string(code)).finish(),
++                    .field("code", &code).finish(),
+             Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt),
+             Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).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),
+             Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()),
+@@ -546,24 +506,6 @@ impl fmt::Display for Error {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+-impl error::Error for Error {
+-    fn description(&self) -> &str {
+-        match self.repr {
+-            Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(),
+-            Repr::Custom(ref c) => c.error.description(),
+-        }
+-    }
+-
+-    fn cause(&self) -> Option<&dyn error::Error> {
+-        match self.repr {
+-            Repr::Os(..) => None,
+-            Repr::Simple(..) => None,
+-            Repr::Custom(ref c) => c.error.cause(),
+-        }
+-    }
+-}
+-
+ fn _assert_error_is_sync_send() {
+     fn _is_sync_send<T: Sync+Send>() {}
+     _is_sync_send::<Error>();
+diff --git a/impls.rs b/impls.rs
+index fe1179a..04ede23 100644
+--- a/impls.rs
++++ b/impls.rs
+@@ -8,15 +8,18 @@
+ // option. This file may not be copied, modified, or distributed
+ // except according to those terms.
+ 
+-use cmp;
+-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind};
+-use fmt;
+-use mem;
++#[cfg(feature="alloc")] use alloc::boxed::Box;
++use core::cmp;
++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind};
++#[cfg(feature="alloc")] use io::BufRead;
++use core::fmt;
++use core::mem;
++#[cfg(feature="alloc")] use alloc::string::String;
++#[cfg(feature="alloc")] use alloc::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<usize> {
+@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R {
+         (**self).initializer()
+     }
+ 
++    #[cfg(feature="alloc")]
+     #[inline]
+     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+         (**self).read_to_end(buf)
+     }
+ 
++    #[cfg(feature="alloc")]
+     #[inline]
+     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+         (**self).read_to_string(buf)
+@@ -43,7 +48,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<usize> { (**self).write(buf) }
+@@ -61,12 +65,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<u64> { (**self).seek(pos) }
+ }
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B {
+     #[inline]
+     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
+@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<R: Read + ?Sized> Read for Box<R> {
+     #[inline]
+     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+@@ -97,11 +100,13 @@ impl<R: Read + ?Sized> Read for Box<R> {
+         (**self).initializer()
+     }
+ 
++    #[cfg(feature="alloc")]
+     #[inline]
+     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+         (**self).read_to_end(buf)
+     }
+ 
++    #[cfg(feature="alloc")]
+     #[inline]
+     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
+         (**self).read_to_string(buf)
+@@ -112,7 +117,7 @@ impl<R: Read + ?Sized> Read for Box<R> {
+         (**self).read_exact(buf)
+     }
+ }
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<W: Write + ?Sized> Write for Box<W> {
+     #[inline]
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
+@@ -130,12 +135,12 @@ impl<W: Write + ?Sized> Write for Box<W> {
+         (**self).write_fmt(fmt)
+     }
+ }
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<S: Seek + ?Sized> Seek for Box<S> {
+     #[inline]
+     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
+ }
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<B: BufRead + ?Sized> BufRead for Box<B> {
+     #[inline]
+     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
+@@ -161,7 +166,6 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> {
+ ///
+ /// Note that reading updates the slice to point to the yet unread part.
+ /// The slice will be empty when EOF is reached.
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a> Read for &'a [u8] {
+     #[inline]
+     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] {
+         Ok(())
+     }
+ 
++    #[cfg(feature="alloc")]
+     #[inline]
+     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
+         buf.extend_from_slice(*self);
+@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<'a> BufRead for &'a [u8] {
+     #[inline]
+     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) }
+@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] {
+ ///
+ /// Note that writing updates the slice to point to the yet unwritten part.
+ /// The slice will be empty when it has been completely overwritten.
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<'a> Write for &'a mut [u8] {
+     #[inline]
+     fn write(&mut self, data: &[u8]) -> io::Result<usize> {
+@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] {
+ 
+ /// Write is implemented for `Vec<u8>` by appending to the vector.
+ /// The vector will grow as needed.
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl Write for Vec<u8> {
+     #[inline]
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+diff --git a/mod.rs b/mod.rs
+index e263db2..565470d 100644
+--- a/mod.rs
++++ b/mod.rs
+@@ -267,47 +267,39 @@
+ //! [`Result`]: ../result/enum.Result.html
+ //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
+ 
+-#![stable(feature = "rust1", since = "1.0.0")]
+-
+-use cmp;
+-use fmt;
+-use str;
+-use memchr;
+-use ptr;
+-
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
++use alloc::string::String;
++#[cfg(feature="alloc")]
++use alloc::vec::Vec;
++use core::cmp;
++use core::fmt;
++use core::str;
++#[cfg(feature="alloc")]
++use core::slice::memchr;
++use core::ptr;
++
++#[cfg(feature="alloc")]
+ pub use self::buffered::{BufReader, BufWriter, LineWriter};
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ pub use self::buffered::IntoInnerError;
+-#[stable(feature = "rust1", since = "1.0.0")]
+ 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, Stdin, Stdout, Stderr};
+-#[stable(feature = "rust1", since = "1.0.0")]
+-pub use self::stdio::{StdoutLock, StderrLock, StdinLock};
+-#[unstable(feature = "print_internals", issue = "0")]
+-pub use self::stdio::{_print, _eprint};
+-#[unstable(feature = "libstd_io_internals", issue = "42788")]
+-#[doc(no_inline, hidden)]
+-pub use self::stdio::{set_panic, set_print};
+ 
+ pub mod prelude;
++#[cfg(feature="alloc")]
+ mod buffered;
+ mod cursor;
+ mod error;
+ mod impls;
+-mod lazy;
+ mod util;
+-mod stdio;
+ 
+-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
++const DEFAULT_BUF_SIZE: usize = 8 * 1024;
+ 
++#[cfg(feature="alloc")]
+ struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize }
+ 
++#[cfg(feature="alloc")]
+ impl<'a> Drop for Guard<'a> {
+     fn drop(&mut self) {
+         unsafe { self.buf.set_len(self.len); }
+@@ -332,6 +324,7 @@ impl<'a> Drop for Guard<'a> {
+ // 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="alloc")]
+ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
+     where F: FnOnce(&mut Vec<u8>) -> Result<usize>
+ {
+@@ -359,10 +352,12 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
+ //
+ // Because we're extending the buffer with uninitialized data for trusted
+ // readers, we need to make sure to truncate that if any of this panics.
++#[cfg(feature="alloc")]
+ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
+     read_to_end_with_reservation(r, buf, 32)
+ }
+ 
++#[cfg(feature="alloc")]
+ fn read_to_end_with_reservation<R: Read + ?Sized>(r: &mut R,
+                                                   buf: &mut Vec<u8>,
+                                                   reservation_size: usize) -> Result<usize>
+@@ -469,7 +464,6 @@ fn read_to_end_with_reservation<R: Read + ?Sized>(r: &mut R,
+ /// [`BufReader`]: struct.BufReader.html
+ /// [`&str`]: ../../std/primitive.str.html
+ /// [slice]: ../../std/primitive.slice.html
+-#[stable(feature = "rust1", since = "1.0.0")]
+ #[doc(spotlight)]
+ pub trait Read {
+     /// Pull some bytes from this source into the specified buffer, returning
+@@ -526,7 +520,6 @@ pub trait Read {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
+ 
+     /// Determines if this `Read`er can work with buffers of uninitialized
+@@ -551,7 +544,6 @@ pub trait Read {
+     ///
+     /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop
+     /// [`Initializer`]: ../../std/io/struct.Initializer.html
+-    #[unstable(feature = "read_initializer", issue = "42788")]
+     #[inline]
+     unsafe fn initializer(&self) -> Initializer {
+         Initializer::zeroing()
+@@ -604,7 +596,7 @@ pub trait Read {
+     /// file.)
+     ///
+     /// [`std::fs::read`]: ../fs/fn.read.html
+-    #[stable(feature = "rust1", since = "1.0.0")]
++    #[cfg(feature="alloc")]
+     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
+         read_to_end(self, buf)
+     }
+@@ -647,7 +639,7 @@ pub trait Read {
+     /// reading from a file.)
+     ///
+     /// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html
+-    #[stable(feature = "rust1", since = "1.0.0")]
++    #[cfg(feature="alloc")]
+     fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
+         // Note that we do *not* call `.read_to_end()` here. We are passing
+         // `&mut Vec<u8>` (the raw contents of `buf`) into the `read_to_end`
+@@ -710,7 +702,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) {
+@@ -762,7 +753,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.
+@@ -799,7 +789,6 @@ pub trait Read {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn bytes(self) -> Bytes<Self> where Self: Sized {
+         Bytes { inner: self }
+     }
+@@ -834,7 +823,6 @@ pub trait Read {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized {
+         Chain { first: self, second: next, done_first: false }
+     }
+@@ -870,20 +858,17 @@ pub trait Read {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn take(self, limit: u64) -> Take<Self> where Self: Sized {
+         Take { inner: self, limit: limit }
+     }
+ }
+ 
+ /// A type used to conditionally initialize buffers passed to `Read` methods.
+-#[unstable(feature = "read_initializer", issue = "42788")]
+ #[derive(Debug)]
+ pub struct Initializer(bool);
+ 
+ impl Initializer {
+     /// Returns a new `Initializer` which will zero out buffers.
+-    #[unstable(feature = "read_initializer", issue = "42788")]
+     #[inline]
+     pub fn zeroing() -> Initializer {
+         Initializer(true)
+@@ -897,21 +882,18 @@ impl Initializer {
+     /// read from buffers passed to `Read` methods, and that the return value of
+     /// the method accurately reflects the number of bytes that have been
+     /// written to the head of the buffer.
+-    #[unstable(feature = "read_initializer", issue = "42788")]
+     #[inline]
+     pub unsafe fn nop() -> Initializer {
+         Initializer(false)
+     }
+ 
+     /// Indicates if a buffer should be initialized.
+-    #[unstable(feature = "read_initializer", issue = "42788")]
+     #[inline]
+     pub fn should_initialize(&self) -> bool {
+         self.0
+     }
+ 
+     /// Initializes a buffer if necessary.
+-    #[unstable(feature = "read_initializer", issue = "42788")]
+     #[inline]
+     pub fn initialize(&self, buf: &mut [u8]) {
+         if self.should_initialize() {
+@@ -954,7 +936,6 @@ impl Initializer {
+ ///     Ok(())
+ /// }
+ /// ```
+-#[stable(feature = "rust1", since = "1.0.0")]
+ #[doc(spotlight)]
+ pub trait Write {
+     /// Write a buffer into this object, returning how many bytes were written.
+@@ -1003,7 +984,6 @@ pub trait Write {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn write(&mut self, buf: &[u8]) -> Result<usize>;
+ 
+     /// Flush this output stream, ensuring that all intermediately buffered
+@@ -1029,7 +1009,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.
+@@ -1062,7 +1041,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) {
+@@ -1114,7 +1092,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
+@@ -1170,7 +1147,6 @@ pub trait Write {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
+ }
+ 
+@@ -1200,7 +1176,6 @@ pub trait Write {
+ ///     Ok(())
+ /// }
+ /// ```
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub trait Seek {
+     /// Seek to an offset, in bytes, in a stream.
+     ///
+@@ -1216,7 +1191,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<u64>;
+ }
+ 
+@@ -1226,29 +1200,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="alloc")]
+ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
+                                    -> Result<usize> {
+     let mut read = 0;
+@@ -1328,7 +1299,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
+ /// }
+ /// ```
+ ///
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ pub trait BufRead: Read {
+     /// Returns the contents of the internal buffer, filling it with more data
+     /// from the inner reader if it is empty.
+@@ -1374,7 +1345,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,
+@@ -1396,7 +1366,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.
+@@ -1452,7 +1421,6 @@ pub trait BufRead: Read {
+     /// assert_eq!(num_bytes, 0);
+     /// assert_eq!(buf, b"");
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize> {
+         read_until(self, byte, buf)
+     }
+@@ -1511,7 +1479,6 @@ pub trait BufRead: Read {
+     /// assert_eq!(num_bytes, 0);
+     /// assert_eq!(buf, "");
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn read_line(&mut self, buf: &mut String) -> Result<usize> {
+         // Note that we are not calling the `.read_until` method here, but
+         // rather our hardcoded implementation. For more details as to why, see
+@@ -1552,7 +1519,6 @@ pub trait BufRead: Read {
+     /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec()));
+     /// assert_eq!(split_iter.next(), None);
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn split(self, byte: u8) -> Split<Self> where Self: Sized {
+         Split { buf: self, delim: byte }
+     }
+@@ -1591,7 +1557,6 @@ pub trait BufRead: Read {
+     /// Each line of the iterator has the same error semantics as [`BufRead::read_line`].
+     ///
+     /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     fn lines(self) -> Lines<Self> where Self: Sized {
+         Lines { buf: self }
+     }
+@@ -1603,7 +1568,6 @@ 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<T, U> {
+     first: T,
+     second: U,
+@@ -1629,7 +1593,6 @@ impl<T, U> Chain<T, U> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "more_io_inner_methods", since = "1.20.0")]
+     pub fn into_inner(self) -> (T, U) {
+         (self.first, self.second)
+     }
+@@ -1652,7 +1615,6 @@ impl<T, U> Chain<T, U> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "more_io_inner_methods", since = "1.20.0")]
+     pub fn get_ref(&self) -> (&T, &U) {
+         (&self.first, &self.second)
+     }
+@@ -1679,13 +1641,11 @@ impl<T, U> Chain<T, U> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "more_io_inner_methods", since = "1.20.0")]
+     pub fn get_mut(&mut self) -> (&mut T, &mut U) {
+         (&mut self.first, &mut self.second)
+     }
+ }
+ 
+-#[stable(feature = "std_debug", since = "1.16.0")]
+ impl<T: fmt::Debug, U: fmt::Debug> fmt::Debug for Chain<T, U> {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         f.debug_struct("Chain")
+@@ -1695,7 +1655,6 @@ impl<T: fmt::Debug, U: fmt::Debug> fmt::Debug for Chain<T, U> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<T: Read, U: Read> Read for Chain<T, U> {
+     fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
+         if !self.done_first {
+@@ -1717,7 +1676,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
+     }
+ }
+ 
+-#[stable(feature = "chain_bufread", since = "1.9.0")]
++#[cfg(feature="alloc")]
+ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
+     fn fill_buf(&mut self) -> Result<&[u8]> {
+         if !self.done_first {
+@@ -1744,7 +1703,6 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
+ /// Please see the documentation of [`take`] for more details.
+ ///
+ /// [`take`]: trait.Read.html#method.take
+-#[stable(feature = "rust1", since = "1.0.0")]
+ #[derive(Debug)]
+ pub struct Take<T> {
+     inner: T,
+@@ -1779,7 +1737,6 @@ impl<T> Take<T> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "rust1", since = "1.0.0")]
+     pub fn limit(&self) -> u64 { self.limit }
+ 
+     /// Sets the number of bytes that can be read before this instance will
+@@ -1805,7 +1762,6 @@ impl<T> Take<T> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "take_set_limit", since = "1.27.0")]
+     pub fn set_limit(&mut self, limit: u64) {
+         self.limit = limit;
+     }
+@@ -1830,7 +1786,6 @@ impl<T> Take<T> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "io_take_into_inner", since = "1.15.0")]
+     pub fn into_inner(self) -> T {
+         self.inner
+     }
+@@ -1855,7 +1810,6 @@ impl<T> Take<T> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "more_io_inner_methods", since = "1.20.0")]
+     pub fn get_ref(&self) -> &T {
+         &self.inner
+     }
+@@ -1884,13 +1838,11 @@ impl<T> Take<T> {
+     ///     Ok(())
+     /// }
+     /// ```
+-    #[stable(feature = "more_io_inner_methods", since = "1.20.0")]
+     pub fn get_mut(&mut self) -> &mut T {
+         &mut self.inner
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<T: Read> Read for Take<T> {
+     fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
+         // Don't call into inner reader at all at EOF because it may still block
+@@ -1908,6 +1860,7 @@ impl<T: Read> Read for Take<T> {
+         self.inner.initializer()
+     }
+ 
++    #[cfg(feature="alloc")]
+     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
+         let reservation_size = cmp::min(self.limit, 32) as usize;
+ 
+@@ -1915,7 +1868,7 @@ impl<T: Read> Read for Take<T> {
+     }
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<T: BufRead> BufRead for Take<T> {
+     fn fill_buf(&mut self) -> Result<&[u8]> {
+         // Don't call into inner reader at all at EOF because it may still block
+@@ -1954,13 +1907,11 @@ fn read_one_byte(reader: &mut dyn Read) -> Option<Result<u8>> {
+ /// Please see the documentation of [`bytes`] for more details.
+ ///
+ /// [`bytes`]: trait.Read.html#method.bytes
+-#[stable(feature = "rust1", since = "1.0.0")]
+ #[derive(Debug)]
+ pub struct Bytes<R> {
+     inner: R,
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+ impl<R: Read> Iterator for Bytes<R> {
+     type Item = Result<u8>;
+ 
+@@ -1976,14 +1927,14 @@ impl<R: Read> Iterator for Bytes<R> {
+ /// `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="alloc")]
+ #[derive(Debug)]
+ pub struct Split<B> {
+     buf: B,
+     delim: u8,
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<B: BufRead> Iterator for Split<B> {
+     type Item = Result<Vec<u8>>;
+ 
+@@ -2008,13 +1959,13 @@ impl<B: BufRead> Iterator for Split<B> {
+ /// `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="alloc")]
+ #[derive(Debug)]
+ pub struct Lines<B> {
+     buf: B,
+ }
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
++#[cfg(feature="alloc")]
+ impl<B: BufRead> Iterator for Lines<B> {
+     type Item = Result<String>;
+ 
+diff --git a/prelude.rs b/prelude.rs
+index 8772d0f..2ebe5f1 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="alloc")] pub use super::BufRead;
+ 
+-#[stable(feature = "rust1", since = "1.0.0")]
+-pub use super::{Read, Write, BufRead, Seek};
++#[cfg(feature="alloc")] pub use alloc::boxed::Box;
++#[cfg(feature="alloc")] pub use alloc::vec::Vec;
+diff --git a/util.rs b/util.rs
+index 371e5b2..810c6e7 100644
+--- a/util.rs
++++ b/util.rs
+@@ -10,9 +10,10 @@
+ 
+ #![allow(missing_copy_implementations)]
+ 
+-use fmt;
+-use io::{self, Read, Initializer, Write, ErrorKind, BufRead};
+-use mem;
++use core::fmt;
++use io::{self, Read, Initializer, Write, ErrorKind};
++use core::mem;
++#[cfg(feature="alloc")] use io::BufRead;
+ 
+ /// Copies the entire contents of a reader into a writer.
+ ///
+@@ -49,7 +50,6 @@ use mem;
+ ///     Ok(())
+ /// }
+ /// ```
+-#[stable(feature = "rust1", since = "1.0.0")]
+ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
+     where R: Read, W: Write
+ {
+@@ -78,7 +78,6 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
+ /// the documentation of [`empty()`][`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.
+@@ -98,10 +97,8 @@ 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 {
+     #[inline]
+     fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) }
+@@ -111,7 +108,8 @@ impl Read for Empty {
+         Initializer::nop()
+     }
+ }
+-#[stable(feature = "rust1", since = "1.0.0")]
++
++#[cfg(feature="alloc")]
+ impl BufRead for Empty {
+     #[inline]
+     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) }
+@@ -119,7 +117,6 @@ impl BufRead for Empty {
+     fn consume(&mut self, _n: usize) {}
+ }
+ 
+-#[stable(feature = "std_debug", since = "1.16.0")]
+ impl fmt::Debug for Empty {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         f.pad("Empty { .. }")
+@@ -132,7 +129,6 @@ impl fmt::Debug 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.
+@@ -149,10 +145,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 {
+     #[inline]
+     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
+@@ -168,7 +162,6 @@ impl Read for Repeat {
+     }
+ }
+ 
+-#[stable(feature = "std_debug", since = "1.16.0")]
+ impl fmt::Debug for Repeat {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         f.pad("Repeat { .. }")
+@@ -181,7 +174,6 @@ impl fmt::Debug 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.
+@@ -198,10 +190,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 {
+     #[inline]
+     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { Ok(buf.len()) }
+@@ -209,7 +199,6 @@ impl Write for Sink {
+     fn flush(&mut self) -> io::Result<()> { Ok(()) }
+ }
+ 
+-#[stable(feature = "std_debug", since = "1.16.0")]
+ impl fmt::Debug for Sink {
+     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+         f.pad("Sink { .. }")

+ 30 - 61
src/b81da278623d9dcda1776008612bd42e1922e9c3/buffered.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/buffered.rs

@@ -60,7 +60,8 @@ pub struct BufReader<R> {
 }
 
 impl<R: Read> BufReader<R> {
-    /// Creates a new `BufReader` with a default buffer capacity.
+    /// Creates a new `BufReader` with a default buffer capacity. The default is currently 8 KB,
+    /// but may change in the future.
     ///
     /// # Examples
     ///
@@ -148,31 +149,6 @@ impl<R: Read> BufReader<R> {
     /// ```
     pub fn get_mut(&mut self) -> &mut R { &mut self.inner }
 
-    /// Returns `true` if there are no bytes in the internal buffer.
-    ///
-    /// # Examples
-    //
-    /// ```no_run
-    /// # #![feature(bufreader_is_empty)]
-    /// use std::io::BufReader;
-    /// use std::io::BufRead;
-    /// use std::fs::File;
-    ///
-    /// fn main() -> std::io::Result<()> {
-    ///     let f1 = File::open("log.txt")?;
-    ///     let mut reader = BufReader::new(f1);
-    ///     assert!(reader.is_empty());
-    ///
-    ///     if reader.fill_buf()?.len() > 0 {
-    ///         assert!(!reader.is_empty());
-    ///     }
-    ///     Ok(())
-    /// }
-    /// ```
-    pub fn is_empty(&self) -> bool {
-        self.buffer().is_empty()
-    }
-
     /// Returns a reference to the internally buffered data.
     ///
     /// Unlike `fill_buf`, this will not attempt to fill the buffer if it is empty.
@@ -306,17 +282,15 @@ impl<R: Seek> Seek for BufReader<R> {
     /// `.into_inner()` immediately after a seek yields the underlying reader
     /// at the same position.
     ///
-    /// To seek without discarding the internal buffer, use [`seek_relative`].
+    /// To seek without discarding the internal buffer, use [`Seek::seek_relative`].
     ///
-    /// See `std::io::Seek` for more details.
+    /// See [`std::io::Seek`] for more details.
     ///
     /// Note: In the edge case where you're seeking with `SeekFrom::Current(n)`
     /// where `n` minus the internal buffer length overflows an `i64`, two
     /// seeks will be performed instead of one. If the second seek returns
     /// `Err`, the underlying reader will be left at the same position it would
     /// have if you called `seek` with `SeekFrom::Current(0)`.
-    ///
-    /// [`seek_relative`]: #method.seek_relative
     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
         let result: u64;
         if let SeekFrom::Current(n) = pos {
@@ -438,7 +412,8 @@ pub struct BufWriter<W: Write> {
 pub struct IntoInnerError<W>(W, Error);
 
 impl<W: Write> BufWriter<W> {
-    /// Creates a new `BufWriter` with a default buffer capacity.
+    /// Creates a new `BufWriter` with a default buffer capacity. The default is currently 8 KB,
+    /// but may change in the future.
     ///
     /// # Examples
     ///
@@ -702,7 +677,7 @@ impl<W> fmt::Display for IntoInnerError<W> {
 /// reducing the number of actual writes to the file.
 ///
 /// ```no_run
-/// use std::fs::File;
+/// use std::fs::{self, File};
 /// use std::io::prelude::*;
 /// use std::io::LineWriter;
 ///
@@ -716,17 +691,30 @@ impl<W> fmt::Display for IntoInnerError<W> {
 ///     let file = File::create("poem.txt")?;
 ///     let mut file = LineWriter::new(file);
 ///
-///     for &byte in road_not_taken.iter() {
-///        file.write(&[byte]).unwrap();
-///     }
+///     file.write_all(b"I shall be telling this with a sigh")?;
 ///
-///     // let's check we did the right thing.
-///     let mut file = File::open("poem.txt")?;
-///     let mut contents = String::new();
+///     // No bytes are written until a newline is encountered (or
+///     // the internal buffer is filled).
+///     assert_eq!(fs::read_to_string("poem.txt")?, "");
+///     file.write_all(b"\n")?;
+///     assert_eq!(
+///         fs::read_to_string("poem.txt")?,
+///         "I shall be telling this with a sigh\n",
+///     );
 ///
-///     file.read_to_string(&mut contents)?;
+///     // Write the rest of the poem.
+///     file.write_all(b"Somewhere ages and ages hence:
+/// Two roads diverged in a wood, and I -
+/// I took the one less traveled by,
+/// And that has made all the difference.")?;
 ///
-///     assert_eq!(contents.as_bytes(), &road_not_taken[..]);
+///     // The last line of the poem doesn't end in a newline, so
+///     // we have to flush or drop the `LineWriter` to finish
+///     // writing.
+///     file.flush()?;
+///
+///     // Confirm the whole poem was written.
+///     assert_eq!(fs::read("poem.txt")?, &road_not_taken[..]);
 ///     Ok(())
 /// }
 /// ```
@@ -821,7 +809,7 @@ impl<W: Write> LineWriter<W> {
     ///
     /// The internal buffer is written out before returning the writer.
     ///
-    // # Errors
+    /// # Errors
     ///
     /// An `Err` will be returned if an error occurs while flushing the buffer.
     ///
@@ -858,7 +846,7 @@ impl<W: Write> Write for LineWriter<W> {
 
         // Find the last newline character in the buffer provided. If found then
         // we're going to write all the data up to that point and then flush,
-        // otherewise we just write the whole block to the underlying writer.
+        // otherwise we just write the whole block to the underlying writer.
         let i = match memchr::memrchr(b'\n', buf) {
             Some(i) => i,
             None => return self.inner.write(buf),
@@ -1206,25 +1194,6 @@ mod tests {
         assert_eq!(reader.read(&mut buf).unwrap(), 0);
     }
 
-    #[test]
-    #[allow(deprecated)]
-    fn read_char_buffered() {
-        let buf = [195, 159];
-        let reader = BufReader::with_capacity(1, &buf[..]);
-        assert_eq!(reader.chars().next().unwrap().unwrap(), 'ß');
-    }
-
-    #[test]
-    #[allow(deprecated)]
-    fn test_chars() {
-        let buf = [195, 159, b'a'];
-        let reader = BufReader::with_capacity(1, &buf[..]);
-        let mut it = reader.chars();
-        assert_eq!(it.next().unwrap().unwrap(), 'ß');
-        assert_eq!(it.next().unwrap().unwrap(), 'a');
-        assert!(it.next().is_none());
-    }
-
     #[test]
     #[should_panic]
     fn dont_panic_in_drop_on_panicked_flush() {

+ 17 - 51
src/b81da278623d9dcda1776008612bd42e1922e9c3/cursor.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/cursor.rs

@@ -10,15 +10,18 @@
 
 use io::prelude::*;
 
+#[cfg(feature="alloc")]
+use core::convert::TryInto;
 use core::cmp;
 use io::{self, Initializer, SeekFrom, Error, ErrorKind};
 
-/// A `Cursor` wraps another type and provides it with a
+/// A `Cursor` wraps an in-memory buffer and provides it with a
 /// [`Seek`] implementation.
 ///
-/// `Cursor`s are typically used with in-memory buffers to allow them to
-/// implement [`Read`] and/or [`Write`], allowing these buffers to be used
-/// anywhere you might use a reader or writer that does actual I/O.
+/// `Cursor`s are used with in-memory buffers, anything implementing
+/// `AsRef<[u8]>`, to allow them to implement [`Read`] and/or [`Write`],
+/// allowing these buffers to be used anywhere you might use a reader or writer
+/// that does actual I/O.
 ///
 /// The standard library implements some I/O traits on various types which
 /// are commonly used as a buffer, like `Cursor<`[`Vec`]`<u8>>` and
@@ -85,11 +88,11 @@ pub struct Cursor<T> {
 }
 
 impl<T> Cursor<T> {
-    /// Creates a new cursor wrapping the provided underlying I/O object.
+    /// Creates a new cursor wrapping the provided underlying in-memory buffer.
     ///
-    /// Cursor initial position is `0` even if underlying object (e.
-    /// g. `Vec`) is not empty. So writing to cursor starts with
-    /// overwriting `Vec` content, not with appending to it.
+    /// Cursor initial position is `0` even if underlying buffer (e.g. `Vec`)
+    /// is not empty. So writing to cursor starts with overwriting `Vec`
+    /// content, not with appending to it.
     ///
     /// # Examples
     ///
@@ -240,7 +243,7 @@ impl<T> Cursor<T> where T: AsRef<[u8]> {
     }
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<T> BufRead for Cursor<T> 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; }
@@ -254,27 +257,10 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result<us
     Ok(amt)
 }
 
-/// Compensate removal of some impls per
-/// https://github.com/rust-lang/rust/pull/49305#issuecomment-376293243
-#[cfg(any(target_pointer_width = "16",
-          target_pointer_width = "32"))]
-fn try_into(n: u64) -> Result<usize, ()> {
-    if n <= (<usize>::max_value() as u64) {
-        Ok(n as usize)
-    } else {
-        Err(())
-    }
-}
-
-#[cfg(any(target_pointer_width = "64"))]
-fn try_into(n: u64) -> Result<usize, ()> {
-    Ok(n as usize)
-}
-
 // Resizing write implementation
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 fn vec_write(pos_mut: &mut u64, vec: &mut Vec<u8>, buf: &[u8]) -> io::Result<usize> {
-    let pos: usize = try_into(*pos_mut).map_err(|_| {
+    let pos: usize = (*pos_mut).try_into().map_err(|_| {
         Error::new(ErrorKind::InvalidInput,
                     "cursor position exceeds maximum possible vector length")
     })?;
@@ -307,7 +293,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> {
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<'a> Write for Cursor<&'a mut Vec<u8>> {
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
         vec_write(&mut self.pos, self.inner, buf)
@@ -315,7 +301,7 @@ impl<'a> Write for Cursor<&'a mut Vec<u8>> {
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
 
-#[cfg(feature = "collections")]
+#[cfg(feature="alloc")]
 impl Write for Cursor<Vec<u8>> {
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
         vec_write(&mut self.pos, &mut self.inner, buf)
@@ -323,7 +309,7 @@ impl Write for Cursor<Vec<u8>> {
     fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
 
-#[cfg(feature = "alloc")]
+#[cfg(feature="alloc")]
 impl Write for Cursor<::alloc::boxed::Box<[u8]>> {
     #[inline]
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
@@ -560,26 +546,6 @@ mod tests {
         assert_eq!(reader.read(&mut buf).unwrap(), 0);
     }
 
-    #[test]
-    #[allow(deprecated)]
-    fn test_read_char() {
-        let b = &b"Vi\xE1\xBB\x87t"[..];
-        let mut c = Cursor::new(b).chars();
-        assert_eq!(c.next().unwrap().unwrap(), 'V');
-        assert_eq!(c.next().unwrap().unwrap(), 'i');
-        assert_eq!(c.next().unwrap().unwrap(), 'ệ');
-        assert_eq!(c.next().unwrap().unwrap(), 't');
-        assert!(c.next().is_none());
-    }
-
-    #[test]
-    #[allow(deprecated)]
-    fn test_read_bad_char() {
-        let b = &b"\x80"[..];
-        let mut c = Cursor::new(b).chars();
-        assert!(c.next().unwrap().is_err());
-    }
-
     #[test]
     fn seek_past_end() {
         let buf = [0xff];

+ 18 - 6
src/b81da278623d9dcda1776008612bd42e1922e9c3/error.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/error.rs

@@ -10,13 +10,12 @@
 
 #[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;
+#[cfg(feature="alloc")] use alloc::string::String;
+#[cfg(not(feature="alloc"))] use ::ErrorString as String;
 use core::convert::From;
 
 /// A specialized [`Result`](../result/enum.Result.html) type for I/O
@@ -79,9 +78,9 @@ impl fmt::Debug for Error {
 enum Repr {
     Os(i32),
     Simple(ErrorKind),
-    #[cfg(feature="alloc")]
+    #[cfg(feature = "alloc")]
     Custom(Box<Custom>),
-    #[cfg(not(feature="alloc"))]
+    #[cfg(not(feature = "alloc"))]
     Custom(Custom),
 }
 
@@ -194,7 +193,7 @@ impl ErrorKind {
             ErrorKind::Interrupted => "operation interrupted",
             ErrorKind::Other => "other os error",
             ErrorKind::UnexpectedEof => "unexpected end of file",
-            ErrorKind::__Nonexhaustive => unreachable!()
+            _ => "unknown error",
         }
     }
 }
@@ -202,6 +201,19 @@ impl ErrorKind {
 /// Intended for use for errors not exposed to the user, where allocating onto
 /// the heap (for normal construction via Error::new) is too costly.
 impl From<ErrorKind> for Error {
+    /// Converts an [`ErrorKind`] into an [`Error`].
+    ///
+    /// This conversion allocates a new error with a simple representation of error kind.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::io::{Error, ErrorKind};
+    ///
+    /// let not_found = ErrorKind::NotFound;
+    /// let error = Error::from(not_found);
+    /// assert_eq!("entity not found", format!("{}", error));
+    /// ```
     #[inline]
     fn from(kind: ErrorKind) -> Error {
         Error {

+ 12 - 12
src/b81da278623d9dcda1776008612bd42e1922e9c3/impls.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/impls.rs

@@ -11,11 +11,11 @@
 #[cfg(feature="alloc")] use alloc::boxed::Box;
 use core::cmp;
 use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind};
-#[cfg(feature="collections")] use io::BufRead;
+#[cfg(feature="alloc")] use io::BufRead;
 use core::fmt;
 use core::mem;
-#[cfg(feature="collections")] use collections::string::String;
-#[cfg(feature="collections")] use collections::vec::Vec;
+#[cfg(feature="alloc")] use alloc::string::String;
+#[cfg(feature="alloc")] use alloc::vec::Vec;
 
 // =============================================================================
 // Forwarding implementations
@@ -31,13 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R {
         (**self).initializer()
     }
 
-    #[cfg(feature="collections")]
+    #[cfg(feature="alloc")]
     #[inline]
     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
         (**self).read_to_end(buf)
     }
 
-    #[cfg(feature="collections")]
+    #[cfg(feature="alloc")]
     #[inline]
     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
         (**self).read_to_string(buf)
@@ -69,7 +69,7 @@ impl<'a, S: Seek + ?Sized> Seek for &'a mut S {
     #[inline]
     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
 }
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B {
     #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
@@ -100,13 +100,13 @@ impl<R: Read + ?Sized> Read for Box<R> {
         (**self).initializer()
     }
 
-    #[cfg(feature="collections")]
+    #[cfg(feature="alloc")]
     #[inline]
     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
         (**self).read_to_end(buf)
     }
 
-    #[cfg(feature="collections")]
+    #[cfg(feature="alloc")]
     #[inline]
     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
         (**self).read_to_string(buf)
@@ -140,7 +140,7 @@ impl<S: Seek + ?Sized> Seek for Box<S> {
     #[inline]
     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
 }
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<B: BufRead + ?Sized> BufRead for Box<B> {
     #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
@@ -211,7 +211,7 @@ impl<'a> Read for &'a [u8] {
         Ok(())
     }
 
-    #[cfg(feature="collections")]
+    #[cfg(feature="alloc")]
     #[inline]
     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
         buf.extend_from_slice(*self);
@@ -221,7 +221,7 @@ impl<'a> Read for &'a [u8] {
     }
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<'a> BufRead for &'a [u8] {
     #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) }
@@ -260,7 +260,7 @@ impl<'a> Write for &'a mut [u8] {
 
 /// Write is implemented for `Vec<u8>` by appending to the vector.
 /// The vector will grow as needed.
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl Write for Vec<u8> {
     #[inline]
     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {

+ 49 - 141
src/b81da278623d9dcda1776008612bd42e1922e9c3/mod.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/mod.rs

@@ -147,7 +147,7 @@
 //! ```
 //!
 //! Note that you cannot use the [`?` operator] in functions that do not return
-//! a [`Result<T, E>`][`Result`] (e.g. `main`). Instead, you can call [`.unwrap()`]
+//! a [`Result<T, E>`][`Result`]. Instead, you can call [`.unwrap()`]
 //! or `match` on the return value to catch any possible errors:
 //!
 //! ```no_run
@@ -267,27 +267,28 @@
 //! [`Result`]: ../result/enum.Result.html
 //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
 
+#[cfg(feature="alloc")]
+use alloc::string::String;
+#[cfg(feature="alloc")]
+use alloc::vec::Vec;
 use core::cmp;
-use core::str as core_str;
 use core::fmt;
-use core::result;
-#[cfg(feature="collections")] use collections::string::String;
 use core::str;
-#[cfg(feature="collections")] use collections::vec::Vec;
-#[cfg(not(core_memchr))]
-mod memchr;
-#[cfg(all(feature="collections",core_memchr))]
+#[cfg(feature="alloc")]
 use core::slice::memchr;
 use core::ptr;
 
-#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter};
-#[cfg(feature="collections")] pub use self::buffered::IntoInnerError;
+#[cfg(feature="alloc")]
+pub use self::buffered::{BufReader, BufWriter, LineWriter};
+#[cfg(feature="alloc")]
+pub use self::buffered::IntoInnerError;
 pub use self::cursor::Cursor;
 pub use self::error::{Result, Error, ErrorKind};
 pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat};
 
 pub mod prelude;
-#[cfg(feature="collections")] mod buffered;
+#[cfg(feature="alloc")]
+mod buffered;
 mod cursor;
 mod error;
 mod impls;
@@ -295,10 +296,10 @@ mod util;
 
 const DEFAULT_BUF_SIZE: usize = 8 * 1024;
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<'a> Drop for Guard<'a> {
     fn drop(&mut self) {
         unsafe { self.buf.set_len(self.len); }
@@ -323,7 +324,7 @@ impl<'a> Drop for Guard<'a> {
 // 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")]
+#[cfg(feature="alloc")]
 fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
     where F: FnOnce(&mut Vec<u8>) -> Result<usize>
 {
@@ -346,20 +347,28 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
 // avoid paying to allocate and zero a huge chunk of memory if the reader only
 // has 4 bytes while still making large reads if the reader does have a ton
 // 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.
+// time is 4,500 times (!) slower than a default reservation size of 32 if the
+// reader has a very small amount of data to return.
 //
 // Because we're extending the buffer with uninitialized data for trusted
 // readers, we need to make sure to truncate that if any of this panics.
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
+    read_to_end_with_reservation(r, buf, 32)
+}
+
+#[cfg(feature="alloc")]
+fn read_to_end_with_reservation<R: Read + ?Sized>(r: &mut R,
+                                                  buf: &mut Vec<u8>,
+                                                  reservation_size: usize) -> Result<usize>
+{
     let start_len = buf.len();
     let mut g = Guard { len: buf.len(), buf: buf };
     let ret;
     loop {
         if g.len == g.buf.len() {
             unsafe {
-                g.buf.reserve(32);
+                g.buf.reserve(reservation_size);
                 let capacity = g.buf.capacity();
                 g.buf.set_len(capacity);
                 r.initializer().initialize(&mut g.buf[g.len..]);
@@ -587,7 +596,7 @@ pub trait Read {
     /// file.)
     ///
     /// [`std::fs::read`]: ../fs/fn.read.html
-    #[cfg(feature = "collections")]
+    #[cfg(feature="alloc")]
     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
         read_to_end(self, buf)
     }
@@ -630,7 +639,7 @@ pub trait Read {
     /// reading from a file.)
     ///
     /// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html
-    #[cfg(feature = "collections")]
+    #[cfg(feature="alloc")]
     fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
         // Note that we do *not* call `.read_to_end()` here. We are passing
         // `&mut Vec<u8>` (the raw contents of `buf`) into the `read_to_end`
@@ -784,47 +793,6 @@ pub trait Read {
         Bytes { inner: self }
     }
 
-    /// Transforms this `Read` instance to an [`Iterator`] over [`char`]s.
-    ///
-    /// This adaptor will attempt to interpret this reader as a UTF-8 encoded
-    /// sequence of characters. The returned iterator will return [`None`] once
-    /// EOF is reached for this reader. Otherwise each element yielded will be a
-    /// [`Result`]`<`[`char`]`, E>` where `E` may contain information about what I/O error
-    /// occurred or where decoding failed.
-    ///
-    /// Currently this adaptor will discard intermediate data read, and should
-    /// be avoided if this is not desired.
-    ///
-    /// # Examples
-    ///
-    /// [`File`]s implement `Read`:
-    ///
-    /// [`File`]: ../fs/struct.File.html
-    /// [`Iterator`]: ../../std/iter/trait.Iterator.html
-    /// [`Result`]: ../../std/result/enum.Result.html
-    /// [`char`]: ../../std/primitive.char.html
-    /// [`None`]: ../../std/option/enum.Option.html#variant.None
-    ///
-    /// ```no_run
-    /// #![feature(io)]
-    /// use std::io;
-    /// use std::io::prelude::*;
-    /// use std::fs::File;
-    ///
-    /// fn main() -> io::Result<()> {
-    ///     let mut f = File::open("foo.txt")?;
-    ///
-    ///     for c in f.chars() {
-    ///         println!("{}", c.unwrap());
-    ///     }
-    ///     Ok(())
-    /// }
-    /// ```
-    #[allow(deprecated)]
-    fn chars(self) -> Chars<Self> where Self: Sized {
-        Chars { inner: self }
-    }
-
     /// Creates an adaptor which will chain this stream with another.
     ///
     /// The returned `Read` instance will first read all bytes from this object
@@ -1211,8 +1179,8 @@ pub trait Write {
 pub trait Seek {
     /// Seek to an offset, in bytes, in a stream.
     ///
-    /// A seek beyond the end of a stream is allowed, but implementation
-    /// defined.
+    /// A seek beyond the end of a stream is allowed, but behavior is defined
+    /// by the implementation.
     ///
     /// If the seek operation completed successfully,
     /// this method returns the new position from the start of the stream.
@@ -1251,7 +1219,7 @@ pub enum SeekFrom {
     Current(i64),
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
                                    -> Result<usize> {
     let mut read = 0;
@@ -1331,9 +1299,10 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
 /// }
 /// ```
 ///
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 pub trait BufRead: Read {
-    /// Fills the internal buffer of this object, returning the buffer contents.
+    /// Returns the contents of the internal buffer, filling it with more data
+    /// from the inner reader if it is empty.
     ///
     /// This function is a lower-level call. It needs to be paired with the
     /// [`consume`] method to function properly. When calling this
@@ -1707,7 +1676,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
     }
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
     fn fill_buf(&mut self) -> Result<&[u8]> {
         if !self.done_first {
@@ -1890,9 +1859,16 @@ impl<T: Read> Read for Take<T> {
     unsafe fn initializer(&self) -> Initializer {
         self.inner.initializer()
     }
+
+    #[cfg(feature="alloc")]
+    fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
+        let reservation_size = cmp::min(self.limit, 32) as usize;
+
+        read_to_end_with_reservation(self, buf, reservation_size)
+    }
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<T: BufRead> BufRead for Take<T> {
     fn fill_buf(&mut self) -> Result<&[u8]> {
         // Don't call into inner reader at all at EOF because it may still block
@@ -1913,7 +1889,7 @@ impl<T: BufRead> BufRead for Take<T> {
     }
 }
 
-fn read_one_byte(reader: &mut Read) -> Option<Result<u8>> {
+fn read_one_byte(reader: &mut dyn Read) -> Option<Result<u8>> {
     let mut buf = [0];
     loop {
         return match reader.read(&mut buf) {
@@ -1944,74 +1920,6 @@ impl<R: Read> Iterator for Bytes<R> {
     }
 }
 
-/// An iterator over the `char`s of a reader.
-///
-/// This struct is generally created by calling [`chars`][chars] on a reader.
-/// Please see the documentation of `chars()` for more details.
-///
-/// [chars]: trait.Read.html#method.chars
-#[derive(Debug)]
-#[allow(deprecated)]
-pub struct Chars<R> {
-    inner: R,
-}
-
-/// An enumeration of possible errors that can be generated from the `Chars`
-/// adapter.
-#[derive(Debug)]
-#[allow(deprecated)]
-pub enum CharsError {
-    /// Variant representing that the underlying stream was read successfully
-    /// but it did not contain valid utf8 data.
-    NotUtf8,
-
-    /// Variant representing that an I/O error occurred.
-    Other(Error),
-}
-
-#[allow(deprecated)]
-impl<R: Read> Iterator for Chars<R> {
-    type Item = result::Result<char, CharsError>;
-
-    fn next(&mut self) -> Option<result::Result<char, CharsError>> {
-        let first_byte = match read_one_byte(&mut self.inner)? {
-            Ok(b) => b,
-            Err(e) => return Some(Err(CharsError::Other(e))),
-        };
-        let width = core_str::utf8_char_width(first_byte);
-        if width == 1 { return Some(Ok(first_byte as char)) }
-        if width == 0 { return Some(Err(CharsError::NotUtf8)) }
-        let mut buf = [first_byte, 0, 0, 0];
-        {
-            let mut start = 1;
-            while start < width {
-                match self.inner.read(&mut buf[start..width]) {
-                    Ok(0) => return Some(Err(CharsError::NotUtf8)),
-                    Ok(n) => start += n,
-                    Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
-                    Err(e) => return Some(Err(CharsError::Other(e))),
-                }
-            }
-        }
-        Some(match str::from_utf8(&buf[..width]).ok() {
-            Some(s) => Ok(s.chars().next().unwrap()),
-            None => Err(CharsError::NotUtf8),
-        })
-    }
-}
-
-#[allow(deprecated)]
-impl fmt::Display for CharsError {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self {
-            CharsError::NotUtf8 => {
-                "byte stream did not contain valid utf8".fmt(f)
-            }
-            CharsError::Other(ref e) => e.fmt(f),
-        }
-    }
-}
-
 /// An iterator over the contents of an instance of `BufRead` split on a
 /// particular byte.
 ///
@@ -2019,14 +1927,14 @@ impl fmt::Display for CharsError {
 /// `BufRead`. Please see the documentation of `split()` for more details.
 ///
 /// [split]: trait.BufRead.html#method.split
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 #[derive(Debug)]
 pub struct Split<B> {
     buf: B,
     delim: u8,
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<B: BufRead> Iterator for Split<B> {
     type Item = Result<Vec<u8>>;
 
@@ -2051,13 +1959,13 @@ impl<B: BufRead> Iterator for Split<B> {
 /// `BufRead`. Please see the documentation of `lines()` for more details.
 ///
 /// [lines]: trait.BufRead.html#method.lines
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 #[derive(Debug)]
 pub struct Lines<B> {
     buf: B,
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl<B: BufRead> Iterator for Lines<B> {
     type Item = Result<String>;
 

+ 3 - 3
src/b81da278623d9dcda1776008612bd42e1922e9c3/prelude.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/prelude.rs

@@ -19,7 +19,7 @@
 //! ```
 
 pub use super::{Read, Write, Seek};
-#[cfg(feature="collections")] pub use super::BufRead;
+#[cfg(feature="alloc")] pub use super::BufRead;
 
-#[cfg(feature="collections")] pub use alloc::boxed::Box;
-#[cfg(feature="collections")] pub use collections::vec::Vec;
+#[cfg(feature="alloc")] pub use alloc::boxed::Box;
+#[cfg(feature="alloc")] pub use alloc::vec::Vec;

+ 8 - 3
src/b81da278623d9dcda1776008612bd42e1922e9c3/util.rs → src/b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d/util.rs

@@ -13,7 +13,7 @@
 use core::fmt;
 use io::{self, Read, Initializer, Write, ErrorKind};
 use core::mem;
-#[cfg(feature="collections")] use io::BufRead;
+#[cfg(feature="alloc")] use io::BufRead;
 
 /// Copies the entire contents of a reader into a writer.
 ///
@@ -24,6 +24,11 @@ use core::mem;
 /// On success, the total number of bytes that were copied from
 /// `reader` to `writer` is returned.
 ///
+/// If you’re wanting to copy the contents of one file to another and you’re
+/// working with filesystem paths, see the [`fs::copy`] function.
+///
+/// [`fs::copy`]: ../fs/fn.copy.html
+///
 /// # Errors
 ///
 /// This function will return an error immediately if any call to `read` or
@@ -104,7 +109,7 @@ impl Read for Empty {
     }
 }
 
-#[cfg(feature="collections")]
+#[cfg(feature="alloc")]
 impl BufRead for Empty {
     #[inline]
     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) }
@@ -212,7 +217,7 @@ mod tests {
         assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
 
         let mut r = repeat(0).take(1 << 17);
-        assert_eq!(copy(&mut r as &mut Read, &mut w as &mut Write).unwrap(), 1 << 17);
+        assert_eq!(copy(&mut r as &mut dyn Read, &mut w as &mut dyn Write).unwrap(), 1 << 17);
     }
 
     #[test]

+ 3 - 2
src/lib.rs

@@ -3,8 +3,9 @@
 //! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html)
 //! for a full description of the functionality.
 #![allow(stable_features,unused_features)]
-#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,
-	str_char,try_from,str_internals,align_offset,doc_spotlight,slice_internals)]
+#![feature(question_mark,const_fn,copy_from_slice,
+	try_from,str_internals,align_offset,doc_spotlight,slice_internals)]
+#![cfg_attr(feature="alloc",feature(alloc))]
 #![no_std]
 
 #[cfg_attr(feature="collections",macro_use)]