Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions library/std/src/sys/io/error/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,

@RalfJung RalfJung Aug 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is also ENOSYS mapping to the same thing. Seems better to group all 3 together.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for highlighting this, you are right ENOSYS maps to Unsupported as well.

Currently the guard was added because Linux libc defines ENOTSUP as EOPNOTSUPP (same value), so an or-pattern would be unreachable and dead code on Linux (95 | 95 => ...).
ENOSYS have distinct value, so it doesn't need a guard, and keeping it as pattern has some benefits (compiler could catch if it will collide with another arm).

I could add it, if you prefer to have 3 of them grouped together anyway, if not, i could just move ENOSYS arm right above this guard, so Unsupported case will be near each other.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it'd be best to have them all next to each other -- whether as one arm or as two (one using the if ... || ...) doesn't matter much IMO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agree, moved ENOSYS to have Unsupported cases next to each other.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Annoying feature of the pattern matching lint, that.


// These two constants can have the same value on some systems,
// but different values on others, so we can't use a match
// clause
Expand Down
Loading