Skip to content

Commit baf4744

Browse files
committed
rustc: Increment by the unit size in iter_structural_ty when iterating over interior vectors if the unit size is dynamic
1 parent 2ebd194 commit baf4744

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,10 +2504,18 @@ fn iter_structural_ty_full(&@block_ctxt cx, ValueRef av, ValueRef bv,
25042504
load_if_immediate(loop_body_cx, src_elem, unit_ty), unit_ty);
25052505

25062506
loop_body_cx = rs.bcx;
2507+
2508+
auto increment;
2509+
if (ty::type_has_dynamic_size(bcx.fcx.lcx.ccx.tcx, unit_ty)) {
2510+
increment = unit_sz;
2511+
} else {
2512+
increment = C_int(1);
2513+
}
2514+
25072515
loop_body_cx.build.Store(loop_body_cx.build.InBoundsGEP(dest_elem,
2508-
[C_int(1)]), dest_elem_ptr);
2516+
[increment]), dest_elem_ptr);
25092517
loop_body_cx.build.Store(loop_body_cx.build.InBoundsGEP(src_elem,
2510-
[C_int(1)]), src_elem_ptr);
2518+
[increment]), src_elem_ptr);
25112519
loop_body_cx.build.Br(loop_header_cx.llbb);
25122520

25132521
ret rslt(next_cx, C_nil());

0 commit comments

Comments
 (0)