rustc: Initialize the drop flag with the new struct literal syntax. Closes #3172.

This commit is contained in:
Patrick Walton 2012-08-09 19:43:47 -07:00
parent b9b0d374d3
commit 770a21272b
2 changed files with 14 additions and 0 deletions

View File

@ -3515,6 +3515,12 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field],
}
}
// Add the drop flag if necessary.
if ty::ty_dtor(block_context.tcx(), class_id).is_some() {
let llflagptr = GEPi(block_context, dest_address, ~[0, 0]);
Store(block_context, C_u8(1), llflagptr);
}
// Now translate each field.
let mut temp_cleanups = ~[];
for fields.each |field| {

View File

@ -0,0 +1,8 @@
struct foo {
x: ~str;
drop { #error["%s", self.x]; }
}
fn main() {
let _z = foo { x: ~"Hello" };
}