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
|
@ -21,7 +21,7 @@ use rustc_ast::Attribute;
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::{
|
||||
mir::*,
|
||||
thir::*,
|
||||
|
@ -37,7 +37,7 @@ pub(super) fn build_custom_mir<'tcx>(
|
|||
hir_id: HirId,
|
||||
thir: &Thir<'tcx>,
|
||||
expr: ExprId,
|
||||
params: &IndexVec<ParamId, Param<'tcx>>,
|
||||
params: &IndexSlice<ParamId, Param<'tcx>>,
|
||||
return_ty: Ty<'tcx>,
|
||||
return_ty_span: Span,
|
||||
span: Span,
|
||||
|
@ -49,7 +49,7 @@ pub(super) fn build_custom_mir<'tcx>(
|
|||
phase: MirPhase::Built,
|
||||
source_scopes: IndexVec::new(),
|
||||
generator: None,
|
||||
local_decls: LocalDecls::new(),
|
||||
local_decls: IndexVec::new(),
|
||||
user_type_annotations: IndexVec::new(),
|
||||
arg_count: params.len(),
|
||||
spread_arg: None,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_middle::{mir::*, thir::*, ty::Ty};
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -81,7 +81,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse_args(&mut self, params: &IndexVec<ParamId, Param<'tcx>>) -> PResult<()> {
|
||||
pub fn parse_args(&mut self, params: &IndexSlice<ParamId, Param<'tcx>>) -> PResult<()> {
|
||||
for param in params.iter() {
|
||||
let (var, span) = {
|
||||
let pat = param.pat.as_ref().unwrap();
|
||||
|
|
|
@ -11,7 +11,7 @@ use rustc_hir as hir;
|
|||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::{GeneratorKind, Node};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||
use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
|
||||
use rustc_middle::middle::region;
|
||||
|
@ -821,7 +821,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
fn args_and_body(
|
||||
&mut self,
|
||||
mut block: BasicBlock,
|
||||
arguments: &IndexVec<ParamId, Param<'tcx>>,
|
||||
arguments: &IndexSlice<ParamId, Param<'tcx>>,
|
||||
argument_scope: region::Scope,
|
||||
expr: &Expr<'tcx>,
|
||||
) -> BlockAnd<()> {
|
||||
|
|
|
@ -86,7 +86,7 @@ use std::mem;
|
|||
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::middle::region;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::thir::{Expr, LintLevel};
|
||||
|
@ -360,7 +360,7 @@ impl DropTree {
|
|||
fn link_blocks<'tcx>(
|
||||
&self,
|
||||
cfg: &mut CFG<'tcx>,
|
||||
blocks: &IndexVec<DropIdx, Option<BasicBlock>>,
|
||||
blocks: &IndexSlice<DropIdx, Option<BasicBlock>>,
|
||||
) {
|
||||
for (drop_idx, drop_data) in self.drops.iter_enumerated().rev() {
|
||||
let Some(block) = blocks[drop_idx] else { continue };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue