@@ -9,7 +9,7 @@ use rustc_middle::mir;
9
9
use rustc_middle:: ty:: layout:: LayoutOf ;
10
10
use rustc_target:: abi:: { FieldIdx , FIRST_VARIANT } ;
11
11
12
- use super :: { ImmTy , Immediate , InterpCx , InterpResult , Machine , PlaceTy , Projectable , Scalar } ;
12
+ use super :: { ImmTy , Immediate , InterpCx , InterpResult , Machine , MemPlaceMeta , PlaceTy , Projectable , Scalar } ;
13
13
use crate :: util;
14
14
15
15
impl < ' 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> {
304
304
( variant_index, variant_dest, active_field_index)
305
305
}
306
306
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.
309
311
let [ data, meta] = & operands. raw else {
310
312
bug ! ( "{kind:?} should have 2 operands, had {operands:?}" ) ;
311
313
} ;
312
314
let data = self . eval_operand ( data, None ) ?;
313
315
let data = self . read_pointer ( & data) ?;
314
316
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
+ } ;
316
322
let ptr_imm = Immediate :: new_pointer_with_meta ( data, meta, self ) ;
317
323
let ptr = ImmTy :: from_immediate ( ptr_imm, dest. layout ) ;
318
324
self . copy_op ( & ptr, dest) ?;
0 commit comments