diff options
author | Scott McMurray <scottmcm@users.noreply.github.com> | 2023-03-31 00:32:44 -0700 |
---|---|---|
committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2023-04-02 17:35:37 -0700 |
commit | a2ee7592d6b7c0daa62b7870ade85e0cc0acca05 (patch) | |
tree | 4ab6bedbd53989ea3c1b556e4d61c33f469c536b /compiler/rustc_mir_dataflow | |
parent | a93bcdc30771340dfff914a1cf48556886ad33a6 (diff) | |
download | rust-a2ee7592d6b7c0daa62b7870ade85e0cc0acca05.tar.gz |
Use `&IndexSlice` instead of `&IndexVec` where possible
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
Diffstat (limited to 'compiler/rustc_mir_dataflow')
-rw-r--r-- | compiler/rustc_mir_dataflow/src/move_paths/mod.rs | 8 | ||||
-rw-r--r-- | compiler/rustc_mir_dataflow/src/value_analysis.rs | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs index 5f22a418de8..257a42cddc8 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs @@ -1,6 +1,6 @@ use crate::move_paths::builder::MoveDat; use rustc_data_structures::fx::FxHashMap; -use rustc_index::vec::IndexVec; +use rustc_index::vec::{IndexSlice, IndexVec}; use rustc_middle::mir::*; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; use rustc_span::Span; @@ -64,7 +64,7 @@ impl<'tcx> MovePath<'tcx> { /// Returns an iterator over the parents of `self`. pub fn parents<'a>( &self, - move_paths: &'a IndexVec<MovePathIndex, MovePath<'tcx>>, + move_paths: &'a IndexSlice<MovePathIndex, MovePath<'tcx>>, ) -> impl 'a + Iterator<Item = (MovePathIndex, &'a MovePath<'tcx>)> { let first = self.parent.map(|mpi| (mpi, &move_paths[mpi])); MovePathLinearIter { @@ -78,7 +78,7 @@ impl<'tcx> MovePath<'tcx> { /// Returns an iterator over the immediate children of `self`. pub fn children<'a>( &self, - move_paths: &'a IndexVec<MovePathIndex, MovePath<'tcx>>, + move_paths: &'a IndexSlice<MovePathIndex, MovePath<'tcx>>, ) -> impl 'a + Iterator<Item = (MovePathIndex, &'a MovePath<'tcx>)> { let first = self.first_child.map(|mpi| (mpi, &move_paths[mpi])); MovePathLinearIter { @@ -95,7 +95,7 @@ impl<'tcx> MovePath<'tcx> { /// `f` will **not** be called on `self`. pub fn find_descendant( &self, - move_paths: &IndexVec<MovePathIndex, MovePath<'_>>, + move_paths: &IndexSlice<MovePathIndex, MovePath<'_>>, f: impl Fn(MovePathIndex) -> bool, ) -> Option<MovePathIndex> { let mut todo = if let Some(child) = self.first_child { diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 63e553bec53..33a15a8d224 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -36,7 +36,7 @@ use std::fmt::{Debug, Formatter}; use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; -use rustc_index::vec::IndexVec; +use rustc_index::vec::{IndexSlice, IndexVec}; use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -1028,8 +1028,8 @@ where fn debug_with_context_rec<V: Debug + Eq>( place: PlaceIndex, place_str: &str, - new: &IndexVec<ValueIndex, V>, - old: Option<&IndexVec<ValueIndex, V>>, + new: &IndexSlice<ValueIndex, V>, + old: Option<&IndexSlice<ValueIndex, V>>, map: &Map, f: &mut Formatter<'_>, ) -> std::fmt::Result { @@ -1069,8 +1069,8 @@ fn debug_with_context_rec<V: Debug + Eq>( } fn debug_with_context<V: Debug + Eq>( - new: &IndexVec<ValueIndex, V>, - old: Option<&IndexVec<ValueIndex, V>>, + new: &IndexSlice<ValueIndex, V>, + old: Option<&IndexSlice<ValueIndex, V>>, map: &Map, f: &mut Formatter<'_>, ) -> std::fmt::Result { |