rustc: Initialize the drop flag with the new struct literal syntax. Closes #3172.
This commit is contained in:
parent
b9b0d374d3
commit
770a21272b
@ -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| {
|
||||
|
8
src/test/run-pass/struct-literal-dtor.rs
Normal file
8
src/test/run-pass/struct-literal-dtor.rs
Normal file
@ -0,0 +1,8 @@
|
||||
struct foo {
|
||||
x: ~str;
|
||||
drop { #error["%s", self.x]; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _z = foo { x: ~"Hello" };
|
||||
}
|
Loading…
Reference in New Issue
Block a user