Skip to content

Commit e07aecd

Browse files
committed
Make make_clone_call take a Place argument
1 parent def3269 commit e07aecd

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/librustc_mir/shim.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
407407
ty: Ty<'tcx>,
408408
rcvr_field: Place<'tcx>,
409409
next: BasicBlock,
410-
cleanup: BasicBlock
411-
) -> Place<'tcx> {
410+
cleanup: BasicBlock,
411+
place: Place<'tcx>
412+
) {
412413
let tcx = self.tcx;
413414

414415
let substs = Substs::for_item(
@@ -439,8 +440,6 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
439440
})
440441
);
441442

442-
let loc = self.make_place(Mutability::Not, ty);
443-
444443
// `let ref_loc: &ty = &rcvr_field;`
445444
let statement = self.make_statement(
446445
StatementKind::Assign(
@@ -453,11 +452,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
453452
self.block(vec![statement], TerminatorKind::Call {
454453
func,
455454
args: vec![Operand::Move(ref_loc)],
456-
destination: Some((loc.clone(), next)),
455+
destination: Some((place, next)),
457456
cleanup: Some(cleanup),
458457
}, false);
459-
460-
loc
461458
}
462459

463460
fn loop_header(
@@ -540,7 +537,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
540537
// `let cloned = Clone::clone(rcvr[beg])`;
541538
// Goto #3 if ok, #5 if unwinding happens.
542539
let rcvr_field = rcvr.clone().index(beg);
543-
let cloned = self.make_clone_call(ty, rcvr_field, BasicBlock::new(3), BasicBlock::new(5));
540+
let cloned = self.make_place(Mutability::Not, ty);
541+
self.make_clone_call(ty, rcvr_field, BasicBlock::new(3),
542+
BasicBlock::new(5), cloned.clone());
544543

545544
// BB #3
546545
// `ret[beg] = cloned;`
@@ -638,16 +637,18 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
638637
for (i, ity) in tys.iter().enumerate() {
639638
let rcvr_field = rcvr.clone().field(Field::new(i), *ity);
640639

640+
let place = self.make_place(Mutability::Not, ity);
641+
returns.push(place.clone());
642+
641643
// BB #(2i)
642644
// `returns[i] = Clone::clone(&rcvr.i);`
643645
// Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens.
644-
returns.push(
645-
self.make_clone_call(
646-
*ity,
647-
rcvr_field,
648-
BasicBlock::new(2 * i + 2),
649-
BasicBlock::new(2 * i + 1),
650-
)
646+
self.make_clone_call(
647+
*ity,
648+
rcvr_field,
649+
BasicBlock::new(2 * i + 2),
650+
BasicBlock::new(2 * i + 1),
651+
place
651652
);
652653

653654
// BB #(2i + 1) (cleanup)

0 commit comments

Comments
 (0)