@@ -23,49 +23,51 @@ use crate::*;
23
23
24
24
impl < ' mir , ' tcx : ' mir > EvalContextExt < ' mir , ' tcx > for crate :: MiriEvalContext < ' mir , ' tcx > { }
25
25
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.
29
- const UNIX_IO_ERROR_TABLE : & [ ( std:: io:: ErrorKind , & str ) ] = {
26
+ // This mapping should match `decode_error_kind` in
27
+ // <https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/mod.rs>.
28
+ const UNIX_IO_ERROR_TABLE : & [ ( & str , std:: io:: ErrorKind ) ] = {
30
29
use std:: io:: ErrorKind :: * ;
31
30
& [
32
- ( ArgumentListTooLong , "E2BIG" ) ,
33
- ( AddrInUse , "EADDRINUSE" ) ,
34
- ( AddrNotAvailable , "EADDRNOTAVAIL" ) ,
35
- ( ResourceBusy , "EBUSY" ) ,
36
- ( ConnectionAborted , "ECONNABORTED" ) ,
37
- ( ConnectionRefused , "ECONNREFUSED" ) ,
38
- ( ConnectionReset , "ECONNRESET" ) ,
39
- ( Deadlock , "EDEADLK" ) ,
40
- ( FilesystemQuotaExceeded , "EDQUOT" ) ,
41
- ( AlreadyExists , "EEXIST" ) ,
42
- ( FileTooLarge , "EFBIG" ) ,
43
- ( HostUnreachable , "EHOSTUNREACH" ) ,
44
- ( Interrupted , "EINTR" ) ,
45
- ( InvalidInput , "EINVAL" ) ,
46
- ( IsADirectory , "EISDIR" ) ,
47
- ( FilesystemLoop , "ELOOP" ) ,
48
- ( NotFound , "ENOENT" ) ,
49
- ( OutOfMemory , "ENOMEM" ) ,
50
- ( StorageFull , "ENOSPC" ) ,
51
- ( Unsupported , "ENOSYS" ) ,
52
- ( TooManyLinks , "EMLINK" ) ,
53
- ( 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" ) ,
63
- ( TimedOut , "ETIMEDOUT" ) ,
64
- ( ExecutableFileBusy , "ETXTBSY" ) ,
65
- ( CrossesDevices , "EXDEV" ) ,
66
- // The following have two valid options...we pick one.
67
- ( PermissionDenied , "EPERM" ) ,
68
- ( WouldBlock , "EWOULDBLOCK" ) ,
31
+ ( "E2BIG" , ArgumentListTooLong ) ,
32
+ ( "EADDRINUSE" , AddrInUse ) ,
33
+ ( "EADDRNOTAVAIL" , AddrNotAvailable ) ,
34
+ ( "EBUSY" , ResourceBusy ) ,
35
+ ( "ECONNABORTED" , ConnectionAborted ) ,
36
+ ( "ECONNREFUSED" , ConnectionRefused ) ,
37
+ ( "ECONNRESET" , ConnectionReset ) ,
38
+ ( "EDEADLK" , Deadlock ) ,
39
+ ( "EDQUOT" , FilesystemQuotaExceeded ) ,
40
+ ( "EEXIST" , AlreadyExists ) ,
41
+ ( "EFBIG" , FileTooLarge ) ,
42
+ ( "EHOSTUNREACH" , HostUnreachable ) ,
43
+ ( "EINTR" , Interrupted ) ,
44
+ ( "EINVAL" , InvalidInput ) ,
45
+ ( "EISDIR" , IsADirectory ) ,
46
+ ( "ELOOP" , FilesystemLoop ) ,
47
+ ( "ENOENT" , NotFound ) ,
48
+ ( "ENOMEM" , OutOfMemory ) ,
49
+ ( "ENOSPC" , StorageFull ) ,
50
+ ( "ENOSYS" , Unsupported ) ,
51
+ ( "EMLINK" , TooManyLinks ) ,
52
+ ( "ENAMETOOLONG" , InvalidFilename ) ,
53
+ ( "ENETDOWN" , NetworkDown ) ,
54
+ ( "ENETUNREACH" , NetworkUnreachable ) ,
55
+ ( "ENOTCONN" , NotConnected ) ,
56
+ ( "ENOTDIR" , NotADirectory ) ,
57
+ ( "ENOTEMPTY" , DirectoryNotEmpty ) ,
58
+ ( "EPIPE" , BrokenPipe ) ,
59
+ ( "EROFS" , ReadOnlyFilesystem ) ,
60
+ ( "ESPIPE" , NotSeekable ) ,
61
+ ( "ESTALE" , StaleNetworkFileHandle ) ,
62
+ ( "ETIMEDOUT" , TimedOut ) ,
63
+ ( "ETXTBSY" , ExecutableFileBusy ) ,
64
+ ( "EXDEV" , CrossesDevices ) ,
65
+ // The following have two valid options. We have both for the forwards mapping; only the
66
+ // first one will be used for the backwards mapping.
67
+ ( "EPERM" , PermissionDenied ) ,
68
+ ( "EACCES" , PermissionDenied ) ,
69
+ ( "EWOULDBLOCK" , WouldBlock ) ,
70
+ ( "EAGAIN" , WouldBlock ) ,
69
71
]
70
72
} ;
71
73
@@ -577,7 +579,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
577
579
let this = self . eval_context_ref ( ) ;
578
580
let target = & this. tcx . sess . target ;
579
581
if target. families . iter ( ) . any ( |f| f == "unix" ) {
580
- for & ( kind , name ) in UNIX_IO_ERROR_TABLE {
582
+ for & ( name , kind ) in UNIX_IO_ERROR_TABLE {
581
583
if err_kind == kind {
582
584
return this. eval_libc ( name) ;
583
585
}
@@ -615,7 +617,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
615
617
let target = & this. tcx . sess . target ;
616
618
if target. families . iter ( ) . any ( |f| f == "unix" ) {
617
619
let errnum = errnum. to_i32 ( ) ?;
618
- for & ( kind , name ) in UNIX_IO_ERROR_TABLE {
620
+ for & ( name , kind ) in UNIX_IO_ERROR_TABLE {
619
621
if errnum == this. eval_libc_i32 ( name) ? {
620
622
return Ok ( kind) ;
621
623
}
0 commit comments