about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Koropoff <bkoropoff@gmail.com>2014-09-13 15:35:21 -0700
committerBrian Koropoff <bkoropoff@gmail.com>2014-09-13 15:35:21 -0700
commit5857ec6d78fec2cf457a5557d89677354eb7d0d1 (patch)
tree01b301a7d8823c7c31997d74ccb0102c49a981d8
parentccae356aced284a964910006af22dc005ea073a2 (diff)
downloadrust-5857ec6d78fec2cf457a5557d89677354eb7d0d1.tar.gz
rust-5857ec6d78fec2cf457a5557d89677354eb7d0d1.zip
Fix issue #17216
The cleanup scope of for loop bindings should translated when
popped to ensure resources are not leaked.
-rw-r--r--src/librustc/middle/trans/controlflow.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs
index 164ddd65f35..607b70317a8 100644
--- a/src/librustc/middle/trans/controlflow.rs
+++ b/src/librustc/middle/trans/controlflow.rs
@@ -357,7 +357,10 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 
     // Codegen the body.
     body_bcx_out = trans_block(body_bcx_out, body, expr::Ignore);
-    body_bcx_out.fcx.pop_custom_cleanup_scope(binding_cleanup_scope);
+    body_bcx_out =
+        body_bcx_out.fcx
+                    .pop_and_trans_custom_cleanup_scope(body_bcx_out,
+                                                        binding_cleanup_scope);
     body_bcx_out =
         body_bcx_out.fcx
                     .pop_and_trans_custom_cleanup_scope(body_bcx_out,