show alignedness of ByRefs; allow converting unaligned ByRef to ptr

This commit is contained in:
Ralf Jung 2017-07-13 09:09:45 -07:00
parent 6fb6a1c4d0
commit 62334acd66
2 changed files with 5 additions and 4 deletions

View File

@ -1575,9 +1575,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
Err(err) => {
panic!("Failed to access local: {:?}", err);
}
Ok(Value::ByRef(ptr, _aligned)) => match ptr.into_inner_primval() {
Ok(Value::ByRef(ptr, aligned)) => match ptr.into_inner_primval() {
PrimVal::Ptr(ptr) => {
write!(msg, " by ref:").unwrap();
write!(msg, " by {}ref:", if aligned { "" } else { "unaligned " }).unwrap();
allocs.push(ptr.alloc_id);
},
ptr => write!(msg, " integral by ref: {:?}", ptr).unwrap(),

View File

@ -86,9 +86,10 @@ impl<'tcx> Lvalue<'tcx> {
}
pub(super) fn to_ptr(self) -> EvalResult<'tcx, MemoryPointer> {
let (ptr, extra, aligned) = self.to_ptr_extra_aligned();
let (ptr, extra, _aligned) = self.to_ptr_extra_aligned();
// At this point, we forget about the alignment information -- the lvalue has been turned into a reference,
// and no matter where it came from, it now must be aligned.
assert_eq!(extra, LvalueExtra::None);
assert_eq!(aligned, true, "tried converting an unaligned lvalue into a ptr");
ptr.to_ptr()
}