Skip to content

Commit

Permalink
Fix generation of str/@. Closes #2638.
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan committed Jun 18, 2012
1 parent 797856c commit 30dd32d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/rt/rust_upcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ upcall_s_str_new_shared(s_str_new_shared_args *args) {
size_t str_fill = args->len + 1;
size_t str_alloc = str_fill;
args->retval = (rust_opaque_box *)
task->boxed.malloc(&str_body_tydesc, str_fill);
rust_str *str = (rust_str *)box_body(args->retval);
task->boxed.malloc(&str_body_tydesc,
str_fill + sizeof(rust_vec));
rust_str *str = (rust_str *)args->retval;
str->body.fill = str_fill;
str->body.alloc = str_alloc;
memcpy(&str->body.data, args->cstr, args->len);
Expand Down
4 changes: 3 additions & 1 deletion src/rustc/middle/trans/tvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ fn trans_estr(bcx: block, s: @str, vstore: ast::vstore,
ast::vstore_box {
let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(*s));
Call(bcx, ccx.upcalls.str_new_shared, [cs, len])
let c = Call(bcx, ccx.upcalls.str_new_shared, [cs, len]);
PointerCast(bcx, c,
T_box_ptr(T_box(ccx, T_vec(ccx, T_i8()))))
}
};

Expand Down
4 changes: 3 additions & 1 deletion src/rustc/middle/trans/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
T_unique_ptr(T_unique(cx, T_vec(cx, T_i8())))
}
ty::ty_enum(did, _) { type_of_enum(cx, did, t) }
ty::ty_estr(ty::vstore_box) { T_box_ptr(T_box(cx, T_i8())) }
ty::ty_estr(ty::vstore_box) {
T_box_ptr(T_box(cx, T_vec(cx, T_i8())))
}
ty::ty_evec(mt, ty::vstore_box) {
T_box_ptr(T_box(cx, T_vec(cx, type_of(cx, mt.ty))))
}
Expand Down

0 comments on commit 30dd32d

Please sign in to comment.