handle array types

This commit is contained in:
Ralf Jung 2017-07-13 20:22:51 -07:00 committed by Oliver Schneider
parent 4457a52d4f
commit bb6e5224da
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9

View file

@ -531,7 +531,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
TyBool | TyFloat(_) | TyChar | TyStr |
TyRef(..) => true,
TyAdt(adt, _) if adt.is_box() => true,
TyAdt(_, _) | TyTuple(..) | TyClosure(..) => false,
TySlice(_) | TyAdt(_, _) | TyTuple(..) | TyClosure(..) | TyArray(..) => false,
TyParam(_) | TyInfer(_) => bug!("I got an incomplete type for validation"),
_ => return Err(EvalError::Unimplemented(format!("Unimplemented type encountered when checking validity."))),
};
@ -622,6 +622,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}
Ok(())
}
TyArray(elem_ty, len) => {
for i in 0..len {
let inner_lvalue = self.lvalue_index(lvalue, ty, i as u64)?;
self.validate(inner_lvalue, elem_ty, vctx)?;
}
Ok(())
}
TyFnPtr(_sig) => {
// TODO: The function names here could need some improvement.
let ptr = self.read_lvalue(lvalue)?.into_ptr(&mut self.memory)?.to_ptr()?;