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
```
This commit is contained in:
Christian Legnitto 2022-08-03 10:39:43 -04:00
parent c24c638884
commit 9154f8b22c

View File

@ -23,26 +23,49 @@
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {} impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
// This mapping is the reverse of `decode_error_kind` in
// <https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/mod.rs>
// and should be kept in sync.
const UNIX_IO_ERROR_TABLE: &[(std::io::ErrorKind, &str)] = { const UNIX_IO_ERROR_TABLE: &[(std::io::ErrorKind, &str)] = {
use std::io::ErrorKind::*; use std::io::ErrorKind::*;
&[ &[
(ArgumentListTooLong, "E2BIG"),
(AddrInUse, "EADDRINUSE"),
(AddrNotAvailable, "EADDRNOTAVAIL"),
(ResourceBusy, "EBUSY"),
(ConnectionAborted, "ECONNABORTED"),
(ConnectionRefused, "ECONNREFUSED"), (ConnectionRefused, "ECONNREFUSED"),
(ConnectionReset, "ECONNRESET"), (ConnectionReset, "ECONNRESET"),
(PermissionDenied, "EPERM"), (Deadlock, "EDEADLK"),
(BrokenPipe, "EPIPE"), (FilesystemQuotaExceeded, "EDQUOT"),
(NotConnected, "ENOTCONN"), (AlreadyExists, "EEXIST"),
(ConnectionAborted, "ECONNABORTED"), (FileTooLarge, "EFBIG"),
(AddrNotAvailable, "EADDRNOTAVAIL"), (HostUnreachable, "EHOSTUNREACH"),
(AddrInUse, "EADDRINUSE"),
(NotFound, "ENOENT"),
(Interrupted, "EINTR"), (Interrupted, "EINTR"),
(InvalidInput, "EINVAL"), (InvalidInput, "EINVAL"),
(InvalidFilename, "ENAMETOOLONG"), (IsADirectory, "EISDIR"),
(TimedOut, "ETIMEDOUT"),
(AlreadyExists, "EEXIST"),
(WouldBlock, "EWOULDBLOCK"),
(DirectoryNotEmpty, "ENOTEMPTY"),
(FilesystemLoop, "ELOOP"), (FilesystemLoop, "ELOOP"),
(NotFound, "ENOENT"),
(OutOfMemory, "ENOMEM"),
(StorageFull, "ENOSPC"),
(Unsupported, "ENOSYS"),
(TooManyLinks, "EMLINK"),
(InvalidFilename, "ENAMETOOLONG"),
(NetworkDown, "ENETDOWN"),
(NetworkUnreachable, "ENETUNREACH"),
(NotConnected, "ENOTCONN"),
(NotADirectory, "ENOTDIR"),
(DirectoryNotEmpty, "ENOTEMPTY"),
(BrokenPipe, "EPIPE"),
(ReadOnlyFilesystem, "EROFS"),
(NotSeekable, "ESPIPE"),
(StaleNetworkFileHandle, "ESTALE"),
(TimedOut, "ETIMEDOUT"),
(ExecutableFileBusy, "ETXTBSY"),
(CrossesDevices, "EXDEV"),
// The following have two valid options...we pick one.
(PermissionDenied, "EPERM"),
(WouldBlock, "EWOULDBLOCK"),
] ]
}; };