diff --git a/compiler/rustc_const_eval/src/interpret/visitor.rs b/compiler/rustc_const_eval/src/interpret/visitor.rs index 95106c7c143b3..a8d472bc2ea23 100644 --- a/compiler/rustc_const_eval/src/interpret/visitor.rs +++ b/compiler/rustc_const_eval/src/interpret/visitor.rs @@ -4,7 +4,6 @@ use std::num::NonZero; use rustc_abi::{FieldIdx, FieldsShape, VariantIdx, Variants}; -use rustc_index::{Idx as _, IndexVec}; use rustc_middle::mir::interpret::InterpResult; use rustc_middle::ty::{self, Ty}; use tracing::trace; @@ -24,20 +23,6 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { self.ecx().read_discriminant(&v.to_op(self.ecx())?) } - /// This function provides the chance to reorder the order in which fields are visited for - /// `FieldsShape::Aggregate`. - /// - /// The default means we iterate in source declaration order; alternatively this can use - /// `in_memory_order` to iterate in memory order. - #[inline(always)] - fn aggregate_field_iter( - in_memory_order: &IndexVec, - ) -> impl Iterator { - // Allow the optimizer to elide the bounds checking when creating each index. - let _ = FieldIdx::new(in_memory_order.len()); - (0..in_memory_order.len()).map(FieldIdx::new) - } - // Recursive actions, ready to be overloaded. /// Visits the given value, dispatching as appropriate to more specialized visitors. #[inline(always)] @@ -171,7 +156,7 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized { self.visit_union(v, fields)?; } FieldsShape::Arbitrary { in_memory_order, .. } => { - for idx in Self::aggregate_field_iter(in_memory_order) { + for idx in in_memory_order.iter().copied() { let field = self.ecx().project_field(v, idx)?; self.visit_field(v, idx.as_usize(), &field)?; } diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 218e4ffe5e2f7..f4fc478481a7a 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -10,7 +10,6 @@ use rustc_data_structures::fx::{FxBuildHasher, FxHashSet}; use rustc_hir::Safety; use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE}; -use rustc_index::IndexVec; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::ExportedSymbol; @@ -583,12 +582,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { self.ecx } - fn aggregate_field_iter( - in_memory_order: &IndexVec, - ) -> impl Iterator { - in_memory_order.iter().copied() - } - // Hook to detect `UnsafeCell`. fn visit_value(&mut self, v: &MPlaceTy<'tcx>) -> InterpResult<'tcx> { trace!("UnsafeCellVisitor: {:?} {:?}", *v, v.layout.ty);