@@ -630,7 +630,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
630630 OperandRef { val : OperandValue :: Immediate ( static_) , layout }
631631 }
632632 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+ }
634644 mir:: Rvalue :: Aggregate ( ref kind, ref fields) => {
635645 let ( variant_index, active_field_index) = match * * kind {
636646 mir:: AggregateKind :: Adt ( _, variant_index, _, _, active_field_index) => {
@@ -1000,12 +1010,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10001010 mir:: Rvalue :: NullaryOp ( ..) |
10011011 mir:: Rvalue :: ThreadLocalRef ( _) |
10021012 mir:: Rvalue :: Use ( ..) |
1013+ mir:: Rvalue :: Repeat ( ..) | // (*)
10031014 mir:: Rvalue :: Aggregate ( ..) | // (*)
10041015 mir:: Rvalue :: WrapUnsafeBinder ( ..) => // (*)
10051016 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 ,
10091017 }
10101018
10111019 // (*) this is only true if the type is suitable
0 commit comments