xref: /relibc/core_io/patches/dcd80b80ae3fe2f327515e57fdc423a3927e44e6.patch (revision 9c41fb90001ef2781317213b24baa972d55820a8)
1diff --git a/buffered.rs b/buffered.rs
2index cd7a50d..efa81b6 100644
3--- a/buffered.rs
4+++ b/buffered.rs
5@@ -10,13 +10,13 @@
6
7 //! Buffering wrappers for I/O traits
8
9+use core::prelude::v1::*;
10 use io::prelude::*;
11
12-use cmp;
13-use error;
14-use fmt;
15+use core::cmp;
16+use core::fmt;
17 use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom};
18-use memchr;
19+use io::memchr;
20
21 /// The `BufReader` struct adds buffering to any reader.
22 ///
23@@ -46,7 +46,6 @@ use memchr;
24 /// # Ok(())
25 /// # }
26 /// ```
27-#[stable(feature = "rust1", since = "1.0.0")]
28 pub struct BufReader<R> {
29     inner: R,
30     buf: Box<[u8]>,
31@@ -69,7 +68,6 @@ impl<R: Read> BufReader<R> {
32     /// # Ok(())
33     /// # }
34     /// ```
35-    #[stable(feature = "rust1", since = "1.0.0")]
36     pub fn new(inner: R) -> BufReader<R> {
37         BufReader::with_capacity(DEFAULT_BUF_SIZE, inner)
38     }
39@@ -90,7 +88,6 @@ impl<R: Read> BufReader<R> {
40     /// # Ok(())
41     /// # }
42     /// ```
43-    #[stable(feature = "rust1", since = "1.0.0")]
44     pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
45         BufReader {
46             inner: inner,
47@@ -118,7 +115,6 @@ impl<R: Read> BufReader<R> {
48     /// # Ok(())
49     /// # }
50     /// ```
51-    #[stable(feature = "rust1", since = "1.0.0")]
52     pub fn get_ref(&self) -> &R { &self.inner }
53
54     /// Gets a mutable reference to the underlying reader.
55@@ -139,7 +135,6 @@ impl<R: Read> BufReader<R> {
56     /// # Ok(())
57     /// # }
58     /// ```
59-    #[stable(feature = "rust1", since = "1.0.0")]
60     pub fn get_mut(&mut self) -> &mut R { &mut self.inner }
61
62     /// Unwraps this `BufReader`, returning the underlying reader.
63@@ -160,11 +155,9 @@ impl<R: Read> BufReader<R> {
64     /// # Ok(())
65     /// # }
66     /// ```
67-    #[stable(feature = "rust1", since = "1.0.0")]
68     pub fn into_inner(self) -> R { self.inner }
69 }
70
71-#[stable(feature = "rust1", since = "1.0.0")]
72 impl<R: Read> Read for BufReader<R> {
73     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
74         // If we don't have any buffered data and we're doing a massive read
75@@ -182,7 +175,6 @@ impl<R: Read> Read for BufReader<R> {
76     }
77 }
78
79-#[stable(feature = "rust1", since = "1.0.0")]
80 impl<R: Read> BufRead for BufReader<R> {
81     fn fill_buf(&mut self) -> io::Result<&[u8]> {
82         // If we've reached the end of our internal buffer then we need to fetch
83@@ -202,7 +194,6 @@ impl<R: Read> BufRead for BufReader<R> {
84     }
85 }
86
87-#[stable(feature = "rust1", since = "1.0.0")]
88 impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
89     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
90         fmt.debug_struct("BufReader")
91@@ -212,7 +203,6 @@ impl<R> fmt::Debug for BufReader<R> where R: fmt::Debug {
92     }
93 }
94
95-#[stable(feature = "rust1", since = "1.0.0")]
96 impl<R: Seek> Seek for BufReader<R> {
97     /// Seek to an offset, in bytes, in the underlying reader.
98     ///
99@@ -305,7 +295,6 @@ impl<R: Seek> Seek for BufReader<R> {
100 /// [`Write`]: ../../std/io/trait.Write.html
101 /// [`write`]: ../../std/net/struct.TcpStream.html#method.write
102 /// [`TcpStream`]: ../../std/net/struct.TcpStream.html
103-#[stable(feature = "rust1", since = "1.0.0")]
104 pub struct BufWriter<W: Write> {
105     inner: Option<W>,
106     buf: Vec<u8>,
107@@ -340,7 +329,6 @@ pub struct BufWriter<W: Write> {
108 /// };
109 /// ```
110 #[derive(Debug)]
111-#[stable(feature = "rust1", since = "1.0.0")]
112 pub struct IntoInnerError<W>(W, Error);
113
114 impl<W: Write> BufWriter<W> {
115@@ -354,7 +342,6 @@ impl<W: Write> BufWriter<W> {
116     ///
117     /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap());
118     /// ```
119-    #[stable(feature = "rust1", since = "1.0.0")]
120     pub fn new(inner: W) -> BufWriter<W> {
121         BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner)
122     }
123@@ -372,7 +359,6 @@ impl<W: Write> BufWriter<W> {
124     /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap();
125     /// let mut buffer = BufWriter::with_capacity(100, stream);
126     /// ```
127-    #[stable(feature = "rust1", since = "1.0.0")]
128     pub fn with_capacity(cap: usize, inner: W) -> BufWriter<W> {
129         BufWriter {
130             inner: Some(inner),
131@@ -421,7 +407,6 @@ impl<W: Write> BufWriter<W> {
132     /// // we can use reference just like buffer
133     /// let reference = buffer.get_ref();
134     /// ```
135-    #[stable(feature = "rust1", since = "1.0.0")]
136     pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() }
137
138     /// Gets a mutable reference to the underlying writer.
139@@ -439,7 +424,6 @@ impl<W: Write> BufWriter<W> {
140     /// // we can use reference just like buffer
141     /// let reference = buffer.get_mut();
142     /// ```
143-    #[stable(feature = "rust1", since = "1.0.0")]
144     pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() }
145
146     /// Unwraps this `BufWriter`, returning the underlying writer.
147@@ -457,7 +441,6 @@ impl<W: Write> BufWriter<W> {
148     /// // unwrap the TcpStream and flush the buffer
149     /// let stream = buffer.into_inner().unwrap();
150     /// ```
151-    #[stable(feature = "rust1", since = "1.0.0")]
152     pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> {
153         match self.flush_buf() {
154             Err(e) => Err(IntoInnerError(self, e)),
155@@ -466,7 +449,6 @@ impl<W: Write> BufWriter<W> {
156     }
157 }
158
159-#[stable(feature = "rust1", since = "1.0.0")]
160 impl<W: Write> Write for BufWriter<W> {
161     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
162         if self.buf.len() + buf.len() > self.buf.capacity() {
163@@ -486,7 +468,6 @@ impl<W: Write> Write for BufWriter<W> {
164     }
165 }
166
167-#[stable(feature = "rust1", since = "1.0.0")]
168 impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug {
169     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
170         fmt.debug_struct("BufWriter")
171@@ -496,7 +477,6 @@ impl<W: Write> fmt::Debug for BufWriter<W> where W: fmt::Debug {
172     }
173 }
174
175-#[stable(feature = "rust1", since = "1.0.0")]
176 impl<W: Write + Seek> Seek for BufWriter<W> {
177     /// Seek to the offset, in bytes, in the underlying writer.
178     ///
179@@ -506,7 +486,6 @@ impl<W: Write + Seek> Seek for BufWriter<W> {
180     }
181 }
182
183-#[stable(feature = "rust1", since = "1.0.0")]
184 impl<W: Write> Drop for BufWriter<W> {
185     fn drop(&mut self) {
186         if self.inner.is_some() && !self.panicked {
187@@ -545,7 +524,6 @@ impl<W> IntoInnerError<W> {
188     ///     }
189     /// };
190     /// ```
191-    #[stable(feature = "rust1", since = "1.0.0")]
192     pub fn error(&self) -> &Error { &self.1 }
193
194     /// Returns the buffered writer instance which generated the error.
195@@ -578,23 +556,13 @@ impl<W> IntoInnerError<W> {
196     ///     }
197     /// };
198     /// ```
199-    #[stable(feature = "rust1", since = "1.0.0")]
200     pub fn into_inner(self) -> W { self.0 }
201 }
202
203-#[stable(feature = "rust1", since = "1.0.0")]
204 impl<W> From<IntoInnerError<W>> for Error {
205     fn from(iie: IntoInnerError<W>) -> Error { iie.1 }
206 }
207
208-#[stable(feature = "rust1", since = "1.0.0")]
209-impl<W: Send + fmt::Debug> error::Error for IntoInnerError<W> {
210-    fn description(&self) -> &str {
211-        error::Error::description(self.error())
212-    }
213-}
214-
215-#[stable(feature = "rust1", since = "1.0.0")]
216 impl<W> fmt::Display for IntoInnerError<W> {
217     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
218         self.error().fmt(f)
219@@ -649,7 +617,6 @@ impl<W> fmt::Display for IntoInnerError<W> {
220 /// # Ok(())
221 /// # }
222 /// ```
223-#[stable(feature = "rust1", since = "1.0.0")]
224 pub struct LineWriter<W: Write> {
225     inner: BufWriter<W>,
226 }
227@@ -669,7 +636,6 @@ impl<W: Write> LineWriter<W> {
228     /// # Ok(())
229     /// # }
230     /// ```
231-    #[stable(feature = "rust1", since = "1.0.0")]
232     pub fn new(inner: W) -> LineWriter<W> {
233         // Lines typically aren't that long, don't use a giant buffer
234         LineWriter::with_capacity(1024, inner)
235@@ -690,7 +656,6 @@ impl<W: Write> LineWriter<W> {
236     /// # Ok(())
237     /// # }
238     /// ```
239-    #[stable(feature = "rust1", since = "1.0.0")]
240     pub fn with_capacity(cap: usize, inner: W) -> LineWriter<W> {
241         LineWriter { inner: BufWriter::with_capacity(cap, inner) }
242     }
243@@ -711,7 +676,6 @@ impl<W: Write> LineWriter<W> {
244     /// # Ok(())
245     /// # }
246     /// ```
247-    #[stable(feature = "rust1", since = "1.0.0")]
248     pub fn get_ref(&self) -> &W { self.inner.get_ref() }
249
250     /// Gets a mutable reference to the underlying writer.
251@@ -734,7 +698,6 @@ impl<W: Write> LineWriter<W> {
252     /// # Ok(())
253     /// # }
254     /// ```
255-    #[stable(feature = "rust1", since = "1.0.0")]
256     pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() }
257
258     /// Unwraps this `LineWriter`, returning the underlying writer.
259@@ -756,7 +719,6 @@ impl<W: Write> LineWriter<W> {
260     /// # Ok(())
261     /// # }
262     /// ```
263-    #[stable(feature = "rust1", since = "1.0.0")]
264     pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> {
265         self.inner.into_inner().map_err(|IntoInnerError(buf, e)| {
266             IntoInnerError(LineWriter { inner: buf }, e)
267@@ -764,7 +726,6 @@ impl<W: Write> LineWriter<W> {
268     }
269 }
270
271-#[stable(feature = "rust1", since = "1.0.0")]
272 impl<W: Write> Write for LineWriter<W> {
273     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
274         match memchr::memrchr(b'\n', buf) {
275@@ -783,7 +744,6 @@ impl<W: Write> Write for LineWriter<W> {
276     fn flush(&mut self) -> io::Result<()> { self.inner.flush() }
277 }
278
279-#[stable(feature = "rust1", since = "1.0.0")]
280 impl<W: Write> fmt::Debug for LineWriter<W> where W: fmt::Debug {
281     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
282         fmt.debug_struct("LineWriter")
283diff --git a/cursor.rs b/cursor.rs
284index 1b50233..6a7b44f 100644
285--- a/cursor.rs
286+++ b/cursor.rs
287@@ -8,10 +8,11 @@
288 // option. This file may not be copied, modified, or distributed
289 // except according to those terms.
290
291+use core::prelude::v1::*;
292 use io::prelude::*;
293
294-use core::convert::TryInto;
295-use cmp;
296+#[cfg(feature = "collections")] use core::convert::TryInto;
297+use core::cmp;
298 use io::{self, SeekFrom, Error, ErrorKind};
299
300 /// A `Cursor` wraps another type and provides it with a
301@@ -79,7 +80,6 @@ use io::{self, SeekFrom, Error, ErrorKind};
302 ///     assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
303 /// }
304 /// ```
305-#[stable(feature = "rust1", since = "1.0.0")]
306 #[derive(Clone, Debug)]
307 pub struct Cursor<T> {
308     inner: T,
309@@ -98,7 +98,6 @@ impl<T> Cursor<T> {
310     /// # fn force_inference(_: &Cursor<Vec<u8>>) {}
311     /// # force_inference(&buff);
312     /// ```
313-    #[stable(feature = "rust1", since = "1.0.0")]
314     pub fn new(inner: T) -> Cursor<T> {
315         Cursor { pos: 0, inner: inner }
316     }
317@@ -116,7 +115,6 @@ impl<T> Cursor<T> {
318     ///
319     /// let vec = buff.into_inner();
320     /// ```
321-    #[stable(feature = "rust1", since = "1.0.0")]
322     pub fn into_inner(self) -> T { self.inner }
323
324     /// Gets a reference to the underlying value in this cursor.
325@@ -132,7 +130,6 @@ impl<T> Cursor<T> {
326     ///
327     /// let reference = buff.get_ref();
328     /// ```
329-    #[stable(feature = "rust1", since = "1.0.0")]
330     pub fn get_ref(&self) -> &T { &self.inner }
331
332     /// Gets a mutable reference to the underlying value in this cursor.
333@@ -151,7 +148,6 @@ impl<T> Cursor<T> {
334     ///
335     /// let reference = buff.get_mut();
336     /// ```
337-    #[stable(feature = "rust1", since = "1.0.0")]
338     pub fn get_mut(&mut self) -> &mut T { &mut self.inner }
339
340     /// Returns the current position of this cursor.
341@@ -173,7 +169,6 @@ impl<T> Cursor<T> {
342     /// buff.seek(SeekFrom::Current(-1)).unwrap();
343     /// assert_eq!(buff.position(), 1);
344     /// ```
345-    #[stable(feature = "rust1", since = "1.0.0")]
346     pub fn position(&self) -> u64 { self.pos }
347
348     /// Sets the position of this cursor.
349@@ -193,11 +188,9 @@ impl<T> Cursor<T> {
350     /// buff.set_position(4);
351     /// assert_eq!(buff.position(), 4);
352     /// ```
353-    #[stable(feature = "rust1", since = "1.0.0")]
354     pub fn set_position(&mut self, pos: u64) { self.pos = pos; }
355 }
356
357-#[stable(feature = "rust1", since = "1.0.0")]
358 impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> {
359     fn seek(&mut self, style: SeekFrom) -> io::Result<u64> {
360         let pos = match style {
361@@ -216,25 +209,27 @@ impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> {
362     }
363 }
364
365-#[stable(feature = "rust1", since = "1.0.0")]
366 impl<T> Read for Cursor<T> where T: AsRef<[u8]> {
367     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
368-        let n = Read::read(&mut self.fill_buf()?, buf)?;
369+        let n = Read::read(&mut self.get_buf()?, buf)?;
370         self.pos += n as u64;
371         Ok(n)
372     }
373 }
374
375-#[stable(feature = "rust1", since = "1.0.0")]
376-impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> {
377-    fn fill_buf(&mut self) -> io::Result<&[u8]> {
378+impl<T> Cursor<T> where T: AsRef<[u8]> {
379+    fn get_buf(&mut self) -> io::Result<&[u8]> {
380         let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64);
381         Ok(&self.inner.as_ref()[(amt as usize)..])
382     }
383+}
384+
385+#[cfg(feature = "collections")]
386+impl<T> BufRead for Cursor<T> where T: AsRef<[u8]> {
387+    fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() }
388     fn consume(&mut self, amt: usize) { self.pos += amt as u64; }
389 }
390
391-#[stable(feature = "rust1", since = "1.0.0")]
392 impl<'a> Write for Cursor<&'a mut [u8]> {
393     #[inline]
394     fn write(&mut self, data: &[u8]) -> io::Result<usize> {
395@@ -246,7 +241,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> {
396     fn flush(&mut self) -> io::Result<()> { Ok(()) }
397 }
398
399-#[stable(feature = "rust1", since = "1.0.0")]
400+#[cfg(feature = "collections")]
401 impl Write for Cursor<Vec<u8>> {
402     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
403         let pos: usize = self.position().try_into().map_err(|_| {
404@@ -276,8 +271,8 @@ impl Write for Cursor<Vec<u8>> {
405     fn flush(&mut self) -> io::Result<()> { Ok(()) }
406 }
407
408-#[stable(feature = "cursor_box_slice", since = "1.5.0")]
409-impl Write for Cursor<Box<[u8]>> {
410+#[cfg(feature = "alloc")]
411+impl Write for Cursor<::alloc::boxed::Box<[u8]>> {
412     #[inline]
413     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
414         let pos = cmp::min(self.pos, self.inner.len() as u64);
415diff --git a/error.rs b/error.rs
416index 795c89c..9a11eee 100644
417--- a/error.rs
418+++ b/error.rs
419@@ -8,11 +8,16 @@
420 // option. This file may not be copied, modified, or distributed
421 // except according to those terms.
422
423-use error;
424-use fmt;
425-use result;
426-use sys;
427-use convert::From;
428+#[cfg(feature="alloc")] use alloc::boxed::Box;
429+#[cfg(not(feature="alloc"))] use ::FakeBox as Box;
430+use core::convert::Into;
431+use core::fmt;
432+use core::marker::{Send, Sync};
433+use core::option::Option::{self, Some, None};
434+use core::result;
435+#[cfg(feature="collections")] use collections::string::String;
436+#[cfg(not(feature="collections"))] use ::ErrorString as String;
437+use core::convert::From;
438
439 /// A specialized [`Result`](../result/enum.Result.html) type for I/O
440 /// operations.
441@@ -44,7 +49,6 @@ use convert::From;
442 ///     Ok(buffer)
443 /// }
444 /// ```
445-#[stable(feature = "rust1", since = "1.0.0")]
446 pub type Result<T> = result::Result<T, Error>;
447
448 /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and
449@@ -56,7 +60,6 @@ pub type Result<T> = result::Result<T, Error>;
450 ///
451 /// [`ErrorKind`]: enum.ErrorKind.html
452 #[derive(Debug)]
453-#[stable(feature = "rust1", since = "1.0.0")]
454 pub struct Error {
455     repr: Repr,
456 }
457@@ -64,13 +67,16 @@ pub struct Error {
458 enum Repr {
459     Os(i32),
460     Simple(ErrorKind),
461+    #[cfg(feature="alloc")]
462     Custom(Box<Custom>),
463+    #[cfg(not(feature="alloc"))]
464+    Custom(Custom),
465 }
466
467 #[derive(Debug)]
468 struct Custom {
469     kind: ErrorKind,
470-    error: Box<error::Error+Send+Sync>,
471+    error: String,
472 }
473
474 /// A list specifying general categories of I/O error.
475@@ -82,47 +88,34 @@ struct Custom {
476 ///
477 /// [`io::Error`]: struct.Error.html
478 #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
479-#[stable(feature = "rust1", since = "1.0.0")]
480 #[allow(deprecated)]
481 pub enum ErrorKind {
482     /// An entity was not found, often a file.
483-    #[stable(feature = "rust1", since = "1.0.0")]
484     NotFound,
485     /// The operation lacked the necessary privileges to complete.
486-    #[stable(feature = "rust1", since = "1.0.0")]
487     PermissionDenied,
488     /// The connection was refused by the remote server.
489-    #[stable(feature = "rust1", since = "1.0.0")]
490     ConnectionRefused,
491     /// The connection was reset by the remote server.
492-    #[stable(feature = "rust1", since = "1.0.0")]
493     ConnectionReset,
494     /// The connection was aborted (terminated) by the remote server.
495-    #[stable(feature = "rust1", since = "1.0.0")]
496     ConnectionAborted,
497     /// The network operation failed because it was not connected yet.
498-    #[stable(feature = "rust1", since = "1.0.0")]
499     NotConnected,
500     /// A socket address could not be bound because the address is already in
501     /// use elsewhere.
502-    #[stable(feature = "rust1", since = "1.0.0")]
503     AddrInUse,
504     /// A nonexistent interface was requested or the requested address was not
505     /// local.
506-    #[stable(feature = "rust1", since = "1.0.0")]
507     AddrNotAvailable,
508     /// The operation failed because a pipe was closed.
509-    #[stable(feature = "rust1", since = "1.0.0")]
510     BrokenPipe,
511     /// An entity already exists, often a file.
512-    #[stable(feature = "rust1", since = "1.0.0")]
513     AlreadyExists,
514     /// The operation needs to block to complete, but the blocking operation was
515     /// requested to not occur.
516-    #[stable(feature = "rust1", since = "1.0.0")]
517     WouldBlock,
518     /// A parameter was incorrect.
519-    #[stable(feature = "rust1", since = "1.0.0")]
520     InvalidInput,
521     /// Data not valid for the operation were encountered.
522     ///
523@@ -134,10 +127,8 @@ pub enum ErrorKind {
524     /// `InvalidData` if the file's contents are not valid UTF-8.
525     ///
526     /// [`InvalidInput`]: #variant.InvalidInput
527-    #[stable(feature = "io_invalid_data", since = "1.2.0")]
528     InvalidData,
529     /// The I/O operation's timeout expired, causing it to be canceled.
530-    #[stable(feature = "rust1", since = "1.0.0")]
531     TimedOut,
532     /// An error returned when an operation could not be completed because a
533     /// call to [`write()`] returned [`Ok(0)`].
534@@ -148,15 +139,12 @@ pub enum ErrorKind {
535     ///
536     /// [`write()`]: ../../std/io/trait.Write.html#tymethod.write
537     /// [`Ok(0)`]: ../../std/io/type.Result.html
538-    #[stable(feature = "rust1", since = "1.0.0")]
539     WriteZero,
540     /// This operation was interrupted.
541     ///
542     /// Interrupted operations can typically be retried.
543-    #[stable(feature = "rust1", since = "1.0.0")]
544     Interrupted,
545     /// Any I/O error not part of this list.
546-    #[stable(feature = "rust1", since = "1.0.0")]
547     Other,
548
549     /// An error returned when an operation could not be completed because an
550@@ -165,15 +153,10 @@ pub enum ErrorKind {
551     /// This typically means that an operation could only succeed if it read a
552     /// particular number of bytes but only a smaller number of bytes could be
553     /// read.
554-    #[stable(feature = "read_exact", since = "1.6.0")]
555     UnexpectedEof,
556
557     /// A marker variant that tells the compiler that users of this enum cannot
558     /// match it exhaustively.
559-    #[unstable(feature = "io_error_internals",
560-               reason = "better expressed through extensible enums that this \
561-                         enum cannot be exhaustively matched against",
562-               issue = "0")]
563     #[doc(hidden)]
564     __Nonexhaustive,
565 }
566@@ -206,7 +189,6 @@ impl ErrorKind {
567
568 /// Intended for use for errors not exposed to the user, where allocating onto
569 /// the heap (for normal construction via Error::new) is too costly.
570-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
571 impl From<ErrorKind> for Error {
572     fn from(kind: ErrorKind) -> Error {
573         Error {
574@@ -234,14 +216,13 @@ impl Error {
575     /// // errors can also be created from other errors
576     /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error);
577     /// ```
578-    #[stable(feature = "rust1", since = "1.0.0")]
579     pub fn new<E>(kind: ErrorKind, error: E) -> Error
580-        where E: Into<Box<error::Error+Send+Sync>>
581+        where E: Into<String>
582     {
583         Self::_new(kind, error.into())
584     }
585
586-    fn _new(kind: ErrorKind, error: Box<error::Error+Send+Sync>) -> Error {
587+    fn _new(kind: ErrorKind, error: String) -> Error {
588         Error {
589             repr: Repr::Custom(Box::new(Custom {
590                 kind: kind,
591@@ -250,24 +231,6 @@ impl Error {
592         }
593     }
594
595-    /// Returns an error representing the last OS error which occurred.
596-    ///
597-    /// This function reads the value of `errno` for the target platform (e.g.
598-    /// `GetLastError` on Windows) and will return a corresponding instance of
599-    /// `Error` for the error code.
600-    ///
601-    /// # Examples
602-    ///
603-    /// ```
604-    /// use std::io::Error;
605-    ///
606-    /// println!("last OS error: {:?}", Error::last_os_error());
607-    /// ```
608-    #[stable(feature = "rust1", since = "1.0.0")]
609-    pub fn last_os_error() -> Error {
610-        Error::from_raw_os_error(sys::os::errno() as i32)
611-    }
612-
613     /// Creates a new instance of an `Error` from a particular OS error code.
614     ///
615     /// # Examples
616@@ -293,7 +256,6 @@ impl Error {
617     /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
618     /// # }
619     /// ```
620-    #[stable(feature = "rust1", since = "1.0.0")]
621     pub fn from_raw_os_error(code: i32) -> Error {
622         Error { repr: Repr::Os(code) }
623     }
624@@ -324,7 +286,6 @@ impl Error {
625     ///     print_os_error(&Error::new(ErrorKind::Other, "oh no!"));
626     /// }
627     /// ```
628-    #[stable(feature = "rust1", since = "1.0.0")]
629     pub fn raw_os_error(&self) -> Option<i32> {
630         match self.repr {
631             Repr::Os(i) => Some(i),
632@@ -358,12 +319,11 @@ impl Error {
633     ///     print_error(&Error::new(ErrorKind::Other, "oh no!"));
634     /// }
635     /// ```
636-    #[stable(feature = "io_error_inner", since = "1.3.0")]
637-    pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> {
638+    pub fn get_ref(&self) -> Option<&String> {
639         match self.repr {
640             Repr::Os(..) => None,
641             Repr::Simple(..) => None,
642-            Repr::Custom(ref c) => Some(&*c.error),
643+            Repr::Custom(ref c) => Some(&c.error),
644         }
645     }
646
647@@ -429,12 +389,11 @@ impl Error {
648     ///     print_error(&change_error(Error::new(ErrorKind::Other, MyError::new())));
649     /// }
650     /// ```
651-    #[stable(feature = "io_error_inner", since = "1.3.0")]
652-    pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> {
653+    pub fn get_mut(&mut self) -> Option<&mut String> {
654         match self.repr {
655             Repr::Os(..) => None,
656             Repr::Simple(..) => None,
657-            Repr::Custom(ref mut c) => Some(&mut *c.error),
658+            Repr::Custom(ref mut c) => Some(&mut c.error),
659         }
660     }
661
662@@ -463,8 +422,7 @@ impl Error {
663     ///     print_error(Error::new(ErrorKind::Other, "oh no!"));
664     /// }
665     /// ```
666-    #[stable(feature = "io_error_inner", since = "1.3.0")]
667-    pub fn into_inner(self) -> Option<Box<error::Error+Send+Sync>> {
668+    pub fn into_inner(self) -> Option<String> {
669         match self.repr {
670             Repr::Os(..) => None,
671             Repr::Simple(..) => None,
672@@ -490,10 +448,9 @@ impl Error {
673     ///     print_error(Error::new(ErrorKind::AddrInUse, "oh no!"));
674     /// }
675     /// ```
676-    #[stable(feature = "rust1", since = "1.0.0")]
677     pub fn kind(&self) -> ErrorKind {
678         match self.repr {
679-            Repr::Os(code) => sys::decode_error_kind(code),
680+            Repr::Os(_code) => ErrorKind::Other,
681             Repr::Custom(ref c) => c.kind,
682             Repr::Simple(kind) => kind,
683         }
684@@ -504,21 +461,18 @@ impl fmt::Debug for Repr {
685     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
686         match *self {
687             Repr::Os(ref code) =>
688-                fmt.debug_struct("Os").field("code", code)
689-                   .field("message", &sys::os::error_string(*code)).finish(),
690+                fmt.debug_struct("Os").field("code", code).finish(),
691             Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(),
692             Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(),
693         }
694     }
695 }
696
697-#[stable(feature = "rust1", since = "1.0.0")]
698 impl fmt::Display for Error {
699     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
700         match self.repr {
701             Repr::Os(code) => {
702-                let detail = sys::os::error_string(code);
703-                write!(fmt, "{} (os error {})", detail, code)
704+                write!(fmt, "os error {}", code)
705             }
706             Repr::Custom(ref c) => c.error.fmt(fmt),
707             Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()),
708@@ -526,24 +480,6 @@ impl fmt::Display for Error {
709     }
710 }
711
712-#[stable(feature = "rust1", since = "1.0.0")]
713-impl error::Error for Error {
714-    fn description(&self) -> &str {
715-        match self.repr {
716-            Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(),
717-            Repr::Custom(ref c) => c.error.description(),
718-        }
719-    }
720-
721-    fn cause(&self) -> Option<&error::Error> {
722-        match self.repr {
723-            Repr::Os(..) => None,
724-            Repr::Simple(..) => None,
725-            Repr::Custom(ref c) => c.error.cause(),
726-        }
727-    }
728-}
729-
730 fn _assert_error_is_sync_send() {
731     fn _is_sync_send<T: Sync+Send>() {}
732     _is_sync_send::<Error>();
733diff --git a/impls.rs b/impls.rs
734index 6b26c01..0ba399b 100644
735--- a/impls.rs
736+++ b/impls.rs
737@@ -8,26 +8,31 @@
738 // option. This file may not be copied, modified, or distributed
739 // except according to those terms.
740
741-use cmp;
742-use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind};
743-use fmt;
744-use mem;
745+#[cfg(feature="alloc")] use alloc::boxed::Box;
746+use core::cmp;
747+use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind};
748+#[cfg(feature="collections")] use io::BufRead;
749+use core::fmt;
750+use core::mem;
751+#[cfg(feature="collections")] use collections::string::String;
752+#[cfg(feature="collections")] use collections::vec::Vec;
753
754 // =============================================================================
755 // Forwarding implementations
756
757-#[stable(feature = "rust1", since = "1.0.0")]
758 impl<'a, R: Read + ?Sized> Read for &'a mut R {
759     #[inline]
760     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
761         (**self).read(buf)
762     }
763
764+    #[cfg(feature="collections")]
765     #[inline]
766     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
767         (**self).read_to_end(buf)
768     }
769
770+    #[cfg(feature="collections")]
771     #[inline]
772     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
773         (**self).read_to_string(buf)
774@@ -38,7 +43,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R {
775         (**self).read_exact(buf)
776     }
777 }
778-#[stable(feature = "rust1", since = "1.0.0")]
779 impl<'a, W: Write + ?Sized> Write for &'a mut W {
780     #[inline]
781     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
782@@ -56,12 +60,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W {
783         (**self).write_fmt(fmt)
784     }
785 }
786-#[stable(feature = "rust1", since = "1.0.0")]
787 impl<'a, S: Seek + ?Sized> Seek for &'a mut S {
788     #[inline]
789     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
790 }
791-#[stable(feature = "rust1", since = "1.0.0")]
792+#[cfg(feature="collections")]
793 impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B {
794     #[inline]
795     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
796@@ -80,18 +83,20 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B {
797     }
798 }
799
800-#[stable(feature = "rust1", since = "1.0.0")]
801+#[cfg(feature="alloc")]
802 impl<R: Read + ?Sized> Read for Box<R> {
803     #[inline]
804     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
805         (**self).read(buf)
806     }
807
808+    #[cfg(feature="collections")]
809     #[inline]
810     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
811         (**self).read_to_end(buf)
812     }
813
814+    #[cfg(feature="collections")]
815     #[inline]
816     fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
817         (**self).read_to_string(buf)
818@@ -102,7 +107,7 @@ impl<R: Read + ?Sized> Read for Box<R> {
819         (**self).read_exact(buf)
820     }
821 }
822-#[stable(feature = "rust1", since = "1.0.0")]
823+#[cfg(feature="alloc")]
824 impl<W: Write + ?Sized> Write for Box<W> {
825     #[inline]
826     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { (**self).write(buf) }
827@@ -120,12 +125,12 @@ impl<W: Write + ?Sized> Write for Box<W> {
828         (**self).write_fmt(fmt)
829     }
830 }
831-#[stable(feature = "rust1", since = "1.0.0")]
832+#[cfg(feature="alloc")]
833 impl<S: Seek + ?Sized> Seek for Box<S> {
834     #[inline]
835     fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> { (**self).seek(pos) }
836 }
837-#[stable(feature = "rust1", since = "1.0.0")]
838+#[cfg(feature="collections")]
839 impl<B: BufRead + ?Sized> BufRead for Box<B> {
840     #[inline]
841     fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() }
842@@ -151,7 +156,6 @@ impl<B: BufRead + ?Sized> BufRead for Box<B> {
843 ///
844 /// Note that reading updates the slice to point to the yet unread part.
845 /// The slice will be empty when EOF is reached.
846-#[stable(feature = "rust1", since = "1.0.0")]
847 impl<'a> Read for &'a [u8] {
848     #[inline]
849     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
850@@ -175,7 +179,7 @@ impl<'a> Read for &'a [u8] {
851     }
852 }
853
854-#[stable(feature = "rust1", since = "1.0.0")]
855+#[cfg(feature="collections")]
856 impl<'a> BufRead for &'a [u8] {
857     #[inline]
858     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) }
859@@ -189,7 +193,6 @@ impl<'a> BufRead for &'a [u8] {
860 ///
861 /// Note that writing updates the slice to point to the yet unwritten part.
862 /// The slice will be empty when it has been completely overwritten.
863-#[stable(feature = "rust1", since = "1.0.0")]
864 impl<'a> Write for &'a mut [u8] {
865     #[inline]
866     fn write(&mut self, data: &[u8]) -> io::Result<usize> {
867@@ -215,7 +218,7 @@ impl<'a> Write for &'a mut [u8] {
868
869 /// Write is implemented for `Vec<u8>` by appending to the vector.
870 /// The vector will grow as needed.
871-#[stable(feature = "rust1", since = "1.0.0")]
872+#[cfg(feature="collections")]
873 impl Write for Vec<u8> {
874     #[inline]
875     fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
876diff --git a/memchr.rs b/memchr.rs
877index 3824a5f..312cf47 100644
878--- a/memchr.rs
879+++ b/memchr.rs
880@@ -11,10 +11,12 @@
881 // Original implementation taken from rust-memchr
882 // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch
883
884+pub use self::fallback::{memchr,memrchr};
885+
886 #[allow(dead_code)]
887 pub mod fallback {
888-    use cmp;
889-    use mem;
890+    use core::cmp;
891+    use core::mem;
892
893     const LO_U64: u64 = 0x0101010101010101;
894     const HI_U64: u64 = 0x8080808080808080;
895diff --git a/mod.rs b/mod.rs
896index ad9ae56..77d9ff1 100644
897--- a/mod.rs
898+++ b/mod.rs
899@@ -253,44 +253,34 @@
900 //! [`try!`]: ../macro.try.html
901 //! [`read()`]: trait.Read.html#tymethod.read
902
903-#![stable(feature = "rust1", since = "1.0.0")]
904-
905-use cmp;
906+use core::cmp;
907 use rustc_unicode::str as core_str;
908-use error as std_error;
909-use fmt;
910-use result;
911-use str;
912-use memchr;
913-
914-#[stable(feature = "rust1", since = "1.0.0")]
915-pub use self::buffered::{BufReader, BufWriter, LineWriter};
916-#[stable(feature = "rust1", since = "1.0.0")]
917-pub use self::buffered::IntoInnerError;
918-#[stable(feature = "rust1", since = "1.0.0")]
919+use core::fmt;
920+use core::iter::{Iterator};
921+use core::marker::Sized;
922+#[cfg(feature="collections")] use core::ops::{Drop, FnOnce};
923+use core::option::Option::{self, Some, None};
924+use core::result::Result::{Ok, Err};
925+use core::result;
926+#[cfg(feature="collections")] use collections::string::String;
927+use core::str;
928+#[cfg(feature="collections")] use collections::vec::Vec;
929+mod memchr;
930+
931+#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter};
932+#[cfg(feature="collections")] pub use self::buffered::IntoInnerError;
933 pub use self::cursor::Cursor;
934-#[stable(feature = "rust1", since = "1.0.0")]
935 pub use self::error::{Result, Error, ErrorKind};
936-#[stable(feature = "rust1", since = "1.0.0")]
937 pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat};
938-#[stable(feature = "rust1", since = "1.0.0")]
939-pub use self::stdio::{stdin, stdout, stderr, _print, Stdin, Stdout, Stderr};
940-#[stable(feature = "rust1", since = "1.0.0")]
941-pub use self::stdio::{StdoutLock, StderrLock, StdinLock};
942-#[unstable(feature = "libstd_io_internals", issue = "0")]
943-#[doc(no_inline, hidden)]
944-pub use self::stdio::{set_panic, set_print};
945
946 pub mod prelude;
947-mod buffered;
948+#[cfg(feature="collections")] mod buffered;
949 mod cursor;
950 mod error;
951 mod impls;
952-mod lazy;
953 mod util;
954-mod stdio;
955
956-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
957+const DEFAULT_BUF_SIZE: usize = 8 * 1024;
958
959 // A few methods below (read_to_string, read_line) will append data into a
960 // `String` buffer, but we need to be pretty careful when doing this. The
961@@ -310,6 +300,7 @@ const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
962 // 2. We're passing a raw buffer to the function `f`, and it is expected that
963 //    the function only *appends* bytes to the buffer. We'll get undefined
964 //    behavior if existing bytes are overwritten to have non-UTF-8 data.
965+#[cfg(feature="collections")]
966 fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
967     where F: FnOnce(&mut Vec<u8>) -> Result<usize>
968 {
969@@ -341,6 +332,7 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
970 // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every
971 // time is 4,500 times (!) slower than this if the reader has a very small
972 // amount of data to return.
973+#[cfg(feature="collections")]
974 fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
975     let start_len = buf.len();
976     let mut len = start_len;
977@@ -423,7 +415,6 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
978 /// # Ok(())
979 /// # }
980 /// ```
981-#[stable(feature = "rust1", since = "1.0.0")]
982 pub trait Read {
983     /// Pull some bytes from this source into the specified buffer, returning
984     /// how many bytes were read.
985@@ -473,7 +464,6 @@ pub trait Read {
986     /// # Ok(())
987     /// # }
988     /// ```
989-    #[stable(feature = "rust1", since = "1.0.0")]
990     fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
991
992     /// Read all bytes until EOF in this source, placing them into `buf`.
993@@ -515,7 +505,7 @@ pub trait Read {
994     /// # Ok(())
995     /// # }
996     /// ```
997-    #[stable(feature = "rust1", since = "1.0.0")]
998+    #[cfg(feature="collections")]
999     fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
1000         read_to_end(self, buf)
1001     }
1002@@ -553,7 +543,7 @@ pub trait Read {
1003     /// # Ok(())
1004     /// # }
1005     /// ```
1006-    #[stable(feature = "rust1", since = "1.0.0")]
1007+    #[cfg(feature="collections")]
1008     fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
1009         // Note that we do *not* call `.read_to_end()` here. We are passing
1010         // `&mut Vec<u8>` (the raw contents of `buf`) into the `read_to_end`
1011@@ -614,7 +604,6 @@ pub trait Read {
1012     /// # Ok(())
1013     /// # }
1014     /// ```
1015-    #[stable(feature = "read_exact", since = "1.6.0")]
1016     fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> {
1017         while !buf.is_empty() {
1018             match self.read(buf) {
1019@@ -666,7 +655,6 @@ pub trait Read {
1020     /// # Ok(())
1021     /// # }
1022     /// ```
1023-    #[stable(feature = "rust1", since = "1.0.0")]
1024     fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
1025
1026     /// Transforms this `Read` instance to an `Iterator` over its bytes.
1027@@ -696,7 +684,6 @@ pub trait Read {
1028     /// # Ok(())
1029     /// # }
1030     /// ```
1031-    #[stable(feature = "rust1", since = "1.0.0")]
1032     fn bytes(self) -> Bytes<Self> where Self: Sized {
1033         Bytes { inner: self }
1034     }
1035@@ -733,10 +720,6 @@ pub trait Read {
1036     /// # Ok(())
1037     /// # }
1038     /// ```
1039-    #[unstable(feature = "io", reason = "the semantics of a partial read/write \
1040-                                         of where errors happen is currently \
1041-                                         unclear and may change",
1042-               issue = "27802")]
1043     fn chars(self) -> Chars<Self> where Self: Sized {
1044         Chars { inner: self }
1045     }
1046@@ -771,7 +754,6 @@ pub trait Read {
1047     /// # Ok(())
1048     /// # }
1049     /// ```
1050-    #[stable(feature = "rust1", since = "1.0.0")]
1051     fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized {
1052         Chain { first: self, second: next, done_first: false }
1053     }
1054@@ -805,7 +787,6 @@ pub trait Read {
1055     /// # Ok(())
1056     /// # }
1057     /// ```
1058-    #[stable(feature = "rust1", since = "1.0.0")]
1059     fn take(self, limit: u64) -> Take<Self> where Self: Sized {
1060         Take { inner: self, limit: limit }
1061     }
1062@@ -845,7 +826,6 @@ pub trait Read {
1063 /// # Ok(())
1064 /// # }
1065 /// ```
1066-#[stable(feature = "rust1", since = "1.0.0")]
1067 pub trait Write {
1068     /// Write a buffer into this object, returning how many bytes were written.
1069     ///
1070@@ -885,7 +865,6 @@ pub trait Write {
1071     /// # Ok(())
1072     /// # }
1073     /// ```
1074-    #[stable(feature = "rust1", since = "1.0.0")]
1075     fn write(&mut self, buf: &[u8]) -> Result<usize>;
1076
1077     /// Flush this output stream, ensuring that all intermediately buffered
1078@@ -911,7 +890,6 @@ pub trait Write {
1079     /// # Ok(())
1080     /// # }
1081     /// ```
1082-    #[stable(feature = "rust1", since = "1.0.0")]
1083     fn flush(&mut self) -> Result<()>;
1084
1085     /// Attempts to write an entire buffer into this write.
1086@@ -938,7 +916,6 @@ pub trait Write {
1087     /// # Ok(())
1088     /// # }
1089     /// ```
1090-    #[stable(feature = "rust1", since = "1.0.0")]
1091     fn write_all(&mut self, mut buf: &[u8]) -> Result<()> {
1092         while !buf.is_empty() {
1093             match self.write(buf) {
1094@@ -990,7 +967,6 @@ pub trait Write {
1095     /// # Ok(())
1096     /// # }
1097     /// ```
1098-    #[stable(feature = "rust1", since = "1.0.0")]
1099     fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> {
1100         // Create a shim which translates a Write to a fmt::Write and saves
1101         // off I/O errors. instead of discarding them
1102@@ -1046,7 +1022,6 @@ pub trait Write {
1103     /// # Ok(())
1104     /// # }
1105     /// ```
1106-    #[stable(feature = "rust1", since = "1.0.0")]
1107     fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
1108 }
1109
1110@@ -1076,7 +1051,6 @@ pub trait Write {
1111 /// # Ok(())
1112 /// # }
1113 /// ```
1114-#[stable(feature = "rust1", since = "1.0.0")]
1115 pub trait Seek {
1116     /// Seek to an offset, in bytes, in a stream.
1117     ///
1118@@ -1092,7 +1066,6 @@ pub trait Seek {
1119     /// Seeking to a negative offset is considered an error.
1120     ///
1121     /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start
1122-    #[stable(feature = "rust1", since = "1.0.0")]
1123     fn seek(&mut self, pos: SeekFrom) -> Result<u64>;
1124 }
1125
1126@@ -1102,29 +1075,26 @@ pub trait Seek {
1127 ///
1128 /// [`Seek`]: trait.Seek.html
1129 #[derive(Copy, PartialEq, Eq, Clone, Debug)]
1130-#[stable(feature = "rust1", since = "1.0.0")]
1131 pub enum SeekFrom {
1132     /// Set the offset to the provided number of bytes.
1133-    #[stable(feature = "rust1", since = "1.0.0")]
1134-    Start(#[stable(feature = "rust1", since = "1.0.0")] u64),
1135+    Start(u64),
1136
1137     /// Set the offset to the size of this object plus the specified number of
1138     /// bytes.
1139     ///
1140     /// It is possible to seek beyond the end of an object, but it's an error to
1141     /// seek before byte 0.
1142-    #[stable(feature = "rust1", since = "1.0.0")]
1143-    End(#[stable(feature = "rust1", since = "1.0.0")] i64),
1144+    End(i64),
1145
1146     /// Set the offset to the current position plus the specified number of
1147     /// bytes.
1148     ///
1149     /// It is possible to seek beyond the end of an object, but it's an error to
1150     /// seek before byte 0.
1151-    #[stable(feature = "rust1", since = "1.0.0")]
1152-    Current(#[stable(feature = "rust1", since = "1.0.0")] i64),
1153+    Current(i64),
1154 }
1155
1156+#[cfg(feature="collections")]
1157 fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
1158                                    -> Result<usize> {
1159     let mut read = 0;
1160@@ -1204,7 +1174,7 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
1161 /// # }
1162 /// ```
1163 ///
1164-#[stable(feature = "rust1", since = "1.0.0")]
1165+#[cfg(feature="collections")]
1166 pub trait BufRead: Read {
1167     /// Fills the internal buffer of this object, returning the buffer contents.
1168     ///
1169@@ -1249,7 +1219,6 @@ pub trait BufRead: Read {
1170     /// // ensure the bytes we worked with aren't returned again later
1171     /// stdin.consume(length);
1172     /// ```
1173-    #[stable(feature = "rust1", since = "1.0.0")]
1174     fn fill_buf(&mut self) -> Result<&[u8]>;
1175
1176     /// Tells this buffer that `amt` bytes have been consumed from the buffer,
1177@@ -1271,7 +1240,6 @@ pub trait BufRead: Read {
1178     /// that method's example includes an example of `consume()`.
1179     ///
1180     /// [`fill_buf()`]: #tymethod.fill_buf
1181-    #[stable(feature = "rust1", since = "1.0.0")]
1182     fn consume(&mut self, amt: usize);
1183
1184     /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached.
1185@@ -1313,7 +1281,6 @@ pub trait BufRead: Read {
1186     /// # Ok(())
1187     /// # }
1188     /// ```
1189-    #[stable(feature = "rust1", since = "1.0.0")]
1190     fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize> {
1191         read_until(self, byte, buf)
1192     }
1193@@ -1360,7 +1327,6 @@ pub trait BufRead: Read {
1194     ///     buffer.clear();
1195     /// }
1196     /// ```
1197-    #[stable(feature = "rust1", since = "1.0.0")]
1198     fn read_line(&mut self, buf: &mut String) -> Result<usize> {
1199         // Note that we are not calling the `.read_until` method here, but
1200         // rather our hardcoded implementation. For more details as to why, see
1201@@ -1397,7 +1363,6 @@ pub trait BufRead: Read {
1202     ///     println!("{:?}", content.unwrap());
1203     /// }
1204     /// ```
1205-    #[stable(feature = "rust1", since = "1.0.0")]
1206     fn split(self, byte: u8) -> Split<Self> where Self: Sized {
1207         Split { buf: self, delim: byte }
1208     }
1209@@ -1425,7 +1390,6 @@ pub trait BufRead: Read {
1210     ///     println!("{}", line.unwrap());
1211     /// }
1212     /// ```
1213-    #[stable(feature = "rust1", since = "1.0.0")]
1214     fn lines(self) -> Lines<Self> where Self: Sized {
1215         Lines { buf: self }
1216     }
1217@@ -1437,14 +1401,12 @@ pub trait BufRead: Read {
1218 /// Please see the documentation of [`chain()`] for more details.
1219 ///
1220 /// [`chain()`]: trait.Read.html#method.chain
1221-#[stable(feature = "rust1", since = "1.0.0")]
1222 pub struct Chain<T, U> {
1223     first: T,
1224     second: U,
1225     done_first: bool,
1226 }
1227
1228-#[stable(feature = "rust1", since = "1.0.0")]
1229 impl<T: Read, U: Read> Read for Chain<T, U> {
1230     fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
1231         if !self.done_first {
1232@@ -1457,7 +1419,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
1233     }
1234 }
1235
1236-#[stable(feature = "chain_bufread", since = "1.9.0")]
1237+#[cfg(feature="collections")]
1238 impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
1239     fn fill_buf(&mut self) -> Result<&[u8]> {
1240         if !self.done_first {
1241@@ -1484,7 +1446,6 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
1242 /// Please see the documentation of [`take()`] for more details.
1243 ///
1244 /// [`take()`]: trait.Read.html#method.take
1245-#[stable(feature = "rust1", since = "1.0.0")]
1246 pub struct Take<T> {
1247     inner: T,
1248     limit: u64,
1249@@ -1518,7 +1479,6 @@ impl<T> Take<T> {
1250     /// # Ok(())
1251     /// # }
1252     /// ```
1253-    #[stable(feature = "rust1", since = "1.0.0")]
1254     pub fn limit(&self) -> u64 { self.limit }
1255
1256     /// Consumes the `Take`, returning the wrapped reader.
1257@@ -1543,13 +1503,11 @@ impl<T> Take<T> {
1258     /// # Ok(())
1259     /// # }
1260     /// ```
1261-    #[unstable(feature = "io_take_into_inner", issue = "23755")]
1262     pub fn into_inner(self) -> T {
1263         self.inner
1264     }
1265 }
1266
1267-#[stable(feature = "rust1", since = "1.0.0")]
1268 impl<T: Read> Read for Take<T> {
1269     fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
1270         // Don't call into inner reader at all at EOF because it may still block
1271@@ -1564,7 +1522,7 @@ impl<T: Read> Read for Take<T> {
1272     }
1273 }
1274
1275-#[stable(feature = "rust1", since = "1.0.0")]
1276+#[cfg(feature="collections")]
1277 impl<T: BufRead> BufRead for Take<T> {
1278     fn fill_buf(&mut self) -> Result<&[u8]> {
1279         // Don't call into inner reader at all at EOF because it may still block
1280@@ -1603,12 +1561,10 @@ fn read_one_byte(reader: &mut Read) -> Option<Result<u8>> {
1281 /// Please see the documentation of [`bytes()`] for more details.
1282 ///
1283 /// [`bytes()`]: trait.Read.html#method.bytes
1284-#[stable(feature = "rust1", since = "1.0.0")]
1285 pub struct Bytes<R> {
1286     inner: R,
1287 }
1288
1289-#[stable(feature = "rust1", since = "1.0.0")]
1290 impl<R: Read> Iterator for Bytes<R> {
1291     type Item = Result<u8>;
1292
1293@@ -1623,8 +1579,6 @@ impl<R: Read> Iterator for Bytes<R> {
1294 /// Please see the documentation of `chars()` for more details.
1295 ///
1296 /// [chars]: trait.Read.html#method.chars
1297-#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
1298-           issue = "27802")]
1299 pub struct Chars<R> {
1300     inner: R,
1301 }
1302@@ -1632,8 +1586,6 @@ pub struct Chars<R> {
1303 /// An enumeration of possible errors that can be generated from the `Chars`
1304 /// adapter.
1305 #[derive(Debug)]
1306-#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
1307-           issue = "27802")]
1308 pub enum CharsError {
1309     /// Variant representing that the underlying stream was read successfully
1310     /// but it did not contain valid utf8 data.
1311@@ -1643,8 +1595,6 @@ pub enum CharsError {
1312     Other(Error),
1313 }
1314
1315-#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
1316-           issue = "27802")]
1317 impl<R: Read> Iterator for Chars<R> {
1318     type Item = result::Result<char, CharsError>;
1319
1320@@ -1676,25 +1626,6 @@ impl<R: Read> Iterator for Chars<R> {
1321     }
1322 }
1323
1324-#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
1325-           issue = "27802")]
1326-impl std_error::Error for CharsError {
1327-    fn description(&self) -> &str {
1328-        match *self {
1329-            CharsError::NotUtf8 => "invalid utf8 encoding",
1330-            CharsError::Other(ref e) => std_error::Error::description(e),
1331-        }
1332-    }
1333-    fn cause(&self) -> Option<&std_error::Error> {
1334-        match *self {
1335-            CharsError::NotUtf8 => None,
1336-            CharsError::Other(ref e) => e.cause(),
1337-        }
1338-    }
1339-}
1340-
1341-#[unstable(feature = "io", reason = "awaiting stability of Read::chars",
1342-           issue = "27802")]
1343 impl fmt::Display for CharsError {
1344     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1345         match *self {
1346@@ -1713,13 +1644,13 @@ impl fmt::Display for CharsError {
1347 /// `BufRead`. Please see the documentation of `split()` for more details.
1348 ///
1349 /// [split]: trait.BufRead.html#method.split
1350-#[stable(feature = "rust1", since = "1.0.0")]
1351+#[cfg(feature="collections")]
1352 pub struct Split<B> {
1353     buf: B,
1354     delim: u8,
1355 }
1356
1357-#[stable(feature = "rust1", since = "1.0.0")]
1358+#[cfg(feature="collections")]
1359 impl<B: BufRead> Iterator for Split<B> {
1360     type Item = Result<Vec<u8>>;
1361
1362@@ -1744,12 +1675,12 @@ impl<B: BufRead> Iterator for Split<B> {
1363 /// `BufRead`. Please see the documentation of `lines()` for more details.
1364 ///
1365 /// [lines]: trait.BufRead.html#method.lines
1366-#[stable(feature = "rust1", since = "1.0.0")]
1367+#[cfg(feature="collections")]
1368 pub struct Lines<B> {
1369     buf: B,
1370 }
1371
1372-#[stable(feature = "rust1", since = "1.0.0")]
1373+#[cfg(feature="collections")]
1374 impl<B: BufRead> Iterator for Lines<B> {
1375     type Item = Result<String>;
1376
1377diff --git a/prelude.rs b/prelude.rs
1378index 8772d0f..49d66c9 100644
1379--- a/prelude.rs
1380+++ b/prelude.rs
1381@@ -18,7 +18,8 @@
1382 //! use std::io::prelude::*;
1383 //! ```
1384
1385-#![stable(feature = "rust1", since = "1.0.0")]
1386+pub use super::{Read, Write, Seek};
1387+#[cfg(feature="collections")] pub use super::BufRead;
1388
1389-#[stable(feature = "rust1", since = "1.0.0")]
1390-pub use super::{Read, Write, BufRead, Seek};
1391+#[cfg(feature="collections")] pub use alloc::boxed::Box;
1392+#[cfg(feature="collections")] pub use collections::vec::Vec;
1393diff --git a/util.rs b/util.rs
1394index 2c68802..93bcfc3 100644
1395--- a/util.rs
1396+++ b/util.rs
1397@@ -10,7 +10,8 @@
1398
1399 #![allow(missing_copy_implementations)]
1400
1401-use io::{self, Read, Write, ErrorKind, BufRead};
1402+use io::{self, Read, Write, ErrorKind};
1403+#[cfg(feature="collections")] use io::BufRead;
1404
1405 /// Copies the entire contents of a reader into a writer.
1406 ///
1407@@ -42,7 +43,6 @@ use io::{self, Read, Write, ErrorKind, BufRead};
1408 /// # Ok(())
1409 /// # }
1410 /// ```
1411-#[stable(feature = "rust1", since = "1.0.0")]
1412 pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
1413     where R: Read, W: Write
1414 {
1415@@ -66,7 +66,6 @@ pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<
1416 /// the documentation of `empty()` for more details.
1417 ///
1418 /// [empty]: fn.empty.html
1419-#[stable(feature = "rust1", since = "1.0.0")]
1420 pub struct Empty { _priv: () }
1421
1422 /// Constructs a new handle to an empty reader.
1423@@ -84,14 +83,12 @@ pub struct Empty { _priv: () }
1424 /// io::empty().read_to_string(&mut buffer).unwrap();
1425 /// assert!(buffer.is_empty());
1426 /// ```
1427-#[stable(feature = "rust1", since = "1.0.0")]
1428 pub fn empty() -> Empty { Empty { _priv: () } }
1429
1430-#[stable(feature = "rust1", since = "1.0.0")]
1431 impl Read for Empty {
1432     fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> { Ok(0) }
1433 }
1434-#[stable(feature = "rust1", since = "1.0.0")]
1435+#[cfg(feature="collections")]
1436 impl BufRead for Empty {
1437     fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) }
1438     fn consume(&mut self, _n: usize) {}
1439@@ -103,7 +100,6 @@ impl BufRead for Empty {
1440 /// see the documentation of `repeat()` for more details.
1441 ///
1442 /// [repeat]: fn.repeat.html
1443-#[stable(feature = "rust1", since = "1.0.0")]
1444 pub struct Repeat { byte: u8 }
1445
1446 /// Creates an instance of a reader that infinitely repeats one byte.
1447@@ -120,10 +116,8 @@ pub struct Repeat { byte: u8 }
1448 /// io::repeat(0b101).read_exact(&mut buffer).unwrap();
1449 /// assert_eq!(buffer, [0b101, 0b101, 0b101]);
1450 /// ```
1451-#[stable(feature = "rust1", since = "1.0.0")]
1452 pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } }
1453
1454-#[stable(feature = "rust1", since = "1.0.0")]
1455 impl Read for Repeat {
1456     fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
1457         for slot in &mut *buf {
1458@@ -139,7 +133,6 @@ impl Read for Repeat {
1459 /// see the documentation of `sink()` for more details.
1460 ///
1461 /// [sink]: fn.sink.html
1462-#[stable(feature = "rust1", since = "1.0.0")]
1463 pub struct Sink { _priv: () }
1464
1465 /// Creates an instance of a writer which will successfully consume all data.
1466@@ -156,10 +149,8 @@ pub struct Sink { _priv: () }
1467 /// let num_bytes = io::sink().write(&buffer).unwrap();
1468 /// assert_eq!(num_bytes, 5);
1469 /// ```
1470-#[stable(feature = "rust1", since = "1.0.0")]
1471 pub fn sink() -> Sink { Sink { _priv: () } }
1472
1473-#[stable(feature = "rust1", since = "1.0.0")]
1474 impl Write for Sink {
1475     fn write(&mut self, buf: &[u8]) -> io::Result<usize> { Ok(buf.len()) }
1476     fn flush(&mut self) -> io::Result<()> { Ok(()) }
1477