@@ -582,7 +582,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
582
582
fd. pread ( communicate, & mut bytes, offset, this)
583
583
}
584
584
} ;
585
- read_byte_helper ( buf, bytes, result, dest, this ) ?;
585
+ self . read_byte_helper ( buf, bytes, result, dest) ?;
586
586
Ok ( ( ) )
587
587
}
588
588
@@ -619,33 +619,35 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
619
619
this. write_scalar ( res, dest) ?;
620
620
Ok ( ( ) )
621
621
}
622
- }
623
- fn read_byte_helper < ' tcx > (
624
- buf : Pointer ,
625
- bytes : Vec < u8 > ,
626
- result : InterpResult < ' tcx , io:: Result < usize > > ,
627
- dest : & MPlaceTy < ' tcx > ,
628
- ecx : & mut MiriInterpCx < ' tcx > ,
629
- ) -> InterpResult < ' tcx > {
630
- // `File::read` never returns a value larger than `count`, so this cannot fail.
631
- match result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) {
632
- // try to pass this the write_ptr inside write
633
- // Pass the pointer inside the write function.
634
- Ok ( read_bytes) => {
635
- // If reading to `bytes` did not fail, we write those bytes to the buffer.
636
- // Crucially, if fewer than `bytes.len()` bytes were read, only write
637
- // that much into the output buffer!
638
- ecx. write_bytes_ptr (
639
- buf,
640
- bytes[ ..usize:: try_from ( read_bytes) . unwrap ( ) ] . iter ( ) . copied ( ) ,
641
- ) ?;
642
- ecx. write_scalar ( Scalar :: from_target_isize ( read_bytes, ecx) , dest) ?;
643
- return Ok ( ( ) ) ;
644
- }
645
- Err ( e) => {
646
- ecx. set_last_error_from_io_error ( e) ?;
647
- ecx. write_scalar ( Scalar :: from_target_isize ( -1 , ecx) , dest) ?;
648
- return Ok ( ( ) ) ;
622
+
623
+ fn read_byte_helper (
624
+ & mut self ,
625
+ buf : Pointer ,
626
+ bytes : Vec < u8 > ,
627
+ result : InterpResult < ' tcx , io:: Result < usize > > ,
628
+ dest : & MPlaceTy < ' tcx > ,
629
+ ) -> InterpResult < ' tcx > {
630
+ let this = self . eval_context_mut ( ) ;
631
+ // `File::read` never returns a value larger than `count`, so this cannot fail.
632
+ match result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) {
633
+ // try to pass this the write_ptr inside write
634
+ // Pass the pointer inside the write function.
635
+ Ok ( read_bytes) => {
636
+ // If reading to `bytes` did not fail, we write those bytes to the buffer.
637
+ // Crucially, if fewer than `bytes.len()` bytes were read, only write
638
+ // that much into the output buffer!
639
+ this. write_bytes_ptr (
640
+ buf,
641
+ bytes[ ..usize:: try_from ( read_bytes) . unwrap ( ) ] . iter ( ) . copied ( ) ,
642
+ ) ?;
643
+ this. write_scalar ( Scalar :: from_target_isize ( read_bytes, this) , dest) ?;
644
+ return Ok ( ( ) ) ;
645
+ }
646
+ Err ( e) => {
647
+ this. set_last_error_from_io_error ( e) ?;
648
+ this. write_scalar ( Scalar :: from_target_isize ( -1 , this) , dest) ?;
649
+ return Ok ( ( ) ) ;
650
+ }
649
651
}
650
652
}
651
653
}
0 commit comments