@@ -267,7 +267,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
267267 & self ,
268268 op : OpTy < ' tcx , M :: PointerTag > ,
269269 ) -> InterpResult < ' tcx , OpTy < ' tcx , M :: PointerTag > > {
270- match op. try_as_mplace ( ) {
270+ match op. try_as_mplace ( self ) {
271271 Ok ( mplace) => Ok ( self . force_mplace_ptr ( mplace) ?. into ( ) ) ,
272272 Err ( imm) => Ok ( imm. into ( ) ) , // Nothing to cast/force
273273 }
@@ -335,7 +335,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
335335 & self ,
336336 src : OpTy < ' tcx , M :: PointerTag > ,
337337 ) -> InterpResult < ' tcx , Result < ImmTy < ' tcx , M :: PointerTag > , MPlaceTy < ' tcx , M :: PointerTag > > > {
338- Ok ( match src. try_as_mplace ( ) {
338+ Ok ( match src. try_as_mplace ( self ) {
339339 Ok ( mplace) => {
340340 if let Some ( val) = self . try_read_immediate_from_mplace ( mplace) ? {
341341 Ok ( val)
@@ -383,7 +383,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
383383 op : OpTy < ' tcx , M :: PointerTag > ,
384384 field : u64 ,
385385 ) -> InterpResult < ' tcx , OpTy < ' tcx , M :: PointerTag > > {
386- let base = match op. try_as_mplace ( ) {
386+ let base = match op. try_as_mplace ( self ) {
387387 Ok ( mplace) => {
388388 // The easy case
389389 let field = self . mplace_field ( mplace, field) ?;
@@ -420,7 +420,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
420420 variant : VariantIdx ,
421421 ) -> InterpResult < ' tcx , OpTy < ' tcx , M :: PointerTag > > {
422422 // Downcasts only change the layout
423- Ok ( match op. try_as_mplace ( ) {
423+ Ok ( match op. try_as_mplace ( self ) {
424424 Ok ( mplace) => self . mplace_downcast ( mplace, variant) ?. into ( ) ,
425425 Err ( ..) => {
426426 let layout = op. layout . for_variant ( self , variant) ;
@@ -439,30 +439,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
439439 Field ( field, _) => self . operand_field ( base, field. index ( ) as u64 ) ?,
440440 Downcast ( _, variant) => self . operand_downcast ( base, variant) ?,
441441 Deref => self . deref_operand ( base) ?. into ( ) ,
442- ConstantIndex { .. } | Index ( _) if base. layout . is_zst ( ) => {
443- OpTy {
444- op : Operand :: Immediate ( Scalar :: zst ( ) . into ( ) ) ,
445- // the actual index doesn't matter, so we just pick a convenient one like 0
446- layout : base. layout . field ( self , 0 ) ?,
447- }
448- }
449- Subslice { from, to, from_end } if base. layout . is_zst ( ) => {
450- let elem_ty = if let ty:: Array ( elem_ty, _) = base. layout . ty . kind {
451- elem_ty
452- } else {
453- bug ! ( "slices shouldn't be zero-sized" ) ;
454- } ;
455- assert ! ( !from_end, "arrays shouldn't be subsliced from the end" ) ;
456-
457- OpTy {
458- op : Operand :: Immediate ( Scalar :: zst ( ) . into ( ) ) ,
459- layout : self . layout_of ( self . tcx . mk_array ( elem_ty, ( to - from) as u64 ) ) ?,
460- }
461- }
462442 Subslice { .. } | ConstantIndex { .. } | Index ( _) => {
463443 // The rest should only occur as mplace, we do not use Immediates for types
464444 // allowing such operations. This matches place_projection forcing an allocation.
465- let mplace = base. assert_mem_place ( ) ;
445+ let mplace = base. assert_mem_place ( self ) ;
466446 self . mplace_projection ( mplace, proj_elem) ?. into ( )
467447 }
468448 } )
0 commit comments