Skip to content

Commit 30dd32d

Browse files
committed
Fix generation of str/@. Closes #2638.
1 parent 797856c commit 30dd32d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/rt/rust_upcall.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ upcall_s_str_new_shared(s_str_new_shared_args *args) {
373373
size_t str_fill = args->len + 1;
374374
size_t str_alloc = str_fill;
375375
args->retval = (rust_opaque_box *)
376-
task->boxed.malloc(&str_body_tydesc, str_fill);
377-
rust_str *str = (rust_str *)box_body(args->retval);
376+
task->boxed.malloc(&str_body_tydesc,
377+
str_fill + sizeof(rust_vec));
378+
rust_str *str = (rust_str *)args->retval;
378379
str->body.fill = str_fill;
379380
str->body.alloc = str_alloc;
380381
memcpy(&str->body.data, args->cstr, args->len);

src/rustc/middle/trans/tvec.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ fn trans_estr(bcx: block, s: @str, vstore: ast::vstore,
290290
ast::vstore_box {
291291
let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
292292
let len = C_uint(ccx, str::len(*s));
293-
Call(bcx, ccx.upcalls.str_new_shared, [cs, len])
293+
let c = Call(bcx, ccx.upcalls.str_new_shared, [cs, len]);
294+
PointerCast(bcx, c,
295+
T_box_ptr(T_box(ccx, T_vec(ccx, T_i8()))))
294296
}
295297
};
296298

src/rustc/middle/trans/type_of.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
9393
T_unique_ptr(T_unique(cx, T_vec(cx, T_i8())))
9494
}
9595
ty::ty_enum(did, _) { type_of_enum(cx, did, t) }
96-
ty::ty_estr(ty::vstore_box) { T_box_ptr(T_box(cx, T_i8())) }
96+
ty::ty_estr(ty::vstore_box) {
97+
T_box_ptr(T_box(cx, T_vec(cx, T_i8())))
98+
}
9799
ty::ty_evec(mt, ty::vstore_box) {
98100
T_box_ptr(T_box(cx, T_vec(cx, type_of(cx, mt.ty))))
99101
}

0 commit comments

Comments
 (0)