@@ -25,26 +25,26 @@ struct FileHandle {
2525trait FileDescriptor < ' tcx > : std:: fmt:: Debug {
2626 fn as_file_handle ( & self ) -> InterpResult < ' tcx , & FileHandle > ;
2727
28- fn read ( & mut self , bytes : & mut [ u8 ] ) -> Result < usize , io:: Error > ;
29- fn write ( & mut self , bytes : & [ u8 ] ) -> Result < usize , io:: Error > ;
30- fn seek ( & mut self , offset : SeekFrom ) -> Result < u64 , io:: Error > ;
28+ fn read ( & mut self , bytes : & mut [ u8 ] ) -> InterpResult < ' tcx , io:: Result < usize > > ;
29+ fn write ( & mut self , bytes : & [ u8 ] ) -> InterpResult < ' tcx , io:: Result < usize > > ;
30+ fn seek ( & mut self , offset : SeekFrom ) -> InterpResult < ' tcx , io:: Result < u64 > > ;
3131}
3232
3333impl < ' tcx > FileDescriptor < ' tcx > for FileHandle {
3434 fn as_file_handle ( & self ) -> InterpResult < ' tcx , & FileHandle > {
3535 Ok ( & self )
3636 }
3737
38- fn read ( & mut self , bytes : & mut [ u8 ] ) -> Result < usize , io:: Error > {
39- self . file . read ( bytes)
38+ fn read ( & mut self , bytes : & mut [ u8 ] ) -> InterpResult < ' tcx , io:: Result < usize > > {
39+ Ok ( self . file . read ( bytes) )
4040 }
4141
42- fn write ( & mut self , bytes : & [ u8 ] ) -> Result < usize , io:: Error > {
43- self . file . write ( bytes)
42+ fn write ( & mut self , bytes : & [ u8 ] ) -> InterpResult < ' tcx , io:: Result < usize > > {
43+ Ok ( self . file . write ( bytes) )
4444 }
4545
46- fn seek ( & mut self , offset : SeekFrom ) -> Result < u64 , io:: Error > {
47- self . file . seek ( offset)
46+ fn seek ( & mut self , offset : SeekFrom ) -> InterpResult < ' tcx , io:: Result < u64 > > {
47+ Ok ( self . file . seek ( offset) )
4848 }
4949}
5050
@@ -509,7 +509,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
509509 // `File::read` never returns a value larger than `count`,
510510 // so this cannot fail.
511511 let result = file_descriptor
512- . read ( & mut bytes)
512+ . read ( & mut bytes) ?
513513 . map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
514514
515515 match result {
@@ -554,7 +554,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
554554 if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
555555 let bytes = this. memory . read_bytes ( buf, Size :: from_bytes ( count) ) ?;
556556 let result = file_descriptor
557- . write ( & bytes)
557+ . write ( & bytes) ?
558558 . map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
559559 this. try_unwrap_io_result ( result)
560560 } else {
@@ -590,7 +590,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
590590
591591 if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
592592 let result = file_descriptor
593- . seek ( seek_from)
593+ . seek ( seek_from) ?
594594 . map ( |offset| i64:: try_from ( offset) . unwrap ( ) ) ;
595595 this. try_unwrap_io_result ( result)
596596 } else {
0 commit comments