Skip to content

Commit 7d50cbc

Browse files
committed
std::io: New ErrorKind value InvalidData
This takes the cases from InvalidInput where a data format error was encountered. This is different from the documented semantics of InvalidInput, which more likely indicate a programming error.
1 parent 4423748 commit 7d50cbc

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/libstd/io/error.rs

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ pub enum ErrorKind {
9595
/// A parameter was incorrect.
9696
#[stable(feature = "rust1", since = "1.0.0")]
9797
InvalidInput,
98+
/// Invalid data encountered.
99+
#[stable(feature = "rust1", since = "1.0.0")]
100+
InvalidData,
98101
/// The I/O operation's timeout expired, causing it to be canceled.
99102
#[stable(feature = "rust1", since = "1.0.0")]
100103
TimedOut,

src/libstd/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
8181
let ret = f(g.s);
8282
if str::from_utf8(&g.s[g.len..]).is_err() {
8383
ret.and_then(|_| {
84-
Err(Error::new(ErrorKind::InvalidInput,
84+
Err(Error::new(ErrorKind::InvalidData,
8585
"stream did not contain valid UTF-8"))
8686
})
8787
} else {

src/libstd/sys/windows/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ impl Output {
170170
}
171171

172172
fn invalid_encoding() -> io::Error {
173-
io::Error::new(io::ErrorKind::InvalidInput, "text was not valid unicode")
173+
io::Error::new(io::ErrorKind::InvalidData, "text was not valid unicode")
174174
}

0 commit comments

Comments
 (0)