Skip to content

Commit 6b70ddf

Browse files
committed
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.
1 parent e117aa0 commit 6b70ddf

File tree

9 files changed

+42
-52
lines changed

9 files changed

+42
-52
lines changed

src/libstd/rt/io/extensions.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use int;
1818
use iter::Iterator;
1919
use vec;
2020
use rt::io::{Reader, Writer, Decorator};
21-
use rt::io::{read_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
21+
use rt::io::{io_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
2222
use option::{Option, Some, None};
2323
use unstable::finally::Finally;
2424
use cast;
@@ -41,17 +41,17 @@ pub trait ReaderUtil {
4141
///
4242
/// # Failure
4343
///
44-
/// Raises the same conditions as `read`. Additionally raises `read_error`
45-
/// on EOF. If `read_error` is handled then `push_bytes` may push less
44+
/// Raises the same conditions as `read`. Additionally raises `io_error`
45+
/// on EOF. If `io_error` is handled then `push_bytes` may push less
4646
/// than the requested number of bytes.
4747
fn push_bytes(&mut self, buf: &mut ~[u8], len: uint);
4848

4949
/// Reads `len` bytes and gives you back a new vector of length `len`
5050
///
5151
/// # Failure
5252
///
53-
/// Raises the same conditions as `read`. Additionally raises `read_error`
54-
/// on EOF. If `read_error` is handled then the returned vector may
53+
/// Raises the same conditions as `read`. Additionally raises `io_error`
54+
/// on EOF. If `io_error` is handled then the returned vector may
5555
/// contain less than the requested number of bytes.
5656
fn read_bytes(&mut self, len: uint) -> ~[u8];
5757

@@ -314,7 +314,7 @@ impl<T: Reader> ReaderUtil for T {
314314
total_read += nread;
315315
}
316316
None => {
317-
read_error::cond.raise(standard_error(EndOfFile));
317+
io_error::cond.raise(standard_error(EndOfFile));
318318
break;
319319
}
320320
}
@@ -334,11 +334,11 @@ impl<T: Reader> ReaderUtil for T {
334334
fn read_to_end(&mut self) -> ~[u8] {
335335
let mut buf = vec::with_capacity(DEFAULT_BUF_SIZE);
336336
let mut keep_reading = true;
337-
do read_error::cond.trap(|e| {
337+
do io_error::cond.trap(|e| {
338338
if e.kind == EndOfFile {
339339
keep_reading = false;
340340
} else {
341-
read_error::cond.raise(e)
341+
io_error::cond.raise(e)
342342
}
343343
}).inside {
344344
while keep_reading {
@@ -641,7 +641,7 @@ mod test {
641641
use cell::Cell;
642642
use rt::io::mem::{MemReader, MemWriter};
643643
use rt::io::mock::MockReader;
644-
use rt::io::{read_error, placeholder_error};
644+
use rt::io::{io_error, placeholder_error};
645645

646646
#[test]
647647
fn read_byte() {
@@ -681,10 +681,10 @@ mod test {
681681
fn read_byte_error() {
682682
let mut reader = MockReader::new();
683683
reader.read = |_| {
684-
read_error::cond.raise(placeholder_error());
684+
io_error::cond.raise(placeholder_error());
685685
None
686686
};
687-
do read_error::cond.trap(|_| {
687+
do io_error::cond.trap(|_| {
688688
}).inside {
689689
let byte = reader.read_byte();
690690
assert!(byte == None);
@@ -722,11 +722,11 @@ mod test {
722722
fn bytes_error() {
723723
let mut reader = MockReader::new();
724724
reader.read = |_| {
725-
read_error::cond.raise(placeholder_error());
725+
io_error::cond.raise(placeholder_error());
726726
None
727727
};
728728
let mut it = reader.bytes();
729-
do read_error::cond.trap(|_| ()).inside {
729+
do io_error::cond.trap(|_| ()).inside {
730730
let byte = it.next();
731731
assert!(byte == None);
732732
}
@@ -765,7 +765,7 @@ mod test {
765765
#[test]
766766
fn read_bytes_eof() {
767767
let mut reader = MemReader::new(~[10, 11]);
768-
do read_error::cond.trap(|_| {
768+
do io_error::cond.trap(|_| {
769769
}).inside {
770770
assert!(reader.read_bytes(4) == ~[10, 11]);
771771
}
@@ -806,7 +806,7 @@ mod test {
806806
fn push_bytes_eof() {
807807
let mut reader = MemReader::new(~[10, 11]);
808808
let mut buf = ~[8, 9];
809-
do read_error::cond.trap(|_| {
809+
do io_error::cond.trap(|_| {
810810
}).inside {
811811
reader.push_bytes(&mut buf, 4);
812812
assert!(buf == ~[8, 9, 10, 11]);
@@ -824,13 +824,13 @@ mod test {
824824
buf[0] = 10;
825825
Some(1)
826826
} else {
827-
read_error::cond.raise(placeholder_error());
827+
io_error::cond.raise(placeholder_error());
828828
None
829829
}
830830
}
831831
};
832832
let mut buf = ~[8, 9];
833-
do read_error::cond.trap(|_| { } ).inside {
833+
do io_error::cond.trap(|_| { } ).inside {
834834
reader.push_bytes(&mut buf, 4);
835835
}
836836
assert!(buf == ~[8, 9, 10]);
@@ -850,7 +850,7 @@ mod test {
850850
buf[0] = 10;
851851
Some(1)
852852
} else {
853-
read_error::cond.raise(placeholder_error());
853+
io_error::cond.raise(placeholder_error());
854854
None
855855
}
856856
}
@@ -903,7 +903,7 @@ mod test {
903903
buf[1] = 11;
904904
Some(2)
905905
} else {
906-
read_error::cond.raise(placeholder_error());
906+
io_error::cond.raise(placeholder_error());
907907
None
908908
}
909909
}

src/libstd/rt/io/file.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on a `ToCStr` object. This trait is already defined for common
1919
objects such as strings and `Path` instances.
2020
2121
All operations in this module, including those as part of `FileStream` et al
22-
block the task during execution. Most will raise `std::rt::io::{io_error,read_error}`
22+
block the task during execution. Most will raise `std::rt::io::{io_error,io_error}`
2323
conditions in the event of failure.
2424
2525
Also included in this module are the `FileInfo` and `DirectoryInfo` traits. When
@@ -35,7 +35,7 @@ use c_str::ToCStr;
3535
use super::{Reader, Writer, Seek};
3636
use super::{SeekStyle, Read, Write};
3737
use rt::rtio::{RtioFileStream, IoFactory, with_local_io};
38-
use rt::io::{io_error, read_error, EndOfFile,
38+
use rt::io::{io_error, EndOfFile,
3939
FileMode, FileAccess, FileStat, IoError,
4040
PathAlreadyExists, PathDoesntExist,
4141
MismatchedFileTypeForOperation, ignore_io_error};
@@ -361,7 +361,7 @@ impl Reader for FileStream {
361361
Err(ioerr) => {
362362
// EOF is indicated by returning None
363363
if ioerr.kind != EndOfFile {
364-
read_error::cond.raise(ioerr);
364+
io_error::cond.raise(ioerr);
365365
}
366366
return None;
367367
}
@@ -388,7 +388,7 @@ impl Writer for FileStream {
388388
match self.fd.flush() {
389389
Ok(_) => (),
390390
Err(ioerr) => {
391-
read_error::cond.raise(ioerr);
391+
io_error::cond.raise(ioerr);
392392
}
393393
}
394394
}
@@ -401,7 +401,7 @@ impl Seek for FileStream {
401401
match res {
402402
Ok(cursor) => cursor,
403403
Err(ioerr) => {
404-
read_error::cond.raise(ioerr);
404+
io_error::cond.raise(ioerr);
405405
return -1;
406406
}
407407
}
@@ -415,7 +415,7 @@ impl Seek for FileStream {
415415
()
416416
},
417417
Err(ioerr) => {
418-
read_error::cond.raise(ioerr);
418+
io_error::cond.raise(ioerr);
419419
}
420420
}
421421
}

src/libstd/rt/io/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,6 @@ condition! {
404404
pub io_error: IoError -> ();
405405
}
406406

407-
// XXX: Can't put doc comments on macros
408-
// Raised by `read` on error
409-
condition! {
410-
pub read_error: IoError -> ();
411-
}
412-
413407
/// Helper for wrapper calls where you want to
414408
/// ignore any io_errors that might be raised
415409
pub fn ignore_io_error<T>(cb: &fn() -> T) -> T {
@@ -429,7 +423,7 @@ pub trait Reader {
429423
///
430424
/// # Failure
431425
///
432-
/// Raises the `read_error` condition on error. If the condition
426+
/// Raises the `io_error` condition on error. If the condition
433427
/// is handled then no guarantee is made about the number of bytes
434428
/// read and the contents of `buf`. If the condition is handled
435429
/// returns `None` (XXX see below).

src/libstd/rt/io/net/tcp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use option::{Option, Some, None};
1212
use result::{Ok, Err};
1313
use rt::io::net::ip::SocketAddr;
1414
use rt::io::{Reader, Writer, Listener, Acceptor};
15-
use rt::io::{io_error, read_error, EndOfFile};
15+
use rt::io::{io_error, EndOfFile};
1616
use rt::rtio::{IoFactory, with_local_io,
1717
RtioSocket, RtioTcpListener, RtioTcpAcceptor, RtioTcpStream};
1818

@@ -67,7 +67,7 @@ impl Reader for TcpStream {
6767
Err(ioerr) => {
6868
// EOF is indicated by returning None
6969
if ioerr.kind != EndOfFile {
70-
read_error::cond.raise(ioerr);
70+
io_error::cond.raise(ioerr);
7171
}
7272
return None;
7373
}
@@ -308,7 +308,7 @@ mod test {
308308
let mut buf = [0];
309309
let nread = stream.read(buf);
310310
assert!(nread.is_none());
311-
do read_error::cond.trap(|e| {
311+
do io_error::cond.trap(|e| {
312312
if cfg!(windows) {
313313
assert_eq!(e.kind, NotConnected);
314314
} else {
@@ -343,7 +343,7 @@ mod test {
343343
let mut buf = [0];
344344
let nread = stream.read(buf);
345345
assert!(nread.is_none());
346-
do read_error::cond.trap(|e| {
346+
do io_error::cond.trap(|e| {
347347
if cfg!(windows) {
348348
assert_eq!(e.kind, NotConnected);
349349
} else {

src/libstd/rt/io/net/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use option::{Option, Some, None};
1212
use result::{Ok, Err};
1313
use rt::io::net::ip::SocketAddr;
1414
use rt::io::{Reader, Writer};
15-
use rt::io::{io_error, read_error, EndOfFile};
15+
use rt::io::{io_error, EndOfFile};
1616
use rt::rtio::{RtioSocket, RtioUdpSocket, IoFactory, with_local_io};
1717

1818
pub struct UdpSocket {
@@ -38,7 +38,7 @@ impl UdpSocket {
3838
Err(ioerr) => {
3939
// EOF is indicated by returning None
4040
if ioerr.kind != EndOfFile {
41-
read_error::cond.raise(ioerr);
41+
io_error::cond.raise(ioerr);
4242
}
4343
None
4444
}

src/libstd/rt/io/option.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
use option::*;
1818
use super::{Reader, Writer, Listener, Acceptor, Seek, SeekStyle};
19-
use super::{standard_error, PreviousIoError, io_error, read_error, IoError};
19+
use super::{standard_error, PreviousIoError, io_error, IoError};
2020

2121
fn prev_io_error() -> IoError {
2222
standard_error(PreviousIoError)
@@ -43,7 +43,7 @@ impl<R: Reader> Reader for Option<R> {
4343
match *self {
4444
Some(ref mut reader) => reader.read(buf),
4545
None => {
46-
read_error::cond.raise(prev_io_error());
46+
io_error::cond.raise(prev_io_error());
4747
None
4848
}
4949
}
@@ -107,7 +107,7 @@ mod test {
107107
use option::*;
108108
use super::super::mem::*;
109109
use rt::test::*;
110-
use super::super::{PreviousIoError, io_error, read_error};
110+
use super::super::{PreviousIoError, io_error, io_error};
111111

112112
#[test]
113113
fn test_option_writer() {
@@ -161,7 +161,7 @@ mod test {
161161
let mut buf = [];
162162

163163
let mut called = false;
164-
do read_error::cond.trap(|err| {
164+
do io_error::cond.trap(|err| {
165165
assert_eq!(err.kind, PreviousIoError);
166166
called = true;
167167
}).inside {

src/libstd/rt/io/pipe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use prelude::*;
1717
use super::{Reader, Writer};
18-
use rt::io::{io_error, read_error, EndOfFile};
18+
use rt::io::{io_error, EndOfFile};
1919
use rt::rtio::RtioPipe;
2020

2121
pub struct PipeStream {
@@ -35,7 +35,7 @@ impl Reader for PipeStream {
3535
Err(ioerr) => {
3636
// EOF is indicated by returning None
3737
if ioerr.kind != EndOfFile {
38-
read_error::cond.raise(ioerr);
38+
io_error::cond.raise(ioerr);
3939
}
4040
return None;
4141
}

src/libsyntax/ext/source_util.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
9393
let file = get_single_str_from_tts(cx, sp, tts, "include_str!");
9494
let file = res_rel_file(cx, sp, &Path::new(file));
9595
let mut error = None;
96-
let bytes = do io::read_error::cond.trap(|e| error = Some(e)).inside {
96+
let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside {
9797
file.open_reader(io::Open).read_to_end()
9898
};
9999
match error {
@@ -120,10 +120,8 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
120120
let file = res_rel_file(cx, sp, &Path::new(file));
121121

122122
let mut error = None;
123-
let bytes = do io::read_error::cond.trap(|e| error = Some(e)).inside {
124-
do io::io_error::cond.trap(|e| error = Some(e)).inside {
125-
file.open_reader(io::Open).read_to_end()
126-
}
123+
let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside {
124+
file.open_reader(io::Open).read_to_end()
127125
};
128126
match error {
129127
Some(e) => {

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<Span>)
271271
};
272272
let mut error = None;
273273
let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside {
274-
do io::read_error::cond.trap(|e| error = Some(e)).inside {
275-
path.open_reader(io::Open).read_to_end()
276-
}
274+
path.open_reader(io::Open).read_to_end()
277275
};
278276
match error {
279277
Some(e) => {

0 commit comments

Comments
 (0)