From bc4ab23772b046b2f30b44efa849a874a90e17dc Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Mon, 29 Jun 2026 18:20:03 +0300 Subject: [PATCH 1/2] std: map ENOTSUP to ErrorKind::Unsupported decode_error_kind maps EOPNOTSUPP to Unsupported but not ENOTSUP. The two are the same value on some targets (Linux, FreeBSD), where that arm already covers both, and different on others (Apple, OpenBSD), where ENOTSUP fell through to Uncategorized. Since they alias on some targets, an or-pattern would be an unreachable arm there; use a match guard, like the existing EAGAIN/EWOULDBLOCK arm. --- library/std/src/sys/io/error/unix.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/io/error/unix.rs b/library/std/src/sys/io/error/unix.rs index c545558c3867e..5bd61e962e6db 100644 --- a/library/std/src/sys/io/error/unix.rs +++ b/library/std/src/sys/io/error/unix.rs @@ -176,11 +176,15 @@ 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, + // 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 From aa49d140b54cac7e7aaa53fc9ab0640d3ad0cd5a Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sun, 16 Aug 2026 17:38:34 +0300 Subject: [PATCH 2/2] std: move ENOSYS next to the other Unsupported arms --- library/std/src/sys/io/error/unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/io/error/unix.rs b/library/std/src/sys/io/error/unix.rs index 5bd61e962e6db..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, @@ -180,6 +179,7 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind { 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