44use std:: num:: NonZero ;
55
66use rustc_abi:: { FieldIdx , FieldsShape , VariantIdx , Variants } ;
7- use rustc_index:: { Idx as _, IndexVec } ;
87use rustc_middle:: mir:: interpret:: InterpResult ;
98use rustc_middle:: ty:: { self , Ty } ;
109use tracing:: trace;
@@ -24,20 +23,6 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
2423 self . ecx ( ) . read_discriminant ( & v. to_op ( self . ecx ( ) ) ?)
2524 }
2625
27- /// This function provides the chance to reorder the order in which fields are visited for
28- /// `FieldsShape::Aggregate`.
29- ///
30- /// The default means we iterate in source declaration order; alternatively this can use
31- /// `in_memory_order` to iterate in memory order.
32- #[ inline( always) ]
33- fn aggregate_field_iter (
34- in_memory_order : & IndexVec < u32 , FieldIdx > ,
35- ) -> impl Iterator < Item = FieldIdx > {
36- // Allow the optimizer to elide the bounds checking when creating each index.
37- let _ = FieldIdx :: new ( in_memory_order. len ( ) ) ;
38- ( 0 ..in_memory_order. len ( ) ) . map ( FieldIdx :: new)
39- }
40-
4126 // Recursive actions, ready to be overloaded.
4227 /// Visits the given value, dispatching as appropriate to more specialized visitors.
4328 #[ inline( always) ]
@@ -171,7 +156,7 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
171156 self . visit_union ( v, fields) ?;
172157 }
173158 FieldsShape :: Arbitrary { in_memory_order, .. } => {
174- for idx in Self :: aggregate_field_iter ( in_memory_order) {
159+ for idx in in_memory_order. iter ( ) . copied ( ) {
175160 let field = self . ecx ( ) . project_field ( v, idx) ?;
176161 self . visit_field ( v, idx. as_usize ( ) , & field) ?;
177162 }
0 commit comments