From 432e931a2ab6a0e642a39f71b15e86dd3bfe3c9a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 19 Sep 2011 13:11:26 -0700 Subject: [PATCH] Don't register record cleanups until the record is built --- src/comp/middle/trans.rs | 2 +- src/test/run-fail/unwind-rec.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/test/run-fail/unwind-rec.rs diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 0d89296594b..5cddc193529 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3961,7 +3961,6 @@ fn trans_rec(cx: @block_ctxt, fields: [ast::field], let rec_res = alloc_ty(bcx, t); let rec_val = rec_res.val; bcx = rec_res.bcx; - add_clean_temp(cx, rec_val, t); let i: int = 0; let base_val = C_nil(); alt base { @@ -4000,6 +3999,7 @@ fn trans_rec(cx: @block_ctxt, fields: [ast::field], } i += 1; } + add_clean_temp(cx, rec_val, t); ret rslt(bcx, rec_val); } diff --git a/src/test/run-fail/unwind-rec.rs b/src/test/run-fail/unwind-rec.rs new file mode 100644 index 00000000000..c6dd2d0abdf --- /dev/null +++ b/src/test/run-fail/unwind-rec.rs @@ -0,0 +1,11 @@ +// error-pattern:fail + +fn build() -> [int] { + fail; +} + +fn main() { + let blk = { + node: build() + }; +} \ No newline at end of file