Skip to content

Commit 5857ec6

Browse files
committed
Fix issue rust-lang#17216
The cleanup scope of for loop bindings should translated when popped to ensure resources are not leaked.
1 parent ccae356 commit 5857ec6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc/middle/trans/controlflow.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,10 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
357357

358358
// Codegen the body.
359359
body_bcx_out = trans_block(body_bcx_out, body, expr::Ignore);
360-
body_bcx_out.fcx.pop_custom_cleanup_scope(binding_cleanup_scope);
360+
body_bcx_out =
361+
body_bcx_out.fcx
362+
.pop_and_trans_custom_cleanup_scope(body_bcx_out,
363+
binding_cleanup_scope);
361364
body_bcx_out =
362365
body_bcx_out.fcx
363366
.pop_and_trans_custom_cleanup_scope(body_bcx_out,

0 commit comments

Comments
 (0)