rustc_codegen_ssa: use project_index, not project_field, for array literals.

This commit is contained in:
Eduard-Mihai Burtescu 2022-06-29 14:58:03 +00:00
parent 66c83ffca1
commit 900309ec8a

View File

@ -125,7 +125,12 @@ pub fn codegen_rvalue(
// Do not generate stores and GEPis for zero-sized fields.
if !op.layout.is_zst() {
let field_index = active_field_index.unwrap_or(i);
let field = dest.project_field(&mut bx, field_index);
let field = if let mir::AggregateKind::Array(_) = **kind {
let llindex = bx.cx().const_usize(field_index as u64);
dest.project_index(&mut bx, llindex)
} else {
dest.project_field(&mut bx, field_index)
};
op.val.store(&mut bx, field);
}
}