Skip to content

Commit ea2c868

Browse files
committed
rustc: Perform type substitutions for tag variants in dynamic_size_of()
1 parent 1e65baa commit ea2c868

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/comp/middle/trans.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1020,9 +1020,17 @@ fn dynamic_size_of(@block_ctxt cx, @ty.t t) -> result {
10201020
let ValueRef max_size = bcx.build.Alloca(T_int());
10211021
bcx.build.Store(C_int(0), max_size);
10221022

1023+
auto ty_params = tag_ty_params(bcx.fcx.ccx, tid);
10231024
auto variants = tag_variants(bcx.fcx.ccx, tid);
10241025
for (ast.variant variant in variants) {
1025-
let vec[@ty.t] tys = variant_types(bcx.fcx.ccx, variant);
1026+
// Perform type substitution on the raw variant types.
1027+
let vec[@ty.t] raw_tys = variant_types(bcx.fcx.ccx, variant);
1028+
let vec[@ty.t] tys = vec();
1029+
for (@ty.t raw_ty in raw_tys) {
1030+
auto t = ty.substitute_ty_params(ty_params, tps, raw_ty);
1031+
tys += vec(t);
1032+
}
1033+
10261034
auto rslt = align_elements(bcx, tys);
10271035
bcx = rslt.bcx;
10281036

0 commit comments

Comments
 (0)