about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2017-07-13 09:09:45 -0700
committerRalf Jung <post@ralfj.de>2017-07-13 09:09:45 -0700
commit62334acd66dcc0812cb04f4a66792ede7aed9b2a (patch)
tree1abe283de33d8e8801806e8c7f222152884515bb /src
parent6fb6a1c4d0527b07a1599c9a9ae7d6b0b9097984 (diff)
downloadrust-62334acd66dcc0812cb04f4a66792ede7aed9b2a.tar.gz
rust-62334acd66dcc0812cb04f4a66792ede7aed9b2a.zip
show alignedness of ByRefs; allow converting unaligned ByRef to ptr
Diffstat (limited to 'src')
-rw-r--r--src/eval_context.rs4
-rw-r--r--src/lvalue.rs5
2 files changed, 5 insertions, 4 deletions
diff --git a/src/eval_context.rs b/src/eval_context.rs
index a4ce1d327e3..1e57adbcf3e 100644
--- a/src/eval_context.rs
+++ b/src/eval_context.rs
@@ -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(),
diff --git a/src/lvalue.rs b/src/lvalue.rs
index 79b8d50c96e..86e09356fd7 100644
--- a/src/lvalue.rs
+++ b/src/lvalue.rs
@@ -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()
     }