From bd0a849f3b0fcc88743dc8d29cf69dd983ed5dbc Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sun, 6 Mar 2016 13:23:43 +0200 Subject: [PATCH] trans: datum::lvalue_scratch_datum doesn't need a move-into-closure trick. --- src/librustc_trans/trans/adt.rs | 2 +- src/librustc_trans/trans/datum.rs | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 798fbbe8fbf5..436963ec26d4 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -1277,7 +1277,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let scratch = unpack_datum!(bcx, datum::lvalue_scratch_datum( bcx, tcx.dtor_type(), "drop_flag", InitAlloca::Uninit("drop flag itself has no dtor"), - cleanup::CustomScope(custom_cleanup_scope), (), |_, bcx, _| { + cleanup::CustomScope(custom_cleanup_scope), |bcx, _| { debug!("no-op populate call for trans_drop_flag_ptr on dtor_type={:?}", tcx.dtor_type()); bcx diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index c1353b4f681e..649f6180de20 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -306,15 +306,14 @@ pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, /// caller can prove that either (1.) the code injected by `populate` /// onto `bcx` always dominates the end of `scope`, or (2.) the data /// being allocated has no associated destructor. -pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>, - ty: Ty<'tcx>, - name: &str, - zero: InitAlloca, - scope: cleanup::ScopeId, - arg: A, - populate: F) - -> DatumBlock<'blk, 'tcx, Lvalue> where - F: FnOnce(A, Block<'blk, 'tcx>, ValueRef) -> Block<'blk, 'tcx>, +pub fn lvalue_scratch_datum<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, + ty: Ty<'tcx>, + name: &str, + zero: InitAlloca, + scope: cleanup::ScopeId, + populate: F) + -> DatumBlock<'blk, 'tcx, Lvalue> where + F: FnOnce(Block<'blk, 'tcx>, ValueRef) -> Block<'blk, 'tcx>, { // Very subtle: potentially initialize the scratch memory at point where it is alloca'ed. // (See discussion at Issue 30530.) @@ -323,7 +322,7 @@ pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>, scope, Value(scratch), ty); // Subtle. Populate the scratch memory *before* scheduling cleanup. - let bcx = populate(arg, bcx, scratch); + let bcx = populate(bcx, scratch); bcx.fcx.schedule_drop_mem(scope, scratch, ty, None); DatumBlock::new(bcx, Datum::new(scratch, ty, Lvalue::new("datum::lvalue_scratch_datum"))) @@ -517,14 +516,14 @@ impl<'tcx> Datum<'tcx, Rvalue> { ByValue => { lvalue_scratch_datum( - bcx, self.ty, name, InitAlloca::Dropped, scope, self, - |this, bcx, llval| { + bcx, self.ty, name, InitAlloca::Dropped, scope, + |bcx, llval| { debug!("populate call for Datum::to_lvalue_datum_in_scope \ - self.ty={:?}", this.ty); + self.ty={:?}", self.ty); // do not call_lifetime_start here; the // `InitAlloc::Dropped` will start scratch // value's lifetime at open of function body. - let bcx = this.store_to(bcx, llval); + let bcx = self.store_to(bcx, llval); bcx.fcx.schedule_lifetime_end(scope, llval); bcx })