about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2017-07-14 09:05:10 -0700
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-07-25 10:30:12 +0200
commit4aae2e766e2e9ab55e7bbea31e85642572f75f9e (patch)
treed1608d38bd734244cb1cc7293f09a4f6ad9d8dc1 /src
parent3f8a497bf09d393e9c544dd9aa8cfa642f776760 (diff)
downloadrust-4aae2e766e2e9ab55e7bbea31e85642572f75f9e.tar.gz
rust-4aae2e766e2e9ab55e7bbea31e85642572f75f9e.zip
handle type of function definitions (98)
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/validation.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc_mir/interpret/validation.rs b/src/librustc_mir/interpret/validation.rs
index 7795bd0e126..54acf1ef028 100644
--- a/src/librustc_mir/interpret/validation.rs
+++ b/src/librustc_mir/interpret/validation.rs
@@ -80,11 +80,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
         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 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
                 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) => {