@@ -310,7 +310,6 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -
310
310
311
311
match self_ty. kind ( ) {
312
312
_ if is_copy => builder. copy_shim ( ) ,
313
- ty:: Array ( ty, len) => builder. array_shim ( dest, src, ty, len) ,
314
313
ty:: Closure ( _, substs) => {
315
314
builder. tuple_like_shim ( dest, src, substs. as_closure ( ) . upvar_tys ( ) )
316
315
}
@@ -459,154 +458,6 @@ impl CloneShimBuilder<'tcx> {
459
458
) ;
460
459
}
461
460
462
- fn loop_header (
463
- & mut self ,
464
- beg : Place < ' tcx > ,
465
- end : Place < ' tcx > ,
466
- loop_body : BasicBlock ,
467
- loop_end : BasicBlock ,
468
- is_cleanup : bool ,
469
- ) {
470
- let tcx = self . tcx ;
471
-
472
- let cond = self . make_place ( Mutability :: Mut , tcx. types . bool ) ;
473
- let compute_cond = self . make_statement ( StatementKind :: Assign ( Box :: new ( (
474
- cond,
475
- Rvalue :: BinaryOp ( BinOp :: Ne , Box :: new ( ( Operand :: Copy ( end) , Operand :: Copy ( beg) ) ) ) ,
476
- ) ) ) ) ;
477
-
478
- // `if end != beg { goto loop_body; } else { goto loop_end; }`
479
- self . block (
480
- vec ! [ compute_cond] ,
481
- TerminatorKind :: if_ ( tcx, Operand :: Move ( cond) , loop_body, loop_end) ,
482
- is_cleanup,
483
- ) ;
484
- }
485
-
486
- fn make_usize ( & self , value : u64 ) -> Box < Constant < ' tcx > > {
487
- Box :: new ( Constant {
488
- span : self . span ,
489
- user_ty : None ,
490
- literal : ty:: Const :: from_usize ( self . tcx , value) . into ( ) ,
491
- } )
492
- }
493
-
494
- fn array_shim (
495
- & mut self ,
496
- dest : Place < ' tcx > ,
497
- src : Place < ' tcx > ,
498
- ty : Ty < ' tcx > ,
499
- len : & ' tcx ty:: Const < ' tcx > ,
500
- ) {
501
- let tcx = self . tcx ;
502
- let span = self . span ;
503
-
504
- let beg = self . local_decls . push ( LocalDecl :: new ( tcx. types . usize , span) ) ;
505
- let end = self . make_place ( Mutability :: Not , tcx. types . usize ) ;
506
-
507
- // BB #0
508
- // `let mut beg = 0;`
509
- // `let end = len;`
510
- // `goto #1;`
511
- let inits = vec ! [
512
- self . make_statement( StatementKind :: Assign ( Box :: new( (
513
- Place :: from( beg) ,
514
- Rvalue :: Use ( Operand :: Constant ( self . make_usize( 0 ) ) ) ,
515
- ) ) ) ) ,
516
- self . make_statement( StatementKind :: Assign ( Box :: new( (
517
- end,
518
- Rvalue :: Use ( Operand :: Constant ( Box :: new( Constant {
519
- span: self . span,
520
- user_ty: None ,
521
- literal: len. into( ) ,
522
- } ) ) ) ,
523
- ) ) ) ) ,
524
- ] ;
525
- self . block ( inits, TerminatorKind :: Goto { target : BasicBlock :: new ( 1 ) } , false ) ;
526
-
527
- // BB #1: loop {
528
- // BB #2;
529
- // BB #3;
530
- // }
531
- // BB #4;
532
- self . loop_header ( Place :: from ( beg) , end, BasicBlock :: new ( 2 ) , BasicBlock :: new ( 4 ) , false ) ;
533
-
534
- // BB #2
535
- // `dest[i] = Clone::clone(src[beg])`;
536
- // Goto #3 if ok, #5 if unwinding happens.
537
- let dest_field = self . tcx . mk_place_index ( dest, beg) ;
538
- let src_field = self . tcx . mk_place_index ( src, beg) ;
539
- self . make_clone_call ( dest_field, src_field, ty, BasicBlock :: new ( 3 ) , BasicBlock :: new ( 5 ) ) ;
540
-
541
- // BB #3
542
- // `beg = beg + 1;`
543
- // `goto #1`;
544
- let statements = vec ! [ self . make_statement( StatementKind :: Assign ( Box :: new( (
545
- Place :: from( beg) ,
546
- Rvalue :: BinaryOp (
547
- BinOp :: Add ,
548
- Box :: new( ( Operand :: Copy ( Place :: from( beg) ) , Operand :: Constant ( self . make_usize( 1 ) ) ) ) ,
549
- ) ,
550
- ) ) ) ) ] ;
551
- self . block ( statements, TerminatorKind :: Goto { target : BasicBlock :: new ( 1 ) } , false ) ;
552
-
553
- // BB #4
554
- // `return dest;`
555
- self . block ( vec ! [ ] , TerminatorKind :: Return , false ) ;
556
-
557
- // BB #5 (cleanup)
558
- // `let end = beg;`
559
- // `let mut beg = 0;`
560
- // goto #6;
561
- let end = beg;
562
- let beg = self . local_decls . push ( LocalDecl :: new ( tcx. types . usize , span) ) ;
563
- let init = self . make_statement ( StatementKind :: Assign ( Box :: new ( (
564
- Place :: from ( beg) ,
565
- Rvalue :: Use ( Operand :: Constant ( self . make_usize ( 0 ) ) ) ,
566
- ) ) ) ) ;
567
- self . block ( vec ! [ init] , TerminatorKind :: Goto { target : BasicBlock :: new ( 6 ) } , true ) ;
568
-
569
- // BB #6 (cleanup): loop {
570
- // BB #7;
571
- // BB #8;
572
- // }
573
- // BB #9;
574
- self . loop_header (
575
- Place :: from ( beg) ,
576
- Place :: from ( end) ,
577
- BasicBlock :: new ( 7 ) ,
578
- BasicBlock :: new ( 9 ) ,
579
- true ,
580
- ) ;
581
-
582
- // BB #7 (cleanup)
583
- // `drop(dest[beg])`;
584
- self . block (
585
- vec ! [ ] ,
586
- TerminatorKind :: Drop {
587
- place : self . tcx . mk_place_index ( dest, beg) ,
588
- target : BasicBlock :: new ( 8 ) ,
589
- unwind : None ,
590
- } ,
591
- true ,
592
- ) ;
593
-
594
- // BB #8 (cleanup)
595
- // `beg = beg + 1;`
596
- // `goto #6;`
597
- let statement = self . make_statement ( StatementKind :: Assign ( Box :: new ( (
598
- Place :: from ( beg) ,
599
- Rvalue :: BinaryOp (
600
- BinOp :: Add ,
601
- Box :: new ( ( Operand :: Copy ( Place :: from ( beg) ) , Operand :: Constant ( self . make_usize ( 1 ) ) ) ) ,
602
- ) ,
603
- ) ) ) ) ;
604
- self . block ( vec ! [ statement] , TerminatorKind :: Goto { target : BasicBlock :: new ( 6 ) } , true ) ;
605
-
606
- // BB #9 (resume)
607
- self . block ( vec ! [ ] , TerminatorKind :: Resume , true ) ;
608
- }
609
-
610
461
fn tuple_like_shim < I > ( & mut self , dest : Place < ' tcx > , src : Place < ' tcx > , tys : I )
611
462
where
612
463
I : Iterator < Item = Ty < ' tcx > > ,
0 commit comments