Skip to content

Commit 4c9eee8

Browse files
committed
Run cleanups during unwinding
Issue #236
1 parent 587b863 commit 4c9eee8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/comp/middle/trans.rs

+12
Original file line numberDiff line numberDiff line change
@@ -3823,6 +3823,18 @@ fn trans_landing_pad(bcx: &@block_ctxt) {
38233823
let llretval = llpad;
38243824
// The landing pad block is a cleanup
38253825
SetCleanup(bcx, llpad);
3826+
3827+
let bcx = bcx;
3828+
let scope_cx = bcx;
3829+
while true {
3830+
scope_cx = find_scope_cx(scope_cx);
3831+
bcx = trans_block_cleanups(bcx, scope_cx);
3832+
scope_cx = alt scope_cx.parent {
3833+
parent_some(b) { b }
3834+
parent_none. { break; }
3835+
};
3836+
}
3837+
38263838
// Continue unwinding
38273839
Resume(bcx, llretval);
38283840
}

src/test/run-fail/unwind-box.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// error-pattern:fail
2+
3+
fn failfn() {
4+
fail;
5+
}
6+
7+
fn main() {
8+
@0;
9+
failfn();
10+
}

0 commit comments

Comments
 (0)