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*.
This commit is contained in:
parent
a93bcdc307
commit
a2ee7592d6
42 changed files with 168 additions and 118 deletions
|
@ -1,6 +1,6 @@
|
|||
pub use super::ffi::*;
|
||||
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::coverage::{
|
||||
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionId,
|
||||
InjectedExpressionIndex, MappedExpressionIndex, Op,
|
||||
|
@ -205,7 +205,7 @@ impl<'tcx> FunctionCoverage<'tcx> {
|
|||
// `expression_index`s lower than the referencing `Expression`. Therefore, it is
|
||||
// reasonable to look up the new index of an expression operand while the `new_indexes`
|
||||
// vector is only complete up to the current `ExpressionIndex`.
|
||||
let id_to_counter = |new_indexes: &IndexVec<
|
||||
let id_to_counter = |new_indexes: &IndexSlice<
|
||||
InjectedExpressionIndex,
|
||||
Option<MappedExpressionIndex>,
|
||||
>,
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::FunctionCx;
|
|||
use crate::traits::*;
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::traversal;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{self, Location, TerminatorKind};
|
||||
|
@ -277,7 +277,7 @@ impl CleanupKind {
|
|||
/// Recover that structure in an analyze pass.
|
||||
pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
|
||||
fn discover_masters<'tcx>(
|
||||
result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
|
||||
result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
|
||||
mir: &mir::Body<'tcx>,
|
||||
) {
|
||||
for (bb, data) in mir.basic_blocks.iter_enumerated() {
|
||||
|
@ -308,7 +308,10 @@ pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKi
|
|||
}
|
||||
}
|
||||
|
||||
fn propagate<'tcx>(result: &mut IndexVec<mir::BasicBlock, CleanupKind>, mir: &mir::Body<'tcx>) {
|
||||
fn propagate<'tcx>(
|
||||
result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
|
||||
mir: &mir::Body<'tcx>,
|
||||
) {
|
||||
let mut funclet_succs = IndexVec::from_elem(None, &mir.basic_blocks);
|
||||
|
||||
let mut set_successor = |funclet: mir::BasicBlock, succ| match funclet_succs[funclet] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue