about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2023-04-01 20:11:38 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2023-04-01 20:32:50 -0700
commitb5b6def021d37c5f1cb7e06c1cf6915bcbcd53b1 (patch)
tree417306b55b8f87daebb5962a774330552beb1337 /compiler/rustc_codegen_cranelift
parent480068c2359ea65df4481788b5ce717a548ce171 (diff)
downloadrust-b5b6def021d37c5f1cb7e06c1cf6915bcbcd53b1.tar.gz
rust-b5b6def021d37c5f1cb7e06c1cf6915bcbcd53b1.zip
Use `FieldIdx` in various things related to aggregates
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r--compiler/rustc_codegen_cranelift/src/base.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs
index 98112fe0830..2630f02e6eb 100644
--- a/compiler/rustc_codegen_cranelift/src/base.rs
+++ b/compiler/rustc_codegen_cranelift/src/base.rs
@@ -802,14 +802,15 @@ fn codegen_stmt<'tcx>(
                     if active_field_index.is_some() {
                         assert_eq!(operands.len(), 1);
                     }
-                    for (i, operand) in operands.iter().enumerate() {
+                    for (i, operand) in operands.iter_enumerated() {
                         let operand = codegen_operand(fx, operand);
                         let field_index = active_field_index.unwrap_or(i);
                         let to = if let mir::AggregateKind::Array(_) = **kind {
-                            let index = fx.bcx.ins().iconst(fx.pointer_type, field_index as i64);
+                            let array_index = i64::from(field_index.as_u32());
+                            let index = fx.bcx.ins().iconst(fx.pointer_type, array_index);
                             variant_dest.place_index(fx, index)
                         } else {
-                            variant_dest.place_field(fx, FieldIdx::new(field_index))
+                            variant_dest.place_field(fx, field_index)
                         };
                         to.write_cvalue(fx, operand);
                     }