]> git.lizzy.rs Git - rust.git/commitdiff
fn ptrs and never were accidentally disabled (55)
authorRalf Jung <post@ralfj.de>
Fri, 14 Jul 2017 03:28:00 +0000 (20:28 -0700)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 25 Jul 2017 08:22:11 +0000 (10:22 +0200)
src/librustc_mir/interpret/lvalue.rs

index 1c7070e77b1b2d33c5ed7b900f96df75c4944ce3..60ce28f82323d97d1a6a906779be1297e8c9809b 100644 (file)
@@ -529,7 +529,7 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>, mut vctx:
         let is_owning = match ty.sty {
             TyInt(_) | TyUint(_) | TyRawPtr(_) |
             TyBool | TyFloat(_) | TyChar | TyStr |
-            TyRef(..) => true,
+            TyRef(..) | TyFnPtr(..) | TyNever => true,
             TyAdt(adt, _) if adt.is_box() => true,
             TySlice(_) | TyAdt(_, _) | TyTuple(..) | TyClosure(..) | TyArray(..) => false,
             TyParam(_) | TyInfer(_) => bug!("I got an incomplete type for validation"),
@@ -611,6 +611,15 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>, mut vctx:
                 let val = self.read_lvalue(lvalue)?;
                 self.validate_ptr(val, ty.boxed_ty(), vctx)
             }
+            TyFnPtr(_sig) => {
+                // TODO: The function names here could need some improvement.
+                let ptr = self.read_lvalue(lvalue)?.into_ptr(&mut self.memory)?.to_ptr()?;
+                self.memory.get_fn(ptr)?;
+                // TODO: Check if the signature matches (should be the same check as what terminator/mod.rs already does on call?).
+                Ok(())
+            }
+
+            // Compound types
             TySlice(elem_ty) => {
                 let len = match lvalue {
                     Lvalue::Ptr { extra: LvalueExtra::Length(len), .. } => len,
@@ -629,13 +638,6 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>, mut 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()?;
-                self.memory.get_fn(ptr)?;
-                // TODO: Check if the signature matches (should be the same check as what terminator/mod.rs already does on call?).
-                Ok(())
-            }
             TyAdt(adt, subst) => {
                 match adt.adt_kind() {
                     AdtKind::Enum => {
@@ -682,6 +684,8 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>, mut vctx:
                     let field_lvalue = self.lvalue_field(lvalue, idx, ty, field_ty)?;
                     self.validate(field_lvalue, field_ty, vctx)?;
                 }
+                // TODO: Check if the signature matches (should be the same check as what terminator/mod.rs already does on call?).
+                // Is there other things we can/should check?  Like vtable pointers?
                 Ok(())
             }
             _ => bug!("We already establishd that this is a type we support.")