@@ -9,7 +9,7 @@ use rustc_middle::mir;
99use rustc_middle:: ty:: layout:: LayoutOf ;
1010use rustc_target:: abi:: { FieldIdx , FIRST_VARIANT } ;
1111
12- use super :: { ImmTy , Immediate , InterpCx , InterpResult , Machine , PlaceTy , Projectable , Scalar } ;
12+ use super :: { ImmTy , Immediate , InterpCx , InterpResult , Machine , MemPlaceMeta , PlaceTy , Projectable , Scalar } ;
1313use crate :: util;
1414
1515impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
@@ -304,15 +304,21 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
304304 ( variant_index, variant_dest, active_field_index)
305305 }
306306 mir:: AggregateKind :: RawPtr ( ..) => {
307- // Trying to `project_field` into pointers tends not to work,
308- // so build the `Immediate` from the parts directly.
307+ // Pointers don't have "fields" in the normal sense, so the
308+ // projection-based code below would either fail in projection
309+ // or in type mismatches. Instead, build an `Immediate` from
310+ // the parts and write that to the destination.
309311 let [ data, meta] = & operands. raw else {
310312 bug ! ( "{kind:?} should have 2 operands, had {operands:?}" ) ;
311313 } ;
312314 let data = self . eval_operand ( data, None ) ?;
313315 let data = self . read_pointer ( & data) ?;
314316 let meta = self . eval_operand ( meta, None ) ?;
315- let meta = self . read_mem_place_meta ( & meta) ?;
317+ let meta = if meta. layout . is_zst ( ) {
318+ MemPlaceMeta :: None
319+ } else {
320+ MemPlaceMeta :: Meta ( self . read_scalar ( & meta) ?)
321+ } ;
316322 let ptr_imm = Immediate :: new_pointer_with_meta ( data, meta, self ) ;
317323 let ptr = ImmTy :: from_immediate ( ptr_imm, dest. layout ) ;
318324 self . copy_op ( & ptr, dest) ?;
0 commit comments