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