about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret/visitor.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-08-04 21:42:35 +0200
committerRalf Jung <post@ralfj.de>2023-08-30 13:43:34 +0200
commitbdd5855b8e127f4a258b0bd90cd5d2dbade1b3cc (patch)
tree3a94ee99816cb0d12f479b257a9a88e027c2f84b /compiler/rustc_const_eval/src/interpret/visitor.rs
parent61efe9d2981b87ec7f2800d62f98c594de151713 (diff)
downloadrust-bdd5855b8e127f4a258b0bd90cd5d2dbade1b3cc.tar.gz
rust-bdd5855b8e127f4a258b0bd90cd5d2dbade1b3cc.zip
interpret: fix projecting into an unsized field of a local
new invariant: Place::Local never refers to something unsized
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/visitor.rs')
-rw-r--r--compiler/rustc_const_eval/src/interpret/visitor.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs
index 531e2bd3ee0..fc21ad1f183 100644
--- a/compiler/rustc_const_eval/src/interpret/visitor.rs
+++ b/compiler/rustc_const_eval/src/interpret/visitor.rs
@@ -170,8 +170,9 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
                 }
             }
             FieldsShape::Array { .. } => {
-                for (idx, field) in self.ecx().project_array_fields(v)?.enumerate() {
-                    self.visit_field(v, idx, &field?)?;
+                let mut iter = self.ecx().project_array_fields(v)?;
+                while let Some((idx, field)) = iter.next(self.ecx())? {
+                    self.visit_field(v, idx.try_into().unwrap(), &field)?;
                 }
             }
         }