@@ -25,26 +25,26 @@ struct FileHandle {
25
25
trait FileDescriptor < ' tcx > : std:: fmt:: Debug {
26
26
fn as_file_handle ( & self ) -> InterpResult < ' tcx , & FileHandle > ;
27
27
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 > > ;
31
31
}
32
32
33
33
impl < ' tcx > FileDescriptor < ' tcx > for FileHandle {
34
34
fn as_file_handle ( & self ) -> InterpResult < ' tcx , & FileHandle > {
35
35
Ok ( & self )
36
36
}
37
37
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) )
40
40
}
41
41
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) )
44
44
}
45
45
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) )
48
48
}
49
49
}
50
50
@@ -509,7 +509,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
509
509
// `File::read` never returns a value larger than `count`,
510
510
// so this cannot fail.
511
511
let result = file_descriptor
512
- . read ( & mut bytes)
512
+ . read ( & mut bytes) ?
513
513
. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
514
514
515
515
match result {
@@ -554,7 +554,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
554
554
if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
555
555
let bytes = this. memory . read_bytes ( buf, Size :: from_bytes ( count) ) ?;
556
556
let result = file_descriptor
557
- . write ( & bytes)
557
+ . write ( & bytes) ?
558
558
. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
559
559
this. try_unwrap_io_result ( result)
560
560
} else {
@@ -590,7 +590,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
590
590
591
591
if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
592
592
let result = file_descriptor
593
- . seek ( seek_from)
593
+ . seek ( seek_from) ?
594
594
. map ( |offset| i64:: try_from ( offset) . unwrap ( ) ) ;
595
595
this. try_unwrap_io_result ( result)
596
596
} else {
0 commit comments