@@ -444,13 +444,27 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
444
444
Field ( field, _) => self . operand_field ( base, field. index ( ) as u64 ) ?,
445
445
Downcast ( _, variant) => self . operand_downcast ( base, variant) ?,
446
446
Deref => self . deref_operand ( base) ?. into ( ) ,
447
- Subslice { .. } | ConstantIndex { .. } | Index ( _) => if base. layout . is_zst ( ) {
447
+ ConstantIndex { .. } | Index ( _) if base. layout . is_zst ( ) => {
448
448
OpTy {
449
449
op : Operand :: Immediate ( Scalar :: zst ( ) . into ( ) ) ,
450
450
// the actual index doesn't matter, so we just pick a convenient one like 0
451
451
layout : base. layout . field ( self , 0 ) ?,
452
452
}
453
- } else {
453
+ }
454
+ Subslice { from, to, from_end } if base. layout . is_zst ( ) => {
455
+ let elem_ty = if let ty:: Array ( elem_ty, _) = base. layout . ty . kind {
456
+ elem_ty
457
+ } else {
458
+ bug ! ( "slices shouldn't be zero-sized" ) ;
459
+ } ;
460
+ assert ! ( !from_end, "arrays shouldn't be subsliced from the end" ) ;
461
+
462
+ OpTy {
463
+ op : Operand :: Immediate ( Scalar :: zst ( ) . into ( ) ) ,
464
+ layout : self . layout_of ( self . tcx . mk_array ( elem_ty, ( to - from) as u64 ) ) ?,
465
+ }
466
+ }
467
+ Subslice { .. } | ConstantIndex { .. } | Index ( _) => {
454
468
// The rest should only occur as mplace, we do not use Immediates for types
455
469
// allowing such operations. This matches place_projection forcing an allocation.
456
470
let mplace = base. assert_mem_place ( ) ;
0 commit comments