@@ -479,9 +479,10 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
479479
480480 fn array_shim ( & mut self , ty : ty:: Ty < ' tcx > , len : usize ) {
481481 let tcx = self . tcx ;
482+ let span = self . span ;
482483 let rcvr = Lvalue :: Local ( Local :: new ( 1 +0 ) ) . deref ( ) ;
483484
484- let beg = self . make_lvalue ( Mutability :: Mut , tcx. types . usize ) ;
485+ let beg = self . local_decls . push ( temp_decl ( Mutability :: Mut , tcx. types . usize , span ) ) ;
485486 let end = self . make_lvalue ( Mutability :: Not , tcx. types . usize ) ;
486487 let ret = self . make_lvalue ( Mutability :: Mut , tcx. mk_array ( ty, len) ) ;
487488
@@ -492,7 +493,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
492493 let inits = vec ! [
493494 self . make_statement(
494495 StatementKind :: Assign (
495- beg . clone ( ) ,
496+ Lvalue :: Local ( beg ) ,
496497 Rvalue :: Use ( Operand :: Constant ( self . make_usize( 0 ) ) )
497498 )
498499 ) ,
@@ -510,19 +511,19 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
510511 // BB #3;
511512 // }
512513 // BB #4;
513- self . loop_header ( beg . clone ( ) , end, BasicBlock :: new ( 2 ) , BasicBlock :: new ( 4 ) , false ) ;
514+ self . loop_header ( Lvalue :: Local ( beg ) , end, BasicBlock :: new ( 2 ) , BasicBlock :: new ( 4 ) , false ) ;
514515
515516 // BB #2
516517 // `let cloned = Clone::clone(rcvr[beg])`;
517518 // Goto #3 if ok, #5 if unwinding happens.
518- let rcvr_field = rcvr. clone ( ) . index ( Operand :: Consume ( beg. clone ( ) ) ) ;
519+ let rcvr_field = rcvr. clone ( ) . index ( beg) ;
519520 let cloned = self . make_clone_call ( ty, rcvr_field, BasicBlock :: new ( 3 ) , BasicBlock :: new ( 5 ) ) ;
520521
521522 // BB #3
522523 // `ret[beg] = cloned;`
523524 // `beg = beg + 1;`
524525 // `goto #1`;
525- let ret_field = ret. clone ( ) . index ( Operand :: Consume ( beg. clone ( ) ) ) ;
526+ let ret_field = ret. clone ( ) . index ( beg) ;
526527 let statements = vec ! [
527528 self . make_statement(
528529 StatementKind :: Assign (
@@ -532,10 +533,10 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
532533 ) ,
533534 self . make_statement(
534535 StatementKind :: Assign (
535- beg . clone ( ) ,
536+ Lvalue :: Local ( beg ) ,
536537 Rvalue :: BinaryOp (
537538 BinOp :: Add ,
538- Operand :: Consume ( beg . clone ( ) ) ,
539+ Operand :: Consume ( Lvalue :: Local ( beg ) ) ,
539540 Operand :: Constant ( self . make_usize( 1 ) )
540541 )
541542 )
@@ -558,10 +559,10 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
558559 // `let mut beg = 0;`
559560 // goto #6;
560561 let end = beg;
561- let beg = self . make_lvalue ( Mutability :: Mut , tcx. types . usize ) ;
562+ let beg = self . local_decls . push ( temp_decl ( Mutability :: Mut , tcx. types . usize , span ) ) ;
562563 let init = self . make_statement (
563564 StatementKind :: Assign (
564- beg . clone ( ) ,
565+ Lvalue :: Local ( beg ) ,
565566 Rvalue :: Use ( Operand :: Constant ( self . make_usize ( 0 ) ) )
566567 )
567568 ) ;
@@ -572,12 +573,13 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
572573 // BB #8;
573574 // }
574575 // BB #9;
575- self . loop_header ( beg. clone ( ) , end, BasicBlock :: new ( 7 ) , BasicBlock :: new ( 9 ) , true ) ;
576+ self . loop_header ( Lvalue :: Local ( beg) , Lvalue :: Local ( end) ,
577+ BasicBlock :: new ( 7 ) , BasicBlock :: new ( 9 ) , true ) ;
576578
577579 // BB #7 (cleanup)
578580 // `drop(ret[beg])`;
579581 self . block ( vec ! [ ] , TerminatorKind :: Drop {
580- location : ret. index ( Operand :: Consume ( beg. clone ( ) ) ) ,
582+ location : ret. index ( beg) ,
581583 target : BasicBlock :: new ( 8 ) ,
582584 unwind : None ,
583585 } , true ) ;
@@ -587,10 +589,10 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
587589 // `goto #6;`
588590 let statement = self . make_statement (
589591 StatementKind :: Assign (
590- beg . clone ( ) ,
592+ Lvalue :: Local ( beg ) ,
591593 Rvalue :: BinaryOp (
592594 BinOp :: Add ,
593- Operand :: Consume ( beg . clone ( ) ) ,
595+ Operand :: Consume ( Lvalue :: Local ( beg ) ) ,
594596 Operand :: Constant ( self . make_usize ( 1 ) )
595597 )
596598 )
0 commit comments