Skip to content

Commit 9154f8b

Browse files
committed
Add additional raw error mappings for the nightly io_error_more feature
Some crates are using nightly and failing when mapping these errors, for example <https://miri.saethlin.dev/?crate=remove_dir_all&version=0.7.0>: ``` error: unsupported operation: io error NotADirectory cannot be translated into a raw os error --> /root/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:1203:19 ```
1 parent c24c638 commit 9154f8b

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

src/helpers.rs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,49 @@ use crate::*;
2323

2424
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
2525

26+
// This mapping is the reverse of `decode_error_kind` in
27+
// <https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/mod.rs>
28+
// and should be kept in sync.
2629
const UNIX_IO_ERROR_TABLE: &[(std::io::ErrorKind, &str)] = {
2730
use std::io::ErrorKind::*;
2831
&[
32+
(ArgumentListTooLong, "E2BIG"),
33+
(AddrInUse, "EADDRINUSE"),
34+
(AddrNotAvailable, "EADDRNOTAVAIL"),
35+
(ResourceBusy, "EBUSY"),
36+
(ConnectionAborted, "ECONNABORTED"),
2937
(ConnectionRefused, "ECONNREFUSED"),
3038
(ConnectionReset, "ECONNRESET"),
31-
(PermissionDenied, "EPERM"),
32-
(BrokenPipe, "EPIPE"),
33-
(NotConnected, "ENOTCONN"),
34-
(ConnectionAborted, "ECONNABORTED"),
35-
(AddrNotAvailable, "EADDRNOTAVAIL"),
36-
(AddrInUse, "EADDRINUSE"),
37-
(NotFound, "ENOENT"),
39+
(Deadlock, "EDEADLK"),
40+
(FilesystemQuotaExceeded, "EDQUOT"),
41+
(AlreadyExists, "EEXIST"),
42+
(FileTooLarge, "EFBIG"),
43+
(HostUnreachable, "EHOSTUNREACH"),
3844
(Interrupted, "EINTR"),
3945
(InvalidInput, "EINVAL"),
46+
(IsADirectory, "EISDIR"),
47+
(FilesystemLoop, "ELOOP"),
48+
(NotFound, "ENOENT"),
49+
(OutOfMemory, "ENOMEM"),
50+
(StorageFull, "ENOSPC"),
51+
(Unsupported, "ENOSYS"),
52+
(TooManyLinks, "EMLINK"),
4053
(InvalidFilename, "ENAMETOOLONG"),
54+
(NetworkDown, "ENETDOWN"),
55+
(NetworkUnreachable, "ENETUNREACH"),
56+
(NotConnected, "ENOTCONN"),
57+
(NotADirectory, "ENOTDIR"),
58+
(DirectoryNotEmpty, "ENOTEMPTY"),
59+
(BrokenPipe, "EPIPE"),
60+
(ReadOnlyFilesystem, "EROFS"),
61+
(NotSeekable, "ESPIPE"),
62+
(StaleNetworkFileHandle, "ESTALE"),
4163
(TimedOut, "ETIMEDOUT"),
42-
(AlreadyExists, "EEXIST"),
64+
(ExecutableFileBusy, "ETXTBSY"),
65+
(CrossesDevices, "EXDEV"),
66+
// The following have two valid options...we pick one.
67+
(PermissionDenied, "EPERM"),
4368
(WouldBlock, "EWOULDBLOCK"),
44-
(DirectoryNotEmpty, "ENOTEMPTY"),
45-
(FilesystemLoop, "ELOOP"),
4669
]
4770
};
4871

0 commit comments

Comments
 (0)