Reintroduce some sanity checks
This commit is contained in:
parent
8b99c61701
commit
76ddede5c2
@ -98,6 +98,13 @@ pub fn value_to_const_value<'tcx>(
|
||||
mut val: Value,
|
||||
ty: Ty<'tcx>,
|
||||
) -> &'tcx ty::Const<'tcx> {
|
||||
let layout = tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap();
|
||||
match (val, &layout.abi) {
|
||||
(Value::ByRef(..), _) |
|
||||
(Value::ByVal(_), &layout::Abi::Scalar(_)) |
|
||||
(Value::ByValPair(..), &layout::Abi::ScalarPair(..)) => {},
|
||||
_ => bug!("bad value/layout combo: {:#?}, {:#?}", val, layout),
|
||||
}
|
||||
let val = (|| {
|
||||
// Convert to ByVal or ByValPair if possible
|
||||
if let Value::ByRef(ptr, align) = val {
|
||||
|
@ -1416,10 +1416,6 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
||||
let layout = self.layout_of(ty)?;
|
||||
self.memory.check_align(ptr, ptr_align)?;
|
||||
|
||||
if layout.size.bytes() == 0 {
|
||||
return Ok(Some(Value::ByVal(PrimVal::Undef)));
|
||||
}
|
||||
|
||||
let ptr = ptr.to_ptr()?;
|
||||
|
||||
// Not the right place to do this
|
||||
|
Loading…
x
Reference in New Issue
Block a user