Skip to content

Commit 27aab83

Browse files
committed
Convert trans_tuple_struct to trans::adt.
Surely this cannot be the best way to get the type.
1 parent 7cfb66c commit 27aab83

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,8 +1945,23 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
19451945
let arg_tys = ty::ty_fn_args(node_id_type(bcx, ctor_id));
19461946
let bcx = copy_args_to_allocas(fcx, bcx, fn_args, raw_llargs, arg_tys);
19471947
1948+
// XXX is there a better way to reconstruct the ty::t?
1949+
let ty_param_substs = match param_substs {
1950+
Some(ref substs) => /*bad*/copy substs.tys,
1951+
None => ~[]
1952+
};
1953+
let ctor_ty = ty::subst_tps(ccx.tcx, ty_param_substs, None,
1954+
ty::node_id_to_type(ccx.tcx, ctor_id));
1955+
let tup_ty = match ty::get(ctor_ty).sty {
1956+
ty::ty_bare_fn(ref bft) => bft.sig.output,
1957+
_ => ccx.sess.bug(fmt!("trans_tuple_struct: unexpected ctor \
1958+
return type %s",
1959+
ty_to_str(ccx.tcx, ctor_ty)))
1960+
};
1961+
let repr = adt::represent_type(ccx, tup_ty);
1962+
19481963
for fields.eachi |i, field| {
1949-
let lldestptr = GEPi(bcx, fcx.llretptr, [0, 0, i]);
1964+
let lldestptr = adt::trans_GEP(bcx, &repr, fcx.llretptr, 0, i);
19501965
let llarg = match fcx.llargs.get(&field.node.id) {
19511966
local_mem(x) => x,
19521967
_ => {

0 commit comments

Comments
 (0)