]> git.lizzy.rs Git - rust.git/commitdiff
handle array types
authorRalf Jung <post@ralfj.de>
Fri, 14 Jul 2017 03:22:51 +0000 (20:22 -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 45dc226af14572dd7154032800a6a3a922b01ba9..1c7070e77b1b2d33c5ed7b900f96df75c4944ce3 100644 (file)
@@ -531,7 +531,7 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>, mut vctx:
             TyBool | TyFloat(_) | TyChar | TyStr |
             TyRef(..) => true,
             TyAdt(adt, _) if adt.is_box() => true,
-            TyAdt(_, _) | TyTuple(..) | TyClosure(..) => false,
+            TySlice(_) | TyAdt(_, _) | TyTuple(..) | TyClosure(..) | TyArray(..) => false,
             TyParam(_) | TyInfer(_) => bug!("I got an incomplete type for validation"),
             _ => return Err(EvalError::Unimplemented(format!("Unimplemented type encountered when checking validity."))),
         };
@@ -622,6 +622,13 @@ pub(super) fn validate(&mut self, lvalue: Lvalue<'tcx>, ty: Ty<'tcx>, mut vctx:
                 }
                 Ok(())
             }
+            TyArray(elem_ty, len) => {
+                for i in 0..len {
+                    let inner_lvalue = self.lvalue_index(lvalue, ty, i as u64)?;
+                    self.validate(inner_lvalue, elem_ty, 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()?;