From 24f213d0231c04c2bde1ca65bb5dc93df7c4aaa7 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 27 Apr 2015 16:08:30 +0200 Subject: [PATCH] drive-by fix: scheduled drops are executed in reverse order. That is, scheduled drops are executed in reverse order, so for correctness, we *schedule* the lifetime end before we schedule the drop, so that when they are executed, the drop will be executed *before* the lifetime end. --- src/librustc_trans/trans/_match.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 1aa996a05ac..41d32304582 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -916,8 +916,8 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let datum = Datum::new(llval, binding_info.ty, Lvalue); if let Some(cs) = cs { - bcx.fcx.schedule_drop_and_fill_mem(cs, llval, binding_info.ty); bcx.fcx.schedule_lifetime_end(cs, binding_info.llmatch); + bcx.fcx.schedule_drop_and_fill_mem(cs, llval, binding_info.ty); } debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));