@@ -630,7 +630,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
630
630
OperandRef { val : OperandValue :: Immediate ( static_) , layout }
631
631
}
632
632
mir:: Rvalue :: Use ( ref operand) => self . codegen_operand ( bx, operand) ,
633
- mir:: Rvalue :: Repeat ( ..) => bug ! ( "{rvalue:?} in codegen_rvalue_operand" ) ,
633
+ mir:: Rvalue :: Repeat ( ref elem, len_const) => {
634
+ // All arrays have `BackendRepr::Memory`, so only the ZST cases
635
+ // end up here. Anything else forces the destination local to be
636
+ // `Memory`, and thus ends up handled in `codegen_rvalue` instead.
637
+ let operand = self . codegen_operand ( bx, elem) ;
638
+ let array_ty = Ty :: new_array_with_const_len ( bx. tcx ( ) , operand. layout . ty , len_const) ;
639
+ let array_ty = self . monomorphize ( array_ty) ;
640
+ let array_layout = bx. layout_of ( array_ty) ;
641
+ assert ! ( array_layout. is_zst( ) ) ;
642
+ OperandRef { val : OperandValue :: ZeroSized , layout : array_layout }
643
+ }
634
644
mir:: Rvalue :: Aggregate ( ref kind, ref fields) => {
635
645
let ( variant_index, active_field_index) = match * * kind {
636
646
mir:: AggregateKind :: Adt ( _, variant_index, _, _, active_field_index) => {
@@ -1000,12 +1010,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1000
1010
mir:: Rvalue :: NullaryOp ( ..) |
1001
1011
mir:: Rvalue :: ThreadLocalRef ( _) |
1002
1012
mir:: Rvalue :: Use ( ..) |
1013
+ mir:: Rvalue :: Repeat ( ..) | // (*)
1003
1014
mir:: Rvalue :: Aggregate ( ..) | // (*)
1004
1015
mir:: Rvalue :: WrapUnsafeBinder ( ..) => // (*)
1005
1016
true ,
1006
- // Arrays are always aggregates, so it's not worth checking anything here.
1007
- // (If it's really `[(); N]` or `[T; 0]` and we use the place path, fine.)
1008
- mir:: Rvalue :: Repeat ( ..) => false ,
1009
1017
}
1010
1018
1011
1019
// (*) this is only true if the type is suitable
0 commit comments