diff --git a/library/std/src/sys/io/error/unix.rs b/library/std/src/sys/io/error/unix.rs index c545558c3867e..ce2a56fa88410 100644 --- a/library/std/src/sys/io/error/unix.rs +++ b/library/std/src/sys/io/error/unix.rs @@ -158,7 +158,6 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind { libc::ENOENT => NotFound, libc::ENOMEM => OutOfMemory, libc::ENOSPC => StorageFull, - libc::ENOSYS => Unsupported, libc::EMLINK => TooManyLinks, libc::ENAMETOOLONG => InvalidFilename, libc::ENETDOWN => NetworkDown, @@ -176,11 +175,16 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind { libc::EXDEV => CrossesDevices, libc::EINPROGRESS => InProgress, libc::EMFILE | libc::ENFILE => TooManyOpenFiles, - libc::EOPNOTSUPP => Unsupported, libc::EIO => InputOutputError, libc::EACCES | libc::EPERM => PermissionDenied, + libc::ENOSYS => Unsupported, + // EOPNOTSUPP and ENOTSUP can have the same value on some systems, + // but different values on others (e.g. Apple), so we can't use a + // match clause + x if x == libc::EOPNOTSUPP || x == libc::ENOTSUP => Unsupported, + // These two constants can have the same value on some systems, // but different values on others, so we can't use a match // clause