about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-10-08 13:41:16 +0200
committerRalf Jung <post@ralfj.de>2018-10-09 13:08:00 +0200
commit6899af82fd80bd83a5e580c72c1655ac3d7a86d3 (patch)
tree341cf0d1447005df048c0f09f83529086dbb3030 /src
parentdb1663d5984b084acbd62290ed13014e2b7a7ed3 (diff)
box is also a primitive type
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/validity.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 9e833598ef1..0aa2e708043 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -152,7 +152,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
             *value, value.layout.size, value.layout.ty);
 
         // Go over all the primitive types
-        match value.layout.ty.sty {
+        let ty = value.layout.ty;
+        match ty.sty {
             ty::Bool => {
                 let value = value.to_scalar_or_undef();
                 try_validation!(value.to_bool(),
@@ -175,7 +176,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
                     // undef. We should fix that, but let's start low.
                 }
             }
-            ty::RawPtr(..) | ty::Ref(..) => {
+            _ if ty.is_box() || ty.is_region_ptr() || ty.is_unsafe_ptr() => {
                 // Handle fat pointers. We also check fat raw pointers,
                 // their metadata must be valid!
                 // This also checks that the ptr itself is initialized, which
@@ -184,7 +185,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
                     "undefined data in pointer", path);
                 // Check metadata early, for better diagnostics
                 if place.layout.is_unsized() {
-                    match self.tcx.struct_tail(place.layout.ty).sty {
+                    let tail = self.tcx.struct_tail(place.layout.ty);
+                    match tail.sty {
                         ty::Dynamic(..) => {
                             let vtable = try_validation!(place.extra.unwrap().to_ptr(),
                                 "non-pointer vtable in fat pointer", path);
@@ -202,13 +204,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
                             // Unsized, but not fat.
                         }
                         _ =>
-                            bug!("Unexpected unsized type tail: {:?}",
-                                self.tcx.struct_tail(place.layout.ty)
-                            ),
+                            bug!("Unexpected unsized type tail: {:?}", tail),
                     }
                 }
                 // for safe ptrs, recursively check
-                if let ty::Ref(..) = value.layout.ty.sty {
+                if !ty.is_unsafe_ptr() {
                     // Make sure this is non-NULL and aligned
                     let (size, align) = self.size_and_align_of(place.extra, place.layout)?;
                     match self.memory.check_align(place.ptr, align) {