about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2024-05-11 15:26:49 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2024-05-11 21:22:51 -0700
commit99213ae164e42966f8dd37fe9f64a1e138fdf500 (patch)
treed78b7a00c9f481b95eca4112bc2f413e06b0e3dc /compiler/rustc_codegen_ssa/src
parentdcab06d7d206a1e061233c0e251deb06ef0c1300 (diff)
downloadrust-99213ae164e42966f8dd37fe9f64a1e138fdf500.tar.gz
rust-99213ae164e42966f8dd37fe9f64a1e138fdf500.zip
Make `index_by_increasing_offset` return one item for primitives
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/rvalue.rs13
1 files changed, 2 insertions, 11 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
index b764ea6a4c6..936ed41a294 100644
--- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
@@ -18,7 +18,6 @@ use rustc_span::{Span, DUMMY_SP};
 use rustc_target::abi::{self, FieldIdx, FIRST_VARIANT};
 
 use arrayvec::ArrayVec;
-use either::Either;
 
 impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
     #[instrument(level = "trace", skip(self, bx))]
@@ -698,24 +697,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
             }
             mir::Rvalue::Use(ref operand) => self.codegen_operand(bx, operand),
             mir::Rvalue::Repeat(..) => bug!("{rvalue:?} in codegen_rvalue_operand"),
-            mir::Rvalue::Aggregate(ref kind, ref fields) => {
+            mir::Rvalue::Aggregate(_, ref fields) => {
                 let ty = rvalue.ty(self.mir, self.cx.tcx());
                 let ty = self.monomorphize(ty);
                 let layout = self.cx.layout_of(ty);
 
-                let field_indices = if let mir::AggregateKind::RawPtr(..) = **kind {
-                    // `index_by_increasing_offset` gives an empty iterator for primitives
-                    Either::Left([0_usize, 1_usize].iter().copied())
-                } else {
-                    Either::Right(layout.fields.index_by_increasing_offset())
-                };
-                debug_assert_eq!(field_indices.len(), fields.len());
-
                 // `rvalue_creates_operand` has arranged that we only get here if
                 // we can build the aggregate immediate from the field immediates.
                 let mut inputs = ArrayVec::<Bx::Value, 2>::new();
                 let mut input_scalars = ArrayVec::<abi::Scalar, 2>::new();
-                for field_idx in field_indices {
+                for field_idx in layout.fields.index_by_increasing_offset() {
                     let field_idx = FieldIdx::from_usize(field_idx);
                     let op = self.codegen_operand(bx, &fields[field_idx]);
                     let values = op.val.immediates_or_place().left_or_else(|p| {