about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-10-18 11:52:23 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-10-24 14:21:57 -0700
commit6b70ddfba1ed5fca7fa67e5f2d2691e9c667d3a3 (patch)
treec5f2dbd75d45048ff68121ac870bde1ae34d2cd3 /src/libstd/rt
parente117aa0e2a4121aab101cb7526a5e79812bfb76e (diff)
downloadrust-6b70ddfba1ed5fca7fa67e5f2d2691e9c667d3a3.tar.gz
rust-6b70ddfba1ed5fca7fa67e5f2d2691e9c667d3a3.zip
Remove io::read_error
The general idea is to remove conditions completely from I/O, so in the meantime
remove the read_error condition to mean the same thing as the io_error condition.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/io/extensions.rs38
-rw-r--r--src/libstd/rt/io/file.rs12
-rw-r--r--src/libstd/rt/io/mod.rs8
-rw-r--r--src/libstd/rt/io/net/tcp.rs8
-rw-r--r--src/libstd/rt/io/net/udp.rs4
-rw-r--r--src/libstd/rt/io/option.rs8
-rw-r--r--src/libstd/rt/io/pipe.rs4
7 files changed, 38 insertions, 44 deletions
diff --git a/src/libstd/rt/io/extensions.rs b/src/libstd/rt/io/extensions.rs
index 99634b532b0..c77e3b91609 100644
--- a/src/libstd/rt/io/extensions.rs
+++ b/src/libstd/rt/io/extensions.rs
@@ -18,7 +18,7 @@ use int;
 use iter::Iterator;
 use vec;
 use rt::io::{Reader, Writer, Decorator};
-use rt::io::{read_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
+use rt::io::{io_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
 use option::{Option, Some, None};
 use unstable::finally::Finally;
 use cast;
@@ -41,8 +41,8 @@ pub trait ReaderUtil {
     ///
     /// # Failure
     ///
-    /// Raises the same conditions as `read`. Additionally raises `read_error`
-    /// on EOF. If `read_error` is handled then `push_bytes` may push less
+    /// Raises the same conditions as `read`. Additionally raises `io_error`
+    /// on EOF. If `io_error` is handled then `push_bytes` may push less
     /// than the requested number of bytes.
     fn push_bytes(&mut self, buf: &mut ~[u8], len: uint);
 
@@ -50,8 +50,8 @@ pub trait ReaderUtil {
     ///
     /// # Failure
     ///
-    /// Raises the same conditions as `read`. Additionally raises `read_error`
-    /// on EOF. If `read_error` is handled then the returned vector may
+    /// Raises the same conditions as `read`. Additionally raises `io_error`
+    /// on EOF. If `io_error` is handled then the returned vector may
     /// contain less than the requested number of bytes.
     fn read_bytes(&mut self, len: uint) -> ~[u8];
 
@@ -314,7 +314,7 @@ impl<T: Reader> ReaderUtil for T {
                             total_read += nread;
                         }
                         None => {
-                            read_error::cond.raise(standard_error(EndOfFile));
+                            io_error::cond.raise(standard_error(EndOfFile));
                             break;
                         }
                     }
@@ -334,11 +334,11 @@ impl<T: Reader> ReaderUtil for T {
     fn read_to_end(&mut self) -> ~[u8] {
         let mut buf = vec::with_capacity(DEFAULT_BUF_SIZE);
         let mut keep_reading = true;
-        do read_error::cond.trap(|e| {
+        do io_error::cond.trap(|e| {
             if e.kind == EndOfFile {
                 keep_reading = false;
             } else {
-                read_error::cond.raise(e)
+                io_error::cond.raise(e)
             }
         }).inside {
             while keep_reading {
@@ -641,7 +641,7 @@ mod test {
     use cell::Cell;
     use rt::io::mem::{MemReader, MemWriter};
     use rt::io::mock::MockReader;
-    use rt::io::{read_error, placeholder_error};
+    use rt::io::{io_error, placeholder_error};
 
     #[test]
     fn read_byte() {
@@ -681,10 +681,10 @@ mod test {
     fn read_byte_error() {
         let mut reader = MockReader::new();
         reader.read = |_| {
-            read_error::cond.raise(placeholder_error());
+            io_error::cond.raise(placeholder_error());
             None
         };
-        do read_error::cond.trap(|_| {
+        do io_error::cond.trap(|_| {
         }).inside {
             let byte = reader.read_byte();
             assert!(byte == None);
@@ -722,11 +722,11 @@ mod test {
     fn bytes_error() {
         let mut reader = MockReader::new();
         reader.read = |_| {
-            read_error::cond.raise(placeholder_error());
+            io_error::cond.raise(placeholder_error());
             None
         };
         let mut it = reader.bytes();
-        do read_error::cond.trap(|_| ()).inside {
+        do io_error::cond.trap(|_| ()).inside {
             let byte = it.next();
             assert!(byte == None);
         }
@@ -765,7 +765,7 @@ mod test {
     #[test]
     fn read_bytes_eof() {
         let mut reader = MemReader::new(~[10, 11]);
-        do read_error::cond.trap(|_| {
+        do io_error::cond.trap(|_| {
         }).inside {
             assert!(reader.read_bytes(4) == ~[10, 11]);
         }
@@ -806,7 +806,7 @@ mod test {
     fn push_bytes_eof() {
         let mut reader = MemReader::new(~[10, 11]);
         let mut buf = ~[8, 9];
-        do read_error::cond.trap(|_| {
+        do io_error::cond.trap(|_| {
         }).inside {
             reader.push_bytes(&mut buf, 4);
             assert!(buf == ~[8, 9, 10, 11]);
@@ -824,13 +824,13 @@ mod test {
                     buf[0] = 10;
                     Some(1)
                 } else {
-                    read_error::cond.raise(placeholder_error());
+                    io_error::cond.raise(placeholder_error());
                     None
                 }
             }
         };
         let mut buf = ~[8, 9];
-        do read_error::cond.trap(|_| { } ).inside {
+        do io_error::cond.trap(|_| { } ).inside {
             reader.push_bytes(&mut buf, 4);
         }
         assert!(buf == ~[8, 9, 10]);
@@ -850,7 +850,7 @@ mod test {
                     buf[0] = 10;
                     Some(1)
                 } else {
-                    read_error::cond.raise(placeholder_error());
+                    io_error::cond.raise(placeholder_error());
                     None
                 }
             }
@@ -903,7 +903,7 @@ mod test {
                     buf[1] = 11;
                     Some(2)
                 } else {
-                    read_error::cond.raise(placeholder_error());
+                    io_error::cond.raise(placeholder_error());
                     None
                 }
             }
diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs
index 0bd0213b5b0..381fa9f2d07 100644
--- a/src/libstd/rt/io/file.rs
+++ b/src/libstd/rt/io/file.rs
@@ -19,7 +19,7 @@ on a `ToCStr` object. This trait is already defined for common
 objects such as strings and `Path` instances.
 
 All operations in this module, including those as part of `FileStream` et al
-block the task during execution. Most will raise `std::rt::io::{io_error,read_error}`
+block the task during execution. Most will raise `std::rt::io::{io_error,io_error}`
 conditions in the event of failure.
 
 Also included in this module are the `FileInfo` and `DirectoryInfo` traits. When
@@ -35,7 +35,7 @@ use c_str::ToCStr;
 use super::{Reader, Writer, Seek};
 use super::{SeekStyle, Read, Write};
 use rt::rtio::{RtioFileStream, IoFactory, with_local_io};
-use rt::io::{io_error, read_error, EndOfFile,
+use rt::io::{io_error, EndOfFile,
             FileMode, FileAccess, FileStat, IoError,
             PathAlreadyExists, PathDoesntExist,
             MismatchedFileTypeForOperation, ignore_io_error};
@@ -361,7 +361,7 @@ impl Reader for FileStream {
             Err(ioerr) => {
                 // EOF is indicated by returning None
                 if ioerr.kind != EndOfFile {
-                    read_error::cond.raise(ioerr);
+                    io_error::cond.raise(ioerr);
                 }
                 return None;
             }
@@ -388,7 +388,7 @@ impl Writer for FileStream {
         match self.fd.flush() {
             Ok(_) => (),
             Err(ioerr) => {
-                read_error::cond.raise(ioerr);
+                io_error::cond.raise(ioerr);
             }
         }
     }
@@ -401,7 +401,7 @@ impl Seek for FileStream {
         match res {
             Ok(cursor) => cursor,
             Err(ioerr) => {
-                read_error::cond.raise(ioerr);
+                io_error::cond.raise(ioerr);
                 return -1;
             }
         }
@@ -415,7 +415,7 @@ impl Seek for FileStream {
                 ()
             },
             Err(ioerr) => {
-                read_error::cond.raise(ioerr);
+                io_error::cond.raise(ioerr);
             }
         }
     }
diff --git a/src/libstd/rt/io/mod.rs b/src/libstd/rt/io/mod.rs
index 240210880bf..7f5b01bb1ec 100644
--- a/src/libstd/rt/io/mod.rs
+++ b/src/libstd/rt/io/mod.rs
@@ -404,12 +404,6 @@ condition! {
     pub io_error: IoError -> ();
 }
 
-// XXX: Can't put doc comments on macros
-// Raised by `read` on error
-condition! {
-    pub read_error: IoError -> ();
-}
-
 /// Helper for wrapper calls where you want to
 /// ignore any io_errors that might be raised
 pub fn ignore_io_error<T>(cb: &fn() -> T) -> T {
@@ -429,7 +423,7 @@ pub trait Reader {
     ///
     /// # Failure
     ///
-    /// Raises the `read_error` condition on error. If the condition
+    /// Raises the `io_error` condition on error. If the condition
     /// is handled then no guarantee is made about the number of bytes
     /// read and the contents of `buf`. If the condition is handled
     /// returns `None` (XXX see below).
diff --git a/src/libstd/rt/io/net/tcp.rs b/src/libstd/rt/io/net/tcp.rs
index 21f98c27296..4e841b36a5d 100644
--- a/src/libstd/rt/io/net/tcp.rs
+++ b/src/libstd/rt/io/net/tcp.rs
@@ -12,7 +12,7 @@ use option::{Option, Some, None};
 use result::{Ok, Err};
 use rt::io::net::ip::SocketAddr;
 use rt::io::{Reader, Writer, Listener, Acceptor};
-use rt::io::{io_error, read_error, EndOfFile};
+use rt::io::{io_error, EndOfFile};
 use rt::rtio::{IoFactory, with_local_io,
                RtioSocket, RtioTcpListener, RtioTcpAcceptor, RtioTcpStream};
 
@@ -67,7 +67,7 @@ impl Reader for TcpStream {
             Err(ioerr) => {
                 // EOF is indicated by returning None
                 if ioerr.kind != EndOfFile {
-                    read_error::cond.raise(ioerr);
+                    io_error::cond.raise(ioerr);
                 }
                 return None;
             }
@@ -308,7 +308,7 @@ mod test {
                 let mut buf = [0];
                 let nread = stream.read(buf);
                 assert!(nread.is_none());
-                do read_error::cond.trap(|e| {
+                do io_error::cond.trap(|e| {
                     if cfg!(windows) {
                         assert_eq!(e.kind, NotConnected);
                     } else {
@@ -343,7 +343,7 @@ mod test {
                 let mut buf = [0];
                 let nread = stream.read(buf);
                 assert!(nread.is_none());
-                do read_error::cond.trap(|e| {
+                do io_error::cond.trap(|e| {
                     if cfg!(windows) {
                         assert_eq!(e.kind, NotConnected);
                     } else {
diff --git a/src/libstd/rt/io/net/udp.rs b/src/libstd/rt/io/net/udp.rs
index eee5dce7b6c..2e4ae95d98e 100644
--- a/src/libstd/rt/io/net/udp.rs
+++ b/src/libstd/rt/io/net/udp.rs
@@ -12,7 +12,7 @@ use option::{Option, Some, None};
 use result::{Ok, Err};
 use rt::io::net::ip::SocketAddr;
 use rt::io::{Reader, Writer};
-use rt::io::{io_error, read_error, EndOfFile};
+use rt::io::{io_error, EndOfFile};
 use rt::rtio::{RtioSocket, RtioUdpSocket, IoFactory, with_local_io};
 
 pub struct UdpSocket {
@@ -38,7 +38,7 @@ impl UdpSocket {
             Err(ioerr) => {
                 // EOF is indicated by returning None
                 if ioerr.kind != EndOfFile {
-                    read_error::cond.raise(ioerr);
+                    io_error::cond.raise(ioerr);
                 }
                 None
             }
diff --git a/src/libstd/rt/io/option.rs b/src/libstd/rt/io/option.rs
index ecfc4a832bf..52699964b62 100644
--- a/src/libstd/rt/io/option.rs
+++ b/src/libstd/rt/io/option.rs
@@ -16,7 +16,7 @@
 
 use option::*;
 use super::{Reader, Writer, Listener, Acceptor, Seek, SeekStyle};
-use super::{standard_error, PreviousIoError, io_error, read_error, IoError};
+use super::{standard_error, PreviousIoError, io_error, IoError};
 
 fn prev_io_error() -> IoError {
     standard_error(PreviousIoError)
@@ -43,7 +43,7 @@ impl<R: Reader> Reader for Option<R> {
         match *self {
             Some(ref mut reader) => reader.read(buf),
             None => {
-                read_error::cond.raise(prev_io_error());
+                io_error::cond.raise(prev_io_error());
                 None
             }
         }
@@ -107,7 +107,7 @@ mod test {
     use option::*;
     use super::super::mem::*;
     use rt::test::*;
-    use super::super::{PreviousIoError, io_error, read_error};
+    use super::super::{PreviousIoError, io_error, io_error};
 
     #[test]
     fn test_option_writer() {
@@ -161,7 +161,7 @@ mod test {
         let mut buf = [];
 
         let mut called = false;
-        do read_error::cond.trap(|err| {
+        do io_error::cond.trap(|err| {
             assert_eq!(err.kind, PreviousIoError);
             called = true;
         }).inside {
diff --git a/src/libstd/rt/io/pipe.rs b/src/libstd/rt/io/pipe.rs
index c15fbc79da9..eba58b97c4d 100644
--- a/src/libstd/rt/io/pipe.rs
+++ b/src/libstd/rt/io/pipe.rs
@@ -15,7 +15,7 @@
 
 use prelude::*;
 use super::{Reader, Writer};
-use rt::io::{io_error, read_error, EndOfFile};
+use rt::io::{io_error, EndOfFile};
 use rt::rtio::RtioPipe;
 
 pub struct PipeStream {
@@ -35,7 +35,7 @@ impl Reader for PipeStream {
             Err(ioerr) => {
                 // EOF is indicated by returning None
                 if ioerr.kind != EndOfFile {
-                    read_error::cond.raise(ioerr);
+                    io_error::cond.raise(ioerr);
                 }
                 return None;
             }