Skip to content

Commit ea8a43a

Browse files
committed
---
yaml --- r: 1592 b: refs/heads/master c: 36b81ab h: refs/heads/master v: v3
1 parent 67418ab commit ea8a43a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 7505c1fa2319adbd928847ca27f75f5a95eb7c3d
2+
refs/heads/master: 36b81abf619171ccbdee8ca6471f340c5a4e0ed5

trunk/src/comp/middle/trans.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4050,7 +4050,27 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
40504050
bcx = src_res.bcx;
40514051
auto dst_res = GEP_tup_like(bcx, pseudo_tup_ty, body, vec(0, i));
40524052
bcx = dst_res.bcx;
4053-
bcx = copy_ty(bcx, INIT, dst_res.val, src_res.val, unit_ty).bcx;
4053+
4054+
// Cast the destination type to the source type. This is needed to
4055+
// make tags work, for a subtle combination of reasons:
4056+
//
4057+
// (1) "dst_res" above is derived from "body", which is in turn
4058+
// derived from "vec_val".
4059+
// (2) "vec_val" has the LLVM type "llty".
4060+
// (3) "llty" is the result of calling type_of() on a vector type.
4061+
// (4) For tags, type_of() returns a different type depending on
4062+
// on whether the tag is behind a box or not. Vector types are
4063+
// considered boxes.
4064+
// (5) "src_res" is derived from "unit_ty", which is not behind a box.
4065+
4066+
auto dst_val;
4067+
if (!ty.type_has_dynamic_size(unit_ty)) {
4068+
dst_val = bcx.build.PointerCast(dst_res.val, T_ptr(llunit_ty));
4069+
} else {
4070+
dst_val = dst_res.val;
4071+
}
4072+
4073+
bcx = copy_ty(bcx, INIT, dst_val, src_res.val, unit_ty).bcx;
40544074
i += 1;
40554075
}
40564076
auto fill = bcx.build.GEP(vec_val,

0 commit comments

Comments
 (0)