1
1
use std:: convert:: TryFrom ;
2
2
use std:: env;
3
3
use std:: ffi:: { OsStr , OsString } ;
4
- use std:: io:: { Error , ErrorKind } ;
4
+ use std:: io:: ErrorKind ;
5
5
6
6
use rustc_data_structures:: fx:: FxHashMap ;
7
7
use rustc_mir:: interpret:: Pointer ;
@@ -324,8 +324,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
324
324
325
325
if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
326
326
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 ) ?;
329
328
return Ok ( Scalar :: null_ptr ( & * this. tcx ) ) ;
330
329
}
331
330
@@ -340,7 +339,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
340
339
let erange = this. eval_libc ( "ERANGE" ) ?;
341
340
this. set_last_error ( erange) ?;
342
341
}
343
- Err ( e) => this. set_last_error_from_io_error ( e) ?,
342
+ Err ( e) => this. set_last_error_from_io_error ( e. kind ( ) ) ?,
344
343
}
345
344
346
345
Ok ( Scalar :: null_ptr ( & * this. tcx ) )
@@ -357,8 +356,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
357
356
358
357
if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
359
358
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 ) ?;
362
360
return Ok ( 0 ) ;
363
361
}
364
362
@@ -369,7 +367,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
369
367
match env:: current_dir ( ) {
370
368
Ok ( cwd) =>
371
369
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 ( ) ) ?,
373
371
}
374
372
Ok ( 0 )
375
373
}
@@ -384,8 +382,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
384
382
385
383
if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
386
384
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 ) ?;
389
386
390
387
return Ok ( -1 ) ;
391
388
}
@@ -395,7 +392,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
395
392
match env:: set_current_dir ( path) {
396
393
Ok ( ( ) ) => Ok ( 0 ) ,
397
394
Err ( e) => {
398
- this. set_last_error_from_io_error ( e) ?;
395
+ this. set_last_error_from_io_error ( e. kind ( ) ) ?;
399
396
Ok ( -1 )
400
397
}
401
398
}
@@ -413,8 +410,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
413
410
414
411
if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
415
412
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 ) ?;
418
414
419
415
return Ok ( 0 ) ;
420
416
}
@@ -424,7 +420,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
424
420
match env:: set_current_dir ( path) {
425
421
Ok ( ( ) ) => Ok ( 1 ) ,
426
422
Err ( e) => {
427
- this. set_last_error_from_io_error ( e) ?;
423
+ this. set_last_error_from_io_error ( e. kind ( ) ) ?;
428
424
Ok ( 0 )
429
425
}
430
426
}
0 commit comments