]> git.lizzy.rs Git - rust.git/commitdiff
Remove io::read_error
authorAlex Crichton <alex@alexcrichton.com>
Fri, 18 Oct 2013 18:52:23 +0000 (11:52 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 24 Oct 2013 21:21:57 +0000 (14:21 -0700)
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.

src/libstd/rt/io/extensions.rs
src/libstd/rt/io/file.rs
src/libstd/rt/io/mod.rs
src/libstd/rt/io/net/tcp.rs
src/libstd/rt/io/net/udp.rs
src/libstd/rt/io/option.rs
src/libstd/rt/io/pipe.rs
src/libsyntax/ext/source_util.rs
src/libsyntax/parse/mod.rs

index 99634b532b082c6962d27f05cc09cf3dfa237ddd..c77e3b91609901a134fabb2a5c82e0d7c6078b48 100644 (file)
@@ -18,7 +18,7 @@
 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 @@ fn push_bytes(&mut self, buf: &mut ~[u8], len: uint) {
                             total_read += nread;
                         }
                         None => {
-                            read_error::cond.raise(standard_error(EndOfFile));
+                            io_error::cond.raise(standard_error(EndOfFile));
                             break;
                         }
                     }
@@ -334,11 +334,11 @@ fn read_bytes(&mut self, len: uint) -> ~[u8] {
     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 @@ fn read_byte_eof() {
     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 @@ fn bytes_eof() {
     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 @@ fn read_bytes_partial() {
     #[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 @@ fn push_bytes_partial() {
     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 @@ fn push_bytes_error() {
                     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 @@ fn push_bytes_fail_reset_len() {
                     buf[0] = 10;
                     Some(1)
                 } else {
-                    read_error::cond.raise(placeholder_error());
+                    io_error::cond.raise(placeholder_error());
                     None
                 }
             }
@@ -903,7 +903,7 @@ fn read_to_end_error() {
                     buf[1] = 11;
                     Some(2)
                 } else {
-                    read_error::cond.raise(placeholder_error());
+                    io_error::cond.raise(placeholder_error());
                     None
                 }
             }
index 0bd0213b5b06ee0d5282c58fe4c6e7a03a676bdc..381fa9f2d073a7c3433cc97100ee423ee181811a 100644 (file)
@@ -19,7 +19,7 @@
 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 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 @@ fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
             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 @@ fn flush(&mut self) {
         match self.fd.flush() {
             Ok(_) => (),
             Err(ioerr) => {
-                read_error::cond.raise(ioerr);
+                io_error::cond.raise(ioerr);
             }
         }
     }
@@ -401,7 +401,7 @@ fn tell(&self) -> u64 {
         match res {
             Ok(cursor) => cursor,
             Err(ioerr) => {
-                read_error::cond.raise(ioerr);
+                io_error::cond.raise(ioerr);
                 return -1;
             }
         }
@@ -415,7 +415,7 @@ fn seek(&mut self, pos: i64, style: SeekStyle) {
                 ()
             },
             Err(ioerr) => {
-                read_error::cond.raise(ioerr);
+                io_error::cond.raise(ioerr);
             }
         }
     }
index 240210880bfab669fa86dadfd5dc346fc9b3fa3e..7f5b01bb1ece9c94f82f9714daa7cde7e6450331 100644 (file)
@@ -404,12 +404,6 @@ fn to_str(&self) -> ~str {
     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).
index 21f98c272968f135a9ff2b826b89578bbdda1651..4e841b36a5d3739d22578cb7077a6a09c845450a 100644 (file)
@@ -12,7 +12,7 @@
 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 @@ fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
             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 @@ fn read_eof_twice_ip4() {
                 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 @@ fn read_eof_twice_ip6() {
                 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 {
index eee5dce7b6c688ee91546b631fdf5e64cdfb0bc1..2e4ae95d98eea83f656953997d9a590cb2bb3893 100644 (file)
@@ -12,7 +12,7 @@
 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 @@ pub fn recvfrom(&mut self, buf: &mut [u8]) -> Option<(uint, SocketAddr)> {
             Err(ioerr) => {
                 // EOF is indicated by returning None
                 if ioerr.kind != EndOfFile {
-                    read_error::cond.raise(ioerr);
+                    io_error::cond.raise(ioerr);
                 }
                 None
             }
index ecfc4a832bfb5f5ae9d31f842c0e0af21f05a0e4..52699964b62418e17273570bb42ecc24956254f2 100644 (file)
@@ -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 @@ fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
         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 @@ fn test_option_reader_error() {
         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 {
index c15fbc79da9f6d85618d469200afa3eea22f794a..eba58b97c4df453d002d9f57b56eac2e038fcbe7 100644 (file)
@@ -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 @@ fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
             Err(ioerr) => {
                 // EOF is indicated by returning None
                 if ioerr.kind != EndOfFile {
-                    read_error::cond.raise(ioerr);
+                    io_error::cond.raise(ioerr);
                 }
                 return None;
             }
index df177cf75dc72f9d024d46982602342c660a28fb..047fc541ba8b37e3509882c72ee2c1a76649839d 100644 (file)
@@ -93,7 +93,7 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
     let file = get_single_str_from_tts(cx, sp, tts, "include_str!");
     let file = res_rel_file(cx, sp, &Path::new(file));
     let mut error = None;
-    let bytes = do io::read_error::cond.trap(|e| error = Some(e)).inside {
+    let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside {
         file.open_reader(io::Open).read_to_end()
     };
     match error {
@@ -120,10 +120,8 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
     let file = res_rel_file(cx, sp, &Path::new(file));
 
     let mut error = None;
-    let bytes = do io::read_error::cond.trap(|e| error = Some(e)).inside {
-        do io::io_error::cond.trap(|e| error = Some(e)).inside {
-            file.open_reader(io::Open).read_to_end()
-        }
+    let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside {
+        file.open_reader(io::Open).read_to_end()
     };
     match error {
         Some(e) => {
index 93e5d3dd7727f0dba23fcc960cda7dd4d17db8a1..fad9eab75420042877630cfcd5ff59375e277992 100644 (file)
@@ -271,9 +271,7 @@ pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<Span>)
     };
     let mut error = None;
     let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside {
-        do io::read_error::cond.trap(|e| error = Some(e)).inside {
-            path.open_reader(io::Open).read_to_end()
-        }
+        path.open_reader(io::Open).read_to_end()
     };
     match error {
         Some(e) => {