Skip to content

Commit dd99f58

Browse files
committedMar 21, 2016
assigning a (MIR) box into an lvalue allocates heap storage that will
need to be initialized. create a MoveOut to represent that deref'ed `*lval` path.
1 parent 5508c40 commit dd99f58

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/librustc_borrowck/borrowck/mir/gather_moves.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,11 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
554554
Rvalue::Box(ref _ty) => {
555555
// this is creating uninitialized
556556
// memory that needs to be initialized.
557-
bb_ctxt.on_move_out_lval(SK::Box, lval, source);
557+
let deref_lval = Lvalue::Projection(Box::new( repr::Projection {
558+
base: lval.clone(),
559+
elem: repr::ProjectionElem::Deref,
560+
}));
561+
bb_ctxt.on_move_out_lval(SK::Box, &deref_lval, source);
558562
}
559563
Rvalue::Aggregate(ref _kind, ref operands) => {
560564
for operand in operands {

0 commit comments

Comments
 (0)
Please sign in to comment.