Skip to content

Commit ef6d9fc

Browse files
committed
---
yaml --- r: 2072 b: refs/heads/master c: f374fa4 h: refs/heads/master v: v3
1 parent c870a83 commit ef6d9fc

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
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: 832ad0e04137ed2943fad44df71bcd06ed2ce511
2+
refs/heads/master: f374fa44b6a1581a9723b9c91d76b5518fbea2e8

trunk/src/comp/middle/trans.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef {
673673
case (ty.ty_char) { llty = T_char(); }
674674
case (ty.ty_str) { llty = T_ptr(T_str()); }
675675
case (ty.ty_tag(_, _)) {
676-
if (boxed) {
676+
if (ty.type_has_dynamic_size(t)) {
677677
llty = T_opaque_tag(cx.tn);
678678
} else {
679679
auto size = static_size_of_tag(cx, t);
@@ -1128,7 +1128,25 @@ fn static_size_of_tag(@crate_ctxt cx, @ty.t t) -> uint {
11281128
auto max_size = 0u;
11291129
auto variants = tag_variants(cx, tid);
11301130
for (variant_info variant in variants) {
1131-
auto tup_ty = ty.plain_tup_ty(variant.args);
1131+
1132+
let vec[@ty.t] args = vec();
1133+
for (@ty.t t in variant.args) {
1134+
alt (t.struct) {
1135+
// NB: We're just going for 'size' here, so we can do a little
1136+
// faking work here and substitute all boxes to boxed ints;
1137+
// this will break any tag cycles we might otherwise traverse
1138+
// (which would cause infinite recursion while measuring
1139+
// size).
1140+
case (ty.ty_box(_)) {
1141+
args += vec(ty.plain_box_ty(ty.plain_ty(ty.ty_int),
1142+
ast.imm));
1143+
}
1144+
case (_) {
1145+
args += vec(t);
1146+
}
1147+
}
1148+
}
1149+
auto tup_ty = ty.plain_tup_ty(args);
11321150

11331151
// Perform any type parameter substitutions.
11341152
tup_ty = ty.substitute_ty_params(ty_params, subtys, tup_ty);
@@ -4420,9 +4438,6 @@ fn trans_args(@block_ctxt cx,
44204438
}
44214439
}
44224440

4423-
val = bcx.build.PointerCast(val, lldestty);
4424-
} else if (mode == ast.alias) {
4425-
auto lldestty = arg_tys.(i);
44264441
val = bcx.build.PointerCast(val, lldestty);
44274442
}
44284443

0 commit comments

Comments
 (0)