@@ -18,7 +18,6 @@ use rustc_span::{Span, DUMMY_SP};
1818use rustc_target:: abi:: { self , FieldIdx , FIRST_VARIANT } ;
1919
2020use arrayvec:: ArrayVec ;
21- use either:: Either ;
2221
2322impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
2423 #[ instrument( level = "trace" , skip( self , bx) ) ]
@@ -698,24 +697,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
698697 }
699698 mir:: Rvalue :: Use ( ref operand) => self . codegen_operand ( bx, operand) ,
700699 mir:: Rvalue :: Repeat ( ..) => bug ! ( "{rvalue:?} in codegen_rvalue_operand" ) ,
701- mir:: Rvalue :: Aggregate ( ref kind , ref fields) => {
700+ mir:: Rvalue :: Aggregate ( _ , ref fields) => {
702701 let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
703702 let ty = self . monomorphize ( ty) ;
704703 let layout = self . cx . layout_of ( ty) ;
705704
706- let field_indices = if let mir:: AggregateKind :: RawPtr ( ..) = * * kind {
707- // `index_by_increasing_offset` gives an empty iterator for primitives
708- Either :: Left ( [ 0_usize , 1_usize ] . iter ( ) . copied ( ) )
709- } else {
710- Either :: Right ( layout. fields . index_by_increasing_offset ( ) )
711- } ;
712- debug_assert_eq ! ( field_indices. len( ) , fields. len( ) ) ;
713-
714705 // `rvalue_creates_operand` has arranged that we only get here if
715706 // we can build the aggregate immediate from the field immediates.
716707 let mut inputs = ArrayVec :: < Bx :: Value , 2 > :: new ( ) ;
717708 let mut input_scalars = ArrayVec :: < abi:: Scalar , 2 > :: new ( ) ;
718- for field_idx in field_indices {
709+ for field_idx in layout . fields . index_by_increasing_offset ( ) {
719710 let field_idx = FieldIdx :: from_usize ( field_idx) ;
720711 let op = self . codegen_operand ( bx, & fields[ field_idx] ) ;
721712 let values = op. val . immediates_or_place ( ) . left_or_else ( |p| {
0 commit comments