]> git.lizzy.rs Git - rust.git/commitdiff
handle type of function definitions (98)
authorRalf Jung <post@ralfj.de>
Fri, 14 Jul 2017 16:05:10 +0000 (09:05 -0700)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 25 Jul 2017 08:30:12 +0000 (10:30 +0200)
src/librustc_mir/interpret/validation.rs

index 7795bd0e126c4721dcfc165dabef6066c2e65a0e..54acf1ef0280d8209ff3dfcdb17e3e0ef6c43b81 100644 (file)
@@ -80,11 +80,10 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, mut ty: Ty<'tcx>, mut vc
         let is_owning = match ty.sty {
             TyInt(_) | TyUint(_) | TyRawPtr(_) |
             TyBool | TyFloat(_) | TyChar | TyStr |
-            TyRef(..) | TyFnPtr(..) | TyNever => true,
+            TyRef(..) | TyFnPtr(..) | TyFnDef(..) | TyNever => true,
             TyAdt(adt, _) if adt.is_box() => true,
             TySlice(_) | TyAdt(_, _) | TyTuple(..) | TyClosure(..) | TyArray(..) | TyDynamic(..) => false,
-            TyParam(_) | TyInfer(_) => bug!("I got an incomplete type for validation"),
-            _ => return Err(EvalError::Unimplemented(format!("Unimplemented type encountered when checking validity."))),
+            TyParam(_) | TyInfer(_) | TyProjection(_) | TyAnon(..) | TyError => bug!("I got an incomplete/unnormalized type for validation"),
         };
         if is_owning {
             match lvalue {
@@ -163,12 +162,16 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, mut ty: Ty<'tcx>, mut vc
                 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(())
             }
+            TyFnDef(..) => {
+                // This is a zero-sized type with all relevant data sitting in the type.
+                // There is nothing to validate.
+                Ok(())
+            }
 
             // Compound types
             TySlice(elem_ty) => {