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