mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Address PR feedback
This commit is contained in:
parent
5e1d16ca55
commit
bb8d6f790b
@ -603,17 +603,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Ok(self.read_immediate(op)?.to_scalar())
|
||||
}
|
||||
|
||||
pub fn read_mem_place_meta(
|
||||
&self,
|
||||
op: &impl Readable<'tcx, M::Provenance>,
|
||||
) -> InterpResult<'tcx, MemPlaceMeta<M::Provenance>> {
|
||||
Ok(if op.layout().is_zst() {
|
||||
MemPlaceMeta::None
|
||||
} else {
|
||||
MemPlaceMeta::Meta(self.read_scalar(op)?)
|
||||
})
|
||||
}
|
||||
|
||||
// Pointer-sized reads are fairly common and need target layout access, so we wrap them in
|
||||
// convenience functions.
|
||||
|
||||
|
@ -9,7 +9,9 @@ use rustc_middle::mir;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
|
||||
|
||||
use super::{ImmTy, Immediate, InterpCx, InterpResult, Machine, PlaceTy, Projectable, Scalar};
|
||||
use super::{
|
||||
ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy, Projectable, Scalar,
|
||||
};
|
||||
use crate::util;
|
||||
|
||||
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> {
|
||||
(variant_index, variant_dest, active_field_index)
|
||||
}
|
||||
mir::AggregateKind::RawPtr(..) => {
|
||||
// Trying to `project_field` into pointers tends not to work,
|
||||
// so build the `Immediate` from the parts directly.
|
||||
// Pointers don't have "fields" in the normal sense, so the
|
||||
// projection-based code below would either fail in projection
|
||||
// or in type mismatches. Instead, build an `Immediate` from
|
||||
// the parts and write that to the destination.
|
||||
let [data, meta] = &operands.raw else {
|
||||
bug!("{kind:?} should have 2 operands, had {operands:?}");
|
||||
};
|
||||
let data = self.eval_operand(data, None)?;
|
||||
let data = self.read_pointer(&data)?;
|
||||
let meta = self.eval_operand(meta, None)?;
|
||||
let meta = self.read_mem_place_meta(&meta)?;
|
||||
let meta = if meta.layout.is_zst() {
|
||||
MemPlaceMeta::None
|
||||
} else {
|
||||
MemPlaceMeta::Meta(self.read_scalar(&meta)?)
|
||||
};
|
||||
let ptr_imm = Immediate::new_pointer_with_meta(data, meta, self);
|
||||
let ptr = ImmTy::from_immediate(ptr_imm, dest.layout);
|
||||
self.copy_op(&ptr, dest)?;
|
||||
|
Loading…
Reference in New Issue
Block a user