Skip to content

Commit

Permalink
Run cleanups during unwinding
Browse files Browse the repository at this point in the history
Issue #236
  • Loading branch information
brson committed Sep 12, 2011
1 parent 587b863 commit 4c9eee8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/run-fail/unwind-box.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// error-pattern:fail

fn failfn() {
fail;
}

fn main() {
@0;
failfn();
}

0 comments on commit 4c9eee8

Please sign in to comment.