11use std:: convert:: TryFrom ;
22use std:: env;
33use std:: ffi:: { OsStr , OsString } ;
4- use std:: io:: { Error , ErrorKind } ;
4+ use std:: io:: ErrorKind ;
55
66use rustc_data_structures:: fx:: FxHashMap ;
77use rustc_mir:: interpret:: Pointer ;
@@ -324,8 +324,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
324324
325325 if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
326326 this. reject_in_isolation ( "getcwd" , reject_with) ?;
327- let err = Error :: new ( ErrorKind :: NotFound , "rejected due to isolation" ) ;
328- this. set_last_error_from_io_error ( err) ?;
327+ this. set_last_error_from_io_error ( ErrorKind :: NotFound ) ?;
329328 return Ok ( Scalar :: null_ptr ( & * this. tcx ) ) ;
330329 }
331330
@@ -340,7 +339,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
340339 let erange = this. eval_libc ( "ERANGE" ) ?;
341340 this. set_last_error ( erange) ?;
342341 }
343- Err ( e) => this. set_last_error_from_io_error ( e) ?,
342+ Err ( e) => this. set_last_error_from_io_error ( e. kind ( ) ) ?,
344343 }
345344
346345 Ok ( Scalar :: null_ptr ( & * this. tcx ) )
@@ -357,8 +356,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
357356
358357 if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
359358 this. reject_in_isolation ( "GetCurrentDirectoryW" , reject_with) ?;
360- let err = Error :: new ( ErrorKind :: NotFound , "rejected due to isolation" ) ;
361- this. set_last_error_from_io_error ( err) ?;
359+ this. set_last_error_from_io_error ( ErrorKind :: NotFound ) ?;
362360 return Ok ( 0 ) ;
363361 }
364362
@@ -369,7 +367,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
369367 match env:: current_dir ( ) {
370368 Ok ( cwd) =>
371369 return Ok ( windows_check_buffer_size ( this. write_path_to_wide_str ( & cwd, buf, size) ?) ) ,
372- Err ( e) => this. set_last_error_from_io_error ( e) ?,
370+ Err ( e) => this. set_last_error_from_io_error ( e. kind ( ) ) ?,
373371 }
374372 Ok ( 0 )
375373 }
@@ -384,8 +382,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
384382
385383 if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
386384 this. reject_in_isolation ( "chdir" , reject_with) ?;
387- let err = Error :: new ( ErrorKind :: NotFound , "rejected due to isolation" ) ;
388- this. set_last_error_from_io_error ( err) ?;
385+ this. set_last_error_from_io_error ( ErrorKind :: NotFound ) ?;
389386
390387 return Ok ( -1 ) ;
391388 }
@@ -395,7 +392,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
395392 match env:: set_current_dir ( path) {
396393 Ok ( ( ) ) => Ok ( 0 ) ,
397394 Err ( e) => {
398- this. set_last_error_from_io_error ( e) ?;
395+ this. set_last_error_from_io_error ( e. kind ( ) ) ?;
399396 Ok ( -1 )
400397 }
401398 }
@@ -413,8 +410,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
413410
414411 if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
415412 this. reject_in_isolation ( "SetCurrentDirectoryW" , reject_with) ?;
416- let err = Error :: new ( ErrorKind :: NotFound , "rejected due to isolation" ) ;
417- this. set_last_error_from_io_error ( err) ?;
413+ this. set_last_error_from_io_error ( ErrorKind :: NotFound ) ?;
418414
419415 return Ok ( 0 ) ;
420416 }
@@ -424,7 +420,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
424420 match env:: set_current_dir ( path) {
425421 Ok ( ( ) ) => Ok ( 1 ) ,
426422 Err ( e) => {
427- this. set_last_error_from_io_error ( e) ?;
423+ this. set_last_error_from_io_error ( e. kind ( ) ) ?;
428424 Ok ( 0 )
429425 }
430426 }
0 commit comments