@@ -25,14 +25,15 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
2525 }
2626
2727 /// 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`.
3029 ///
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.
3332 #[ 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 ( )
3637 }
3738
3839 // Recursive actions, ready to be overloaded.
@@ -172,9 +173,9 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
172173 & FieldsShape :: Union ( fields) => {
173174 self . visit_union ( v, fields) ?;
174175 }
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 ( ) ;
178179 let field = self . ecx ( ) . project_field ( v, idx) ?;
179180 self . visit_field ( v, idx, & field) ?;
180181 }
0 commit comments