about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2016-03-15 16:59:48 +0100
committerFelix S. Klock II <pnkfelix@pnkfx.org>2016-03-21 18:36:23 +0100
commitdd99f58fe15134b42c6f74225107a08f267046f2 (patch)
treee509706e57334824128f6a42e009f2b9e324306c
parent5508c40d0494fbb2f5e83a4bb37d86cb0c04c76e (diff)
downloadrust-dd99f58fe15134b42c6f74225107a08f267046f2.tar.gz
rust-dd99f58fe15134b42c6f74225107a08f267046f2.zip
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.
-rw-r--r--src/librustc_borrowck/borrowck/mir/gather_moves.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_borrowck/borrowck/mir/gather_moves.rs b/src/librustc_borrowck/borrowck/mir/gather_moves.rs
index a524a03f0f5..17a016a3ae3 100644
--- a/src/librustc_borrowck/borrowck/mir/gather_moves.rs
+++ b/src/librustc_borrowck/borrowck/mir/gather_moves.rs
@@ -554,7 +554,11 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> MoveData<'tcx>
                         Rvalue::Box(ref _ty) => {
                             // this is creating uninitialized
                             // memory that needs to be initialized.
-                            bb_ctxt.on_move_out_lval(SK::Box, lval, source);
+                            let deref_lval = Lvalue::Projection(Box::new( repr::Projection {
+                                base: lval.clone(),
+                                elem: repr::ProjectionElem::Deref,
+                            }));
+                            bb_ctxt.on_move_out_lval(SK::Box, &deref_lval, source);
                         }
                         Rvalue::Aggregate(ref _kind, ref operands) => {
                             for operand in operands {