@@ -379,8 +379,6 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
379
379
TerminatorKind :: Call { args, destination : Some ( destination) , cleanup, .. } => {
380
380
debug ! ( "Inlined {:?} into {:?}" , callsite. callee, self . source) ;
381
381
382
- let is_box_free = Some ( callsite. callee ) == self . tcx . lang_items ( ) . box_free_fn ( ) ;
383
-
384
382
let mut local_map = IndexVec :: with_capacity ( callee_mir. local_decls . len ( ) ) ;
385
383
let mut scope_map = IndexVec :: with_capacity ( callee_mir. visibility_scopes . len ( ) ) ;
386
384
let mut promoted_map = IndexVec :: with_capacity ( callee_mir. promoted . len ( ) ) ;
@@ -460,24 +458,8 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
460
458
461
459
let return_block = destination. 1 ;
462
460
463
- let args : Vec < _ > = if is_box_free {
464
- assert ! ( args. len( ) == 1 ) ;
465
- // box_free takes a Box, but is defined with a *mut T, inlining
466
- // needs to generate the cast.
467
- // FIXME: we should probably just generate correct MIR in the first place...
468
-
469
- let arg = if let Operand :: Move ( ref place) = args[ 0 ] {
470
- place. clone ( )
471
- } else {
472
- bug ! ( "Constant arg to \" box_free\" " ) ;
473
- } ;
474
-
475
- let ptr_ty = args[ 0 ] . ty ( caller_mir, self . tcx ) ;
476
- vec ! [ self . cast_box_free_arg( arg, ptr_ty, & callsite, caller_mir) ]
477
- } else {
478
- // Copy the arguments if needed.
479
- self . make_call_args ( args, & callsite, caller_mir)
480
- } ;
461
+ // Copy the arguments if needed.
462
+ let args: Vec < _ > = self . make_call_args ( args, & callsite, caller_mir) ;
481
463
482
464
let bb_len = caller_mir. basic_blocks ( ) . len ( ) ;
483
465
let mut integrator = Integrator {
@@ -518,49 +500,6 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
518
500
}
519
501
}
520
502
521
- fn cast_box_free_arg ( & self , arg : Place < ' tcx > , ptr_ty : Ty < ' tcx > ,
522
- callsite : & CallSite < ' tcx > , caller_mir : & mut Mir < ' tcx > ) -> Local {
523
- let arg = Rvalue :: Ref (
524
- self . tcx . types . re_erased ,
525
- BorrowKind :: Mut { allow_two_phase_borrow : false } ,
526
- arg. deref ( ) ) ;
527
-
528
- let ty = arg. ty ( caller_mir, self . tcx ) ;
529
- let ref_tmp = LocalDecl :: new_temp ( ty, callsite. location . span ) ;
530
- let ref_tmp = caller_mir. local_decls . push ( ref_tmp) ;
531
- let ref_tmp = Place :: Local ( ref_tmp) ;
532
-
533
- let ref_stmt = Statement {
534
- source_info : callsite. location ,
535
- kind : StatementKind :: Assign ( ref_tmp. clone ( ) , arg)
536
- } ;
537
-
538
- caller_mir[ callsite. bb ]
539
- . statements . push ( ref_stmt) ;
540
-
541
- let pointee_ty = match ptr_ty. sty {
542
- ty:: TyRawPtr ( tm) | ty:: TyRef ( _, tm) => tm. ty ,
543
- _ if ptr_ty. is_box ( ) => ptr_ty. boxed_ty ( ) ,
544
- _ => bug ! ( "Invalid type `{:?}` for call to box_free" , ptr_ty)
545
- } ;
546
- let ptr_ty = self . tcx . mk_mut_ptr ( pointee_ty) ;
547
-
548
- let raw_ptr = Rvalue :: Cast ( CastKind :: Misc , Operand :: Move ( ref_tmp) , ptr_ty) ;
549
-
550
- let cast_tmp = LocalDecl :: new_temp ( ptr_ty, callsite. location . span ) ;
551
- let cast_tmp = caller_mir. local_decls . push ( cast_tmp) ;
552
-
553
- let cast_stmt = Statement {
554
- source_info : callsite. location ,
555
- kind : StatementKind :: Assign ( Place :: Local ( cast_tmp) , raw_ptr)
556
- } ;
557
-
558
- caller_mir[ callsite. bb ]
559
- . statements . push ( cast_stmt) ;
560
-
561
- cast_tmp
562
- }
563
-
564
503
fn make_call_args (
565
504
& self ,
566
505
args : Vec < Operand < ' tcx > > ,
0 commit comments