@@ -25,14 +25,15 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
25
25
}
26
26
27
27
/// This function provides the chance to reorder the order in which fields are visited for
28
- /// `FieldsShape::Aggregate`: The order of fields will be
29
- /// `(0..num_fields).map(aggregate_field_order)`.
28
+ /// `FieldsShape::Aggregate`.
30
29
///
31
- /// The default means we iterate in source declaration order; alternative this can do an inverse
32
- /// lookup in `memory_index` to use memory field order instead .
30
+ /// The default means we iterate in source declaration order; alternatively this can do some
31
+ /// work with `memory_index` to iterate in memory order.
33
32
#[ inline( always) ]
34
- fn aggregate_field_order ( _memory_index : & IndexVec < FieldIdx , u32 > , idx : usize ) -> usize {
35
- idx
33
+ fn aggregate_field_iter (
34
+ memory_index : & IndexVec < FieldIdx , u32 > ,
35
+ ) -> impl Iterator < Item = FieldIdx > + ' static {
36
+ memory_index. indices ( )
36
37
}
37
38
38
39
// Recursive actions, ready to be overloaded.
@@ -172,9 +173,9 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
172
173
& FieldsShape :: Union ( fields) => {
173
174
self . visit_union ( v, fields) ?;
174
175
}
175
- FieldsShape :: Arbitrary { offsets , memory_index } => {
176
- for idx in 0 ..offsets . len ( ) {
177
- let idx = Self :: aggregate_field_order ( memory_index , idx) ;
176
+ FieldsShape :: Arbitrary { memory_index , .. } => {
177
+ for idx in Self :: aggregate_field_iter ( memory_index ) {
178
+ let idx = idx. as_usize ( ) ;
178
179
let field = self . ecx ( ) . project_field ( v, idx) ?;
179
180
self . visit_field ( v, idx, & field) ?;
180
181
}
0 commit comments