]> git.lizzy.rs Git - rust.git/commitdiff
assigning a (MIR) box into an lvalue allocates heap storage that will
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Tue, 15 Mar 2016 15:59:48 +0000 (16:59 +0100)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Mon, 21 Mar 2016 17:36:23 +0000 (18:36 +0100)
need to be initialized. create a MoveOut to represent that deref'ed
`*lval` path.

src/librustc_borrowck/borrowck/mir/gather_moves.rs

index a524a03f0f5bee23826992705ba3555399b8d56d..17a016a3ae300e5aa3ae125f9826c6f7c7f10881 100644 (file)
@@ -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 {