Skip to content

Commit 770a212

Browse files
committed
rustc: Initialize the drop flag with the new struct literal syntax. Closes #3172.
1 parent b9b0d37 commit 770a212

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,6 +3515,12 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field],
35153515
}
35163516
}
35173517

3518+
// Add the drop flag if necessary.
3519+
if ty::ty_dtor(block_context.tcx(), class_id).is_some() {
3520+
let llflagptr = GEPi(block_context, dest_address, ~[0, 0]);
3521+
Store(block_context, C_u8(1), llflagptr);
3522+
}
3523+
35183524
// Now translate each field.
35193525
let mut temp_cleanups = ~[];
35203526
for fields.each |field| {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
struct foo {
2+
x: ~str;
3+
drop { #error["%s", self.x]; }
4+
}
5+
6+
fn main() {
7+
let _z = foo { x: ~"Hello" };
8+
}

0 commit comments

Comments
 (0)