Skip to content

Commit 8b24964

Browse files
committed
auto merge of #13799 : m-r-r/rust/patch-std-io-standard_error, r=alexcrichton
Hello, With the latest version of Rust, calling to the function [`std::io::standard_error()`](http://static.rust-lang.org/doc/master/std/io/fn.standard_error.html) succeeds only if the value of the argument is `EndOfFile`, `IoUnavailable` or `InvalidInput`. If the function is called with another value as argument, it fails without message. Here is a piece of code that reproduces the problem: ```rust use std::io::{standard_error,EndOfFile,FileNotFound,PermissionDenied}; fn main() { println!("Error 1: {}", standard_error(EndOfFile)); // does not fail println!("Error 2: {}", standard_error(FileNotFound)); // fails println!("Error 3: {}", standard_error(PermissionDenied)); //fails } ``` This was because the `IoErrorKind` passed as argument wasn't matched against all the possible values. I added the missing branches in the `match` statement inside the function, and i removed the call to the `fail!()` macro. I rebuilt the crate with the latest `rustc` version and it seems to works.
2 parents 479b8a8 + a7b8a13 commit 8b24964

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/libstd/io/mod.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,21 @@ pub fn standard_error(kind: IoErrorKind) -> IoError {
14081408
EndOfFile => "end of file",
14091409
IoUnavailable => "I/O is unavailable",
14101410
InvalidInput => "invalid input",
1411-
_ => fail!()
1411+
OtherIoError => "unknown I/O error",
1412+
FileNotFound => "file not found",
1413+
PermissionDenied => "permission denied",
1414+
ConnectionFailed => "connection failed",
1415+
Closed => "stream is closed",
1416+
ConnectionRefused => "connection refused",
1417+
ConnectionReset => "connection reset",
1418+
ConnectionAborted => "connection aborted",
1419+
NotConnected => "not connected",
1420+
BrokenPipe => "broken pipe",
1421+
PathAlreadyExists => "file exists",
1422+
PathDoesntExist => "no such file",
1423+
MismatchedFileTypeForOperation => "mismatched file type",
1424+
ResourceUnavailable => "resource unavailable",
1425+
TimedOut => "operation timed out"
14121426
};
14131427
IoError {
14141428
kind: kind,

0 commit comments

Comments
 (0)