about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-03-02 22:24:23 +0100
committerRalf Jung <post@ralfj.de>2020-03-06 22:41:49 +0100
commit58f8cc21352613639fdc58f4f8a59f5c579b5372 (patch)
treea5a87a3a8e9fb30f77b9463f1bd0699811909411
parentf0586f9aea1948fe208751f8183d58f9af1116b6 (diff)
downloadrust-58f8cc21352613639fdc58f4f8a59f5c579b5372.tar.gz
rust-58f8cc21352613639fdc58f4f8a59f5c579b5372.zip
rename visit_primitive -> try_visit_primitive, and comments
-rw-r--r--src/librustc_mir/interpret/validity.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index 74a22b90a8b..29d18e87c4f 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -406,7 +406,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
 
     /// Check if this is a value of primitive type, and if yes check the validity of the value
     /// at that type.  Return `true` if the type is indeed primitive.
-    fn visit_primitive(&mut self, value: OpTy<'tcx, M::PointerTag>) -> InterpResult<'tcx, bool> {
+    fn try_visit_primitive(&mut self, value: OpTy<'tcx, M::PointerTag>) -> InterpResult<'tcx, bool> {
         // Go over all the primitive types
         let ty = value.layout.ty;
         match ty.kind {
@@ -477,7 +477,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
                 // Nothing to check.
                 Ok(true)
             }
-            // This should be all the (inhabited) primitive types. The rest is compound, we
+            // The above should be all the (inhabited) primitive types. The rest is compound, we
             // check them by visiting their fields/variants.
             // (`Str` UTF-8 check happens in `visit_aggregate`, too.)
             ty::Adt(..)
@@ -489,7 +489,8 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
             | ty::Closure(..)
             | ty::Generator(..)
             | ty::GeneratorWitness(..) => Ok(false),
-            // Some types only occur during inference, we should not see them here.
+            // Some types only occur during typechecking, they have no layout.
+            // We should not see them here and we could not check them anyway.
             ty::Error
             | ty::Infer(..)
             | ty::Placeholder(..)
@@ -618,7 +619,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
         trace!("visit_value: {:?}, {:?}", *op, op.layout);
 
         // Check primitive types -- the leafs of our recursive descend.
-        if self.visit_primitive(op)? {
+        if self.try_visit_primitive(op)? {
             return Ok(());
         }
         // Sanity check: `builtin_deref` does not know any pointers that are not primitive.