1- use std:: mem;
1+ use std:: { mem, iter } ;
22use std:: ffi:: { OsStr , OsString } ;
33
44use rustc:: hir:: def_id:: { DefId , CRATE_DEF_INDEX } ;
@@ -379,7 +379,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
379379 _ => throw_unsup_format ! ( "The {} error cannot be transformed into a raw os error" , e)
380380 } ) ?
381381 } else {
382- // FIXME: we have to implement the windows' equivalent of this.
382+ // FIXME: we have to implement the Windows equivalent of this.
383383 throw_unsup_format ! ( "Setting the last OS error from an io::Error is unsupported for {}." , target. target_os)
384384 } ;
385385 this. set_last_error ( last_error)
@@ -390,7 +390,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
390390 /// `Ok(-1)` and sets the last OS error accordingly.
391391 ///
392392 /// This function uses `T: From<i32>` instead of `i32` directly because some IO related
393- /// functions return different integer types (like `read`, that returns an `i64`)
393+ /// functions return different integer types (like `read`, that returns an `i64`).
394394 fn try_unwrap_io_result < T : From < i32 > > (
395395 & mut self ,
396396 result : std:: io:: Result < T > ,
@@ -423,12 +423,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
423423 ) -> InterpResult < ' tcx , bool > {
424424 let bytes = os_str_to_bytes ( os_str) ?;
425425 // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required null
426- // terminator to memory using the `ptr` pointer would cause an overflow .
426+ // terminator to memory using the `ptr` pointer would cause an out-of-bounds access .
427427 if size <= bytes. len ( ) as u64 {
428428 return Ok ( false ) ;
429429 }
430- // FIXME: We should use `Iterator::chain` instead when rust-lang/rust#65704 lands.
431- self . eval_context_mut ( ) . memory . write_bytes ( scalar, [ bytes, & [ 0 ] ] . concat ( ) ) ?;
430+ self . eval_context_mut ( ) . memory . write_bytes ( scalar, bytes. iter ( ) . copied ( ) . chain ( iter:: once ( 0u8 ) ) ) ?;
432431 Ok ( true )
433432 }
434433}
0 commit comments