Skip to content

Commit 900309e

Browse files
committed
rustc_codegen_ssa: use project_index, not project_field, for array literals.
1 parent 66c83ff commit 900309e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
125125
// Do not generate stores and GEPis for zero-sized fields.
126126
if !op.layout.is_zst() {
127127
let field_index = active_field_index.unwrap_or(i);
128-
let field = dest.project_field(&mut bx, field_index);
128+
let field = if let mir::AggregateKind::Array(_) = **kind {
129+
let llindex = bx.cx().const_usize(field_index as u64);
130+
dest.project_index(&mut bx, llindex)
131+
} else {
132+
dest.project_field(&mut bx, field_index)
133+
};
129134
op.val.store(&mut bx, field);
130135
}
131136
}

0 commit comments

Comments
 (0)