diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index fc5405ea7f69e..13d07fe9b1da2 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -898,7 +898,7 @@ pub fn copy, Q: AsRef>(from: P, to: Q) -> io::Result { let from = from.as_ref(); let to = to.as_ref(); if !from.is_file() { - return Err(Error::new(ErrorKind::InvalidInput, + return Err(Error::new(ErrorKind::InvalidParam, "the source path is not an existing file")) } diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 72743106abf6a..2d2cd737318cc 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -74,7 +74,7 @@ macro_rules! seek { }; if pos < 0 { - Err(Error::new(ErrorKind::InvalidInput, + Err(Error::new(ErrorKind::InvalidParam, "invalid seek to a negative position")) } else { self.pos = pos as u64; diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index 97c5a29d308a1..bc0e29b87b3b0 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -94,6 +94,9 @@ pub enum ErrorKind { WouldBlock, /// A parameter was incorrect. #[stable(feature = "rust1", since = "1.0.0")] + InvalidParam, + /// Invalid data were encountered in an I/O operation. + #[stable(feature = "rust1", since = "1.0.0")] InvalidInput, /// The I/O operation's timeout expired, causing it to be canceled. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index b0bf9d0f80626..f538fbb3b1af3 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -433,7 +433,7 @@ impl ToSocketAddrs for str { ($e:expr, $msg:expr) => ( match $e { Some(r) => r, - None => return Err(io::Error::new(io::ErrorKind::InvalidInput, + None => return Err(io::Error::new(io::ErrorKind::InvalidParam, $msg)), } ) diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index bff9774bcd04a..9806c4b2926d2 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -77,7 +77,7 @@ fn each_addr(addr: A, mut f: F) -> io::Result } } Err(last_err.unwrap_or_else(|| { - Error::new(ErrorKind::InvalidInput, + Error::new(ErrorKind::InvalidParam, "could not resolve to any addresses") })) } diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 28063c1edb3f7..6b7302d8c0d73 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -292,7 +292,7 @@ mod tests { match TcpStream::connect("0.0.0.0:1") { Ok(..) => panic!(), Err(e) => assert!(e.kind() == ErrorKind::ConnectionRefused || - e.kind() == ErrorKind::InvalidInput || + e.kind() == ErrorKind::InvalidParam || e.kind() == ErrorKind::AddrInUse || e.kind() == ErrorKind::AddrNotAvailable, "bad error: {} {:?}", e, e.kind()), diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 67c7096904d6f..5edb88aafbea1 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -75,7 +75,7 @@ impl UdpSocket { -> io::Result { match try!(addr.to_socket_addrs()).next() { Some(addr) => self.0.send_to(buf, &addr), - None => Err(Error::new(ErrorKind::InvalidInput, + None => Err(Error::new(ErrorKind::InvalidParam, "no addresses to send data to")), } } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 61398e16ba036..1202dd20e495c 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -448,7 +448,7 @@ impl Child { // newer process that happens to have the same (re-used) id if self.status.is_some() { return Err(Error::new( - ErrorKind::InvalidInput, + ErrorKind::InvalidParam, "invalid argument: can't kill an exited process", )) } diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 7da7071670ab6..80c56c5f1182f 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -76,7 +76,7 @@ fn sockaddr_to_addr(storage: &libc::sockaddr_storage, }))) } _ => { - Err(Error::new(ErrorKind::InvalidInput, "invalid argument")) + Err(Error::new(ErrorKind::InvalidParam, "invalid argument")) } } } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 350161c751cb8..e8e8a893dc560 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -362,7 +362,7 @@ impl DirBuilder { fn cstr(path: &Path) -> io::Result { path.as_os_str().to_cstring().ok_or( - io::Error::new(io::ErrorKind::InvalidInput, "path contained a null")) + io::Error::new(io::ErrorKind::InvalidParam, "path contained a null")) } impl FromInner for File { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index c1a4e8cee9ed4..26fb14736c096 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -60,7 +60,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { libc::EADDRINUSE => ErrorKind::AddrInUse, libc::ENOENT => ErrorKind::NotFound, libc::EINTR => ErrorKind::Interrupted, - libc::EINVAL => ErrorKind::InvalidInput, + libc::EINVAL => ErrorKind::InvalidParam, libc::ETIMEDOUT => ErrorKind::TimedOut, libc::consts::os::posix88::EEXIST => ErrorKind::AlreadyExists, diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 4c30f0f86604f..a2049a6de64dc 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -56,7 +56,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { libc::WSAECONNABORTED => ErrorKind::ConnectionAborted, libc::WSAECONNREFUSED => ErrorKind::ConnectionRefused, libc::WSAECONNRESET => ErrorKind::ConnectionReset, - libc::WSAEINVAL => ErrorKind::InvalidInput, + libc::WSAEINVAL => ErrorKind::InvalidParam, libc::WSAENOTCONN => ErrorKind::NotConnected, libc::WSAEWOULDBLOCK => ErrorKind::WouldBlock,