@@ -9,7 +9,9 @@ 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 :: {
13
+ ImmTy , Immediate , InterpCx , InterpResult , Machine , MemPlaceMeta , PlaceTy , Projectable , Scalar ,
14
+ } ;
13
15
use crate :: util;
14
16
15
17
impl < ' mir , ' tcx : ' mir , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
@@ -304,15 +306,21 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
304
306
( variant_index, variant_dest, active_field_index)
305
307
}
306
308
mir:: AggregateKind :: RawPtr ( ..) => {
307
- // Trying to `project_field` into pointers tends not to work,
308
- // so build the `Immediate` from the parts directly.
309
+ // Pointers don't have "fields" in the normal sense, so the
310
+ // projection-based code below would either fail in projection
311
+ // or in type mismatches. Instead, build an `Immediate` from
312
+ // the parts and write that to the destination.
309
313
let [ data, meta] = & operands. raw else {
310
314
bug ! ( "{kind:?} should have 2 operands, had {operands:?}" ) ;
311
315
} ;
312
316
let data = self . eval_operand ( data, None ) ?;
313
317
let data = self . read_pointer ( & data) ?;
314
318
let meta = self . eval_operand ( meta, None ) ?;
315
- let meta = self . read_mem_place_meta ( & meta) ?;
319
+ let meta = if meta. layout . is_zst ( ) {
320
+ MemPlaceMeta :: None
321
+ } else {
322
+ MemPlaceMeta :: Meta ( self . read_scalar ( & meta) ?)
323
+ } ;
316
324
let ptr_imm = Immediate :: new_pointer_with_meta ( data, meta, self ) ;
317
325
let ptr = ImmTy :: from_immediate ( ptr_imm, dest. layout ) ;
318
326
self . copy_op ( & ptr, dest) ?;
0 commit comments