Skip to content

Commit 24f213d

Browse files
committed
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.
1 parent b0a4808 commit 24f213d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librustc_trans/trans/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
916916

917917
let datum = Datum::new(llval, binding_info.ty, Lvalue);
918918
if let Some(cs) = cs {
919-
bcx.fcx.schedule_drop_and_fill_mem(cs, llval, binding_info.ty);
920919
bcx.fcx.schedule_lifetime_end(cs, binding_info.llmatch);
920+
bcx.fcx.schedule_drop_and_fill_mem(cs, llval, binding_info.ty);
921921
}
922922

923923
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));

0 commit comments

Comments
 (0)