@@ -9,12 +9,11 @@ use rustc_ast::expand::allocator::alloc_error_handler_name;
99use rustc_hir:: def:: DefKind ;
1010use rustc_hir:: def_id:: CrateNum ;
1111use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
12- use rustc_middle:: { mir, ty} ;
1312use rustc_middle:: ty:: Ty ;
13+ use rustc_middle:: { mir, ty} ;
1414use rustc_span:: Symbol ;
1515use rustc_target:: callconv:: { Conv , FnAbi } ;
1616
17-
1817use self :: helpers:: { ToHost , ToSoft } ;
1918use super :: alloc:: EvalContextExt as _;
2019use super :: backtrace:: EvalContextExt as _;
@@ -279,7 +278,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
279278 match link_name. as_str ( ) {
280279 // Miri-specific extern functions
281280 "miri_start_unwind" => {
282- let [ payload] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
281+ let [ payload] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
283282 this. handle_miri_start_unwind ( payload) ?;
284283 return interp_ok ( EmulateItemResult :: NeedsUnwind ) ;
285284 }
@@ -288,7 +287,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
288287 this. run_provenance_gc ( ) ;
289288 }
290289 "miri_get_alloc_id" => {
291- let [ ptr] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
290+ let [ ptr] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
292291 let ptr = this. read_pointer ( ptr) ?;
293292 let ( alloc_id, _, _) = this. ptr_get_alloc_id ( ptr, 0 ) . map_err_kind ( |_e| {
294293 err_machine_stop ! ( TerminationInfo :: Abort ( format!(
@@ -298,7 +297,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
298297 this. write_scalar ( Scalar :: from_u64 ( alloc_id. 0 . get ( ) ) , dest) ?;
299298 }
300299 "miri_print_borrow_state" => {
301- let [ id, show_unnamed] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
300+ let [ id, show_unnamed] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
302301 let id = this. read_scalar ( id) ?. to_u64 ( ) ?;
303302 let show_unnamed = this. read_scalar ( show_unnamed) ?. to_bool ( ) ?;
304303 if let Some ( id) = std:: num:: NonZero :: new ( id) . map ( AllocId )
@@ -312,8 +311,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
312311 "miri_pointer_name" => {
313312 // This associates a name to a tag. Very useful for debugging, and also makes
314313 // tests more strict.
315- let [ ptr, nth_parent, name] =
316- this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
314+ let [ ptr, nth_parent, name] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
317315 let ptr = this. read_pointer ( ptr) ?;
318316 let nth_parent = this. read_scalar ( nth_parent) ?. to_u8 ( ) ?;
319317 let name = this. read_immediate ( name) ?;
@@ -337,8 +335,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
337335 this. machine . static_roots . push ( alloc_id) ;
338336 }
339337 "miri_host_to_target_path" => {
340- let [ ptr, out, out_size] =
341- this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
338+ let [ ptr, out, out_size] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
342339 let ptr = this. read_pointer ( ptr) ?;
343340 let out = this. read_pointer ( out) ?;
344341 let out_size = this. read_scalar ( out_size) ?. to_target_usize ( this) ?;
@@ -429,22 +426,20 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
429426
430427 // Aborting the process.
431428 "exit" => {
432- let [ code] =
433- this. check_shim ( abi, Conv :: C , link_name, args) ?;
429+ let [ code] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
434430 let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
435431 throw_machine_stop ! ( TerminationInfo :: Exit { code: code. into( ) , leak_check: false } ) ;
436432 }
437433 "abort" => {
438- let [ ] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
434+ let [ ] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
439435 throw_machine_stop ! ( TerminationInfo :: Abort (
440436 "the program aborted execution" . to_owned( )
441437 ) )
442438 }
443439
444440 // Standard C allocation
445441 "malloc" => {
446- let [ size] =
447- this. check_shim ( abi, Conv :: C , link_name, args) ?;
442+ let [ size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
448443 let size = this. read_target_usize ( size) ?;
449444 if size <= this. max_size_of_val ( ) . bytes ( ) {
450445 let res = this. malloc ( size, /*zero_init:*/ false ) ?;
@@ -458,8 +453,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
458453 }
459454 }
460455 "calloc" => {
461- let [ items, elem_size] =
462- this. check_shim ( abi, Conv :: C , link_name, args) ?;
456+ let [ items, elem_size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
463457 let items = this. read_target_usize ( items) ?;
464458 let elem_size = this. read_target_usize ( elem_size) ?;
465459 if let Some ( size) = this. compute_size_in_bytes ( Size :: from_bytes ( elem_size) , items) {
@@ -474,14 +468,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
474468 }
475469 }
476470 "free" => {
477- let [ ptr] =
478- this. check_shim ( abi, Conv :: C , link_name, args) ?;
471+ let [ ptr] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
479472 let ptr = this. read_pointer ( ptr) ?;
480473 this. free ( ptr) ?;
481474 }
482475 "realloc" => {
483- let [ old_ptr, new_size] =
484- this. check_shim ( abi, Conv :: C , link_name, args) ?;
476+ let [ old_ptr, new_size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
485477 let old_ptr = this. read_pointer ( old_ptr) ?;
486478 let new_size = this. read_target_usize ( new_size) ?;
487479 if new_size <= this. max_size_of_val ( ) . bytes ( ) {
@@ -619,8 +611,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
619611
620612 // C memory handling functions
621613 "memcmp" => {
622- let [ left, right, n] =
623- this. check_shim ( abi, Conv :: C , link_name, args) ?;
614+ let [ left, right, n] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
624615 let left = this. read_pointer ( left) ?;
625616 let right = this. read_pointer ( right) ?;
626617 let n = Size :: from_bytes ( this. read_target_usize ( n) ?) ;
@@ -644,8 +635,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
644635 this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
645636 }
646637 "memrchr" => {
647- let [ ptr, val, num] =
648- this. check_shim ( abi, Conv :: C , link_name, args) ?;
638+ let [ ptr, val, num] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
649639 let ptr = this. read_pointer ( ptr) ?;
650640 let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
651641 let num = this. read_target_usize ( num) ?;
@@ -671,8 +661,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
671661 }
672662 }
673663 "memchr" => {
674- let [ ptr, val, num] =
675- this. check_shim ( abi, Conv :: C , link_name, args) ?;
664+ let [ ptr, val, num] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
676665 let ptr = this. read_pointer ( ptr) ?;
677666 let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
678667 let num = this. read_target_usize ( num) ?;
@@ -695,8 +684,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
695684 }
696685 }
697686 "strlen" => {
698- let [ ptr] =
699- this. check_shim ( abi, Conv :: C , link_name, args) ?;
687+ let [ ptr] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
700688 let ptr = this. read_pointer ( ptr) ?;
701689 // This reads at least 1 byte, so we are already enforcing that this is a valid pointer.
702690 let n = this. read_c_str ( ptr) ?. len ( ) ;
@@ -706,8 +694,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
706694 ) ?;
707695 }
708696 "wcslen" => {
709- let [ ptr] =
710- this. check_shim ( abi, Conv :: C , link_name, args) ?;
697+ let [ ptr] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
711698 let ptr = this. read_pointer ( ptr) ?;
712699 // This reads at least 1 byte, so we are already enforcing that this is a valid pointer.
713700 let n = this. read_wchar_t_str ( ptr) ?. len ( ) ;
@@ -717,8 +704,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
717704 ) ?;
718705 }
719706 "memcpy" => {
720- let [ ptr_dest, ptr_src, n] =
721- this. check_shim ( abi, Conv :: C , link_name, args) ?;
707+ let [ ptr_dest, ptr_src, n] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
722708 let ptr_dest = this. read_pointer ( ptr_dest) ?;
723709 let ptr_src = this. read_pointer ( ptr_src) ?;
724710 let n = this. read_target_usize ( n) ?;
@@ -732,8 +718,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
732718 this. write_pointer ( ptr_dest, dest) ?;
733719 }
734720 "strcpy" => {
735- let [ ptr_dest, ptr_src] =
736- this. check_shim ( abi, Conv :: C , link_name, args) ?;
721+ let [ ptr_dest, ptr_src] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
737722 let ptr_dest = this. read_pointer ( ptr_dest) ?;
738723 let ptr_src = this. read_pointer ( ptr_src) ?;
739724
@@ -878,8 +863,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
878863 this. write_scalar ( res, dest) ?;
879864 }
880865 "lgammaf_r" => {
881- let [ x, signp] =
882- this. check_shim ( abi, Conv :: C , link_name, args) ?;
866+ let [ x, signp] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
883867 let x = this. read_scalar ( x) ?. to_f32 ( ) ?;
884868 let signp = this. deref_pointer ( signp) ?;
885869
@@ -890,8 +874,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
890874 this. write_scalar ( res, dest) ?;
891875 }
892876 "lgamma_r" => {
893- let [ x, signp] =
894- this. check_shim ( abi, Conv :: C , link_name, args) ?;
877+ let [ x, signp] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
895878 let x = this. read_scalar ( x) ?. to_f64 ( ) ?;
896879 let signp = this. deref_pointer ( signp) ?;
897880
@@ -904,8 +887,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
904887
905888 // LLVM intrinsics
906889 "llvm.prefetch" => {
907- let [ p, rw, loc, ty] =
908- this. check_shim ( abi, Conv :: C , link_name, args) ?;
890+ let [ p, rw, loc, ty] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
909891
910892 let _ = this. read_pointer ( p) ?;
911893 let rw = this. read_scalar ( rw) ?. to_i32 ( ) ?;
@@ -932,7 +914,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
932914 // Used to implement the x86 `_mm{,256,512}_popcnt_epi{8,16,32,64}` and wasm
933915 // `{i,u}8x16_popcnt` functions.
934916 name if name. starts_with ( "llvm.ctpop.v" ) => {
935- let [ op] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
917+ let [ op] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
936918
937919 let ( op, op_len) = this. project_to_simd ( op) ?;
938920 let ( dest, dest_len) = this. project_to_simd ( dest) ?;
0 commit comments