From 4c9eee8aa42891ac2a165eb3bbae9c16e4ee438d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 7 Sep 2011 15:12:37 -0700 Subject: [PATCH] Run cleanups during unwinding Issue #236 --- src/comp/middle/trans.rs | 12 ++++++++++++ src/test/run-fail/unwind-box.rs | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/run-fail/unwind-box.rs diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index f90c5a15fb08..aa82e03d57b4 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3823,6 +3823,18 @@ fn trans_landing_pad(bcx: &@block_ctxt) { let llretval = llpad; // The landing pad block is a cleanup SetCleanup(bcx, llpad); + + let bcx = bcx; + let scope_cx = bcx; + while true { + scope_cx = find_scope_cx(scope_cx); + bcx = trans_block_cleanups(bcx, scope_cx); + scope_cx = alt scope_cx.parent { + parent_some(b) { b } + parent_none. { break; } + }; + } + // Continue unwinding Resume(bcx, llretval); } diff --git a/src/test/run-fail/unwind-box.rs b/src/test/run-fail/unwind-box.rs new file mode 100644 index 000000000000..19906bda0ae7 --- /dev/null +++ b/src/test/run-fail/unwind-box.rs @@ -0,0 +1,10 @@ +// error-pattern:fail + +fn failfn() { + fail; +} + +fn main() { + @0; + failfn(); +} \ No newline at end of file