Skip to content

Commit aae2127

Browse files
committed
Encode the istr shape correctly. Issue #855
1 parent 6841f38 commit aae2127

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/comp/middle/shape.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,13 @@ fn shape_of(ccx: &@crate_ctxt, t: ty::t) -> [u8] {
308308
ty::ty_str. {
309309
s += [shape_evec, 1u8, 1u8, 0u8, shape_u8];
310310
}
311-
ty::ty_istr. { s += [shape_ivec, 1u8, 1u8, 0u8, shape_u8]; }
312-
311+
ty::ty_istr. {
312+
s += [shape_ivec];
313+
add_bool(s, true); // type is POD
314+
let unit_ty = ty::mk_mach(ccx.tcx, ast::ty_u8);
315+
add_size_hint(ccx, s, unit_ty);
316+
add_substr(s, shape_of(ccx, unit_ty));
317+
}
313318

314319
ty::ty_tag(did, tps) {
315320
alt tag_kind(ccx, did) {

src/test/run-pass/istr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ fn test_heap_assign() {
1616
s = ~"AAAA";
1717
}
1818

19+
fn test_heap_log() {
20+
let s = ~"a big ol' string";
21+
log s;
22+
}
23+
1924
fn main() {
2025
test_stack_assign();
2126
test_heap_lit();
2227
test_heap_assign();
28+
test_heap_log();
2329
}

0 commit comments

Comments
 (0)