Properly evaluate zst enum

This commit is contained in:
Oliver Schneider 2018-03-31 23:06:26 +02:00 committed by Anthony Ramine
parent 1839ec5ef8
commit 2807f4f773
2 changed files with 10 additions and 0 deletions

View File

@ -1319,6 +1319,15 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
pub fn try_read_value(&self, ptr: Pointer, ptr_align: Align, ty: Ty<'tcx>) -> EvalResult<'tcx, Option<Value>> {
use syntax::ast::FloatTy;
let layout = self.layout_of(ty)?;
// do the strongest layout check of the two
let align = layout.align.max(ptr_align);
self.memory.check_align(ptr, align)?;
if layout.size.bytes() == 0 {
return Ok(Some(Value::ByVal(PrimVal::Undef)));
}
let ptr = ptr.to_ptr()?;
let val = match ty.sty {
ty::TyBool => {

View File

@ -136,6 +136,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
let val = [a, b][field_index];
Ok(Some((Value::ByVal(val), field.ty)))
},
// FIXME(oli-obk): figure out whether we should be calling `try_read_value` here
_ => Ok(None),
}
}