about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2020-12-03 20:39:33 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2021-06-18 17:45:04 +0100
commit5513faa512427524e9dbc6f333d8e46a8c397a9e (patch)
tree6965ef7d539c3deae3c7e70a4986b9591bf08e9d
parentf092501737cb7beb9f5568efa61505db769e179c (diff)
downloadrust-5513faa512427524e9dbc6f333d8e46a8c397a9e.tar.gz
rust-5513faa512427524e9dbc6f333d8e46a8c397a9e.zip
ErrorKind: Reformat the mapping table (unix)
* Sort the single matches alphabetically.
* use ErrorKind::*;

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rw-r--r--library/std/src/sys/unix/mod.rs36
1 files changed, 19 insertions, 17 deletions
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs
index 21c718825b8..387067a505b 100644
--- a/library/std/src/sys/unix/mod.rs
+++ b/library/std/src/sys/unix/mod.rs
@@ -133,29 +133,31 @@ pub use crate::sys::android::signal;
 pub use libc::signal;
 
 pub fn decode_error_kind(errno: i32) -> ErrorKind {
+    use ErrorKind::*;
     match errno as libc::c_int {
-        libc::ECONNREFUSED => ErrorKind::ConnectionRefused,
-        libc::ECONNRESET => ErrorKind::ConnectionReset,
-        libc::EPERM | libc::EACCES => ErrorKind::PermissionDenied,
-        libc::EPIPE => ErrorKind::BrokenPipe,
-        libc::ENOTCONN => ErrorKind::NotConnected,
-        libc::ECONNABORTED => ErrorKind::ConnectionAborted,
-        libc::EADDRNOTAVAIL => ErrorKind::AddrNotAvailable,
-        libc::EADDRINUSE => ErrorKind::AddrInUse,
-        libc::ENOENT => ErrorKind::NotFound,
-        libc::EINTR => ErrorKind::Interrupted,
-        libc::EINVAL => ErrorKind::InvalidInput,
-        libc::ETIMEDOUT => ErrorKind::TimedOut,
-        libc::EEXIST => ErrorKind::AlreadyExists,
-        libc::ENOSYS => ErrorKind::Unsupported,
-        libc::ENOMEM => ErrorKind::OutOfMemory,
+        libc::EADDRINUSE => AddrInUse,
+        libc::EADDRNOTAVAIL => AddrNotAvailable,
+        libc::ECONNABORTED => ConnectionAborted,
+        libc::ECONNREFUSED => ConnectionRefused,
+        libc::ECONNRESET => ConnectionReset,
+        libc::EEXIST => AlreadyExists,
+        libc::EINTR => Interrupted,
+        libc::EINVAL => InvalidInput,
+        libc::ENOENT => NotFound,
+        libc::ENOMEM => OutOfMemory,
+        libc::ENOSYS => Unsupported,
+        libc::ENOTCONN => NotConnected,
+        libc::EPIPE => BrokenPipe,
+        libc::ETIMEDOUT => TimedOut,
+
+        libc::EACCES | libc::EPERM  => PermissionDenied,
 
         // These two constants can have the same value on some systems,
         // but different values on others, so we can't use a match
         // clause
-        x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => ErrorKind::WouldBlock,
+        x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => WouldBlock,
 
-        _ => ErrorKind::Uncategorized,
+        _ => Uncategorized,
     }
 }