mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-24 06:18:30 +03:00
more type sanity checks in Miri
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
use rustc_target::abi::{VariantIdx, Variants};
|
||||
|
||||
use super::{
|
||||
from_known_layout, ConstValue, GlobalId, InterpCx, InterpResult, MPlaceTy, Machine, MemPlace,
|
||||
Place, PlaceTy, Pointer, Scalar, ScalarMaybeUninit,
|
||||
from_known_layout, mir_assign_valid_types, ConstValue, GlobalId, InterpCx, InterpResult,
|
||||
MPlaceTy, Machine, MemPlace, Place, PlaceTy, Pointer, Scalar, ScalarMaybeUninit,
|
||||
};
|
||||
|
||||
/// An `Immediate` represents a single immediate self-contained Rust value.
|
||||
@@ -469,6 +469,14 @@ pub fn eval_place_to_op(
|
||||
.try_fold(base_op, |op, elem| self.operand_projection(op, elem))?;
|
||||
|
||||
trace!("eval_place_to_op: got {:?}", *op);
|
||||
// Sanity-check the type we ended up with.
|
||||
debug_assert!(mir_assign_valid_types(
|
||||
*self.tcx,
|
||||
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
|
||||
place.ty(&self.frame().body.local_decls, *self.tcx).ty
|
||||
))?,
|
||||
op.layout,
|
||||
));
|
||||
Ok(op)
|
||||
}
|
||||
|
||||
|
||||
@@ -638,6 +638,14 @@ pub fn eval_place(
|
||||
}
|
||||
|
||||
self.dump_place(place_ty.place);
|
||||
// Sanity-check the type we ended up with.
|
||||
debug_assert!(mir_assign_valid_types(
|
||||
*self.tcx,
|
||||
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
|
||||
place.ty(&self.frame().body.local_decls, *self.tcx).ty
|
||||
))?,
|
||||
place_ty.layout,
|
||||
));
|
||||
Ok(place_ty)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user