mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
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
@ -289,7 +289,7 @@ pub trait LayoutCalculator {
|
||||
fn layout_of_struct_or_enum(
|
||||
&self,
|
||||
repr: &ReprOptions,
|
||||
variants: &IndexVec<VariantIdx, Vec<Layout<'_>>>,
|
||||
variants: &IndexSlice<VariantIdx, Vec<Layout<'_>>>,
|
||||
is_enum: bool,
|
||||
is_unsafe_cell: bool,
|
||||
scalar_valid_range: (Bound<u128>, Bound<u128>),
|
||||
@ -883,7 +883,7 @@ pub trait LayoutCalculator {
|
||||
fn layout_of_union(
|
||||
&self,
|
||||
repr: &ReprOptions,
|
||||
variants: &IndexVec<VariantIdx, Vec<Layout<'_>>>,
|
||||
variants: &IndexSlice<VariantIdx, Vec<Layout<'_>>>,
|
||||
) -> Option<LayoutS> {
|
||||
let dl = self.current_data_layout();
|
||||
let dl = dl.borrow();
|
||||
|
@ -11,7 +11,7 @@ use bitflags::bitflags;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
#[cfg(feature = "nightly")]
|
||||
use rustc_data_structures::stable_hasher::StableOrd;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
#[cfg(feature = "nightly")]
|
||||
use rustc_macros::HashStable_Generic;
|
||||
#[cfg(feature = "nightly")]
|
||||
|
@ -12,7 +12,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::PredicateOrigin;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::source_map::DesugaringKind;
|
||||
@ -25,7 +25,7 @@ use thin_vec::ThinVec;
|
||||
pub(super) struct ItemLowerer<'a, 'hir> {
|
||||
pub(super) tcx: TyCtxt<'hir>,
|
||||
pub(super) resolver: &'a mut ResolverAstLowering,
|
||||
pub(super) ast_index: &'a IndexVec<LocalDefId, AstOwner<'a>>,
|
||||
pub(super) ast_index: &'a IndexSlice<LocalDefId, AstOwner<'a>>,
|
||||
pub(super) owners: &'a mut IndexVec<LocalDefId, hir::MaybeOwner<&'hir hir::OwnerInfo<'hir>>>,
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::definitions::DefPathData;
|
||||
use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_macros::fluent_messages;
|
||||
use rustc_middle::{
|
||||
span_bug,
|
||||
@ -414,7 +414,7 @@ fn index_crate<'a>(
|
||||
/// This hash will then be part of the crate_hash which is stored in the metadata.
|
||||
fn compute_hir_hash(
|
||||
tcx: TyCtxt<'_>,
|
||||
owners: &IndexVec<LocalDefId, hir::MaybeOwner<&hir::OwnerInfo<'_>>>,
|
||||
owners: &IndexSlice<LocalDefId, hir::MaybeOwner<&hir::OwnerInfo<'_>>>,
|
||||
) -> Fingerprint {
|
||||
let mut hir_body_nodes: Vec<_> = owners
|
||||
.iter_enumerated()
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
|
||||
use rustc_data_structures::graph::scc::Sccs;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
|
||||
use rustc_span::Span;
|
||||
@ -60,7 +60,9 @@ impl<'tcx> OutlivesConstraintSet<'tcx> {
|
||||
Sccs::new(region_graph)
|
||||
}
|
||||
|
||||
pub(crate) fn outlives(&self) -> &IndexVec<OutlivesConstraintIndex, OutlivesConstraint<'tcx>> {
|
||||
pub(crate) fn outlives(
|
||||
&self,
|
||||
) -> &IndexSlice<OutlivesConstraintIndex, OutlivesConstraint<'tcx>> {
|
||||
&self.outlives
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
//! This file provides API for compiler consumers.
|
||||
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_infer::infer::{DefiningAnchor, TyCtxtInferExt};
|
||||
use rustc_middle::mir::Body;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
@ -35,6 +35,6 @@ pub fn get_body_with_borrowck_facts(
|
||||
let (input_body, promoted) = tcx.mir_promoted(def);
|
||||
let infcx = tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(def.did)).build();
|
||||
let input_body: &Body<'_> = &input_body.borrow();
|
||||
let promoted: &IndexVec<_, _> = &promoted.borrow();
|
||||
let promoted: &IndexSlice<_, _> = &promoted.borrow();
|
||||
*super::do_mir_borrowck(&infcx, input_body, promoted, true).1.unwrap()
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use rustc_errors::{Applicability, Diagnostic};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_infer::infer::NllRegionVariableOrigin;
|
||||
use rustc_middle::mir::{
|
||||
Body, CastKind, ConstraintCategory, FakeReadCause, Local, LocalInfo, Location, Operand, Place,
|
||||
@ -60,7 +60,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
local_names: &IndexVec<Local, Option<Symbol>>,
|
||||
local_names: &IndexSlice<Local, Option<Symbol>>,
|
||||
err: &mut Diagnostic,
|
||||
borrow_desc: &str,
|
||||
borrow_span: Option<Span>,
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
use crate::Upvar;
|
||||
use crate::{nll::ToRegionVid, region_infer::RegionInferenceContext};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice};
|
||||
use rustc_middle::mir::{Body, Local};
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use rustc_span::source_map::Span;
|
||||
@ -14,7 +14,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
local_names: &IndexVec<Local, Option<Symbol>>,
|
||||
local_names: &IndexSlice<Local, Option<Symbol>>,
|
||||
upvars: &[Upvar<'tcx>],
|
||||
fr: RegionVid,
|
||||
) -> Option<(Option<Symbol>, Span)> {
|
||||
@ -113,7 +113,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
pub(crate) fn get_argument_name_and_span_for_region(
|
||||
&self,
|
||||
body: &Body<'tcx>,
|
||||
local_names: &IndexVec<Local, Option<Symbol>>,
|
||||
local_names: &IndexSlice<Local, Option<Symbol>>,
|
||||
argument_index: usize,
|
||||
) -> (Option<Symbol>, Span) {
|
||||
let implicit_inputs = self.universal_regions().defining_ty.implicit_inputs();
|
||||
|
@ -23,7 +23,7 @@ use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticMessage, Subdiagnost
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_index::bit_set::ChunkedBitSet;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_infer::infer::{
|
||||
DefiningAnchor, InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
|
||||
};
|
||||
@ -154,7 +154,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> &Bor
|
||||
let infcx =
|
||||
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)).build();
|
||||
let input_body: &Body<'_> = &input_body.borrow();
|
||||
let promoted: &IndexVec<_, _> = &promoted.borrow();
|
||||
let promoted: &IndexSlice<_, _> = &promoted.borrow();
|
||||
let opt_closure_req = do_mir_borrowck(&infcx, input_body, promoted, false).0;
|
||||
debug!("mir_borrowck done");
|
||||
|
||||
@ -170,7 +170,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -> &Bor
|
||||
fn do_mir_borrowck<'tcx>(
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
input_body: &Body<'tcx>,
|
||||
input_promoted: &IndexVec<Promoted, Body<'tcx>>,
|
||||
input_promoted: &IndexSlice<Promoted, Body<'tcx>>,
|
||||
return_body_with_facts: bool,
|
||||
) -> (BorrowCheckResult<'tcx>, Option<Box<BodyWithBorrowckFacts<'tcx>>>) {
|
||||
let def = input_body.source.with_opt_param().as_local().unwrap();
|
||||
@ -223,7 +223,7 @@ fn do_mir_borrowck<'tcx>(
|
||||
// be modified (in place) to contain non-lexical lifetimes. It
|
||||
// will have a lifetime tied to the inference context.
|
||||
let mut body_owned = input_body.clone();
|
||||
let mut promoted = input_promoted.clone();
|
||||
let mut promoted = input_promoted.to_owned();
|
||||
let free_regions =
|
||||
nll::replace_regions_in_mir(&infcx, param_env, &mut body_owned, &mut promoted);
|
||||
let body = &body_owned; // no further changes
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::infer::MemberConstraint;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::Span;
|
||||
@ -215,7 +215,7 @@ where
|
||||
/// target_list: A -> B -> C -> D -> E -> F -> (None)
|
||||
/// ```
|
||||
fn append_list(
|
||||
constraints: &mut IndexVec<NllMemberConstraintIndex, NllMemberConstraint<'_>>,
|
||||
constraints: &mut IndexSlice<NllMemberConstraintIndex, NllMemberConstraint<'_>>,
|
||||
target_list: NllMemberConstraintIndex,
|
||||
source_list: NllMemberConstraintIndex,
|
||||
) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_middle::mir::{create_dump_file, dump_enabled, dump_mir, PassWhere};
|
||||
use rustc_middle::mir::{
|
||||
BasicBlock, Body, ClosureOutlivesSubject, ClosureRegionRequirements, LocalKind, Location,
|
||||
@ -59,7 +59,7 @@ pub(crate) fn replace_regions_in_mir<'tcx>(
|
||||
infcx: &BorrowckInferCtxt<'_, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body: &mut Body<'tcx>,
|
||||
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
|
||||
promoted: &mut IndexSlice<Promoted, Body<'tcx>>,
|
||||
) -> UniversalRegions<'tcx> {
|
||||
let def = body.source.with_opt_param().as_local().unwrap();
|
||||
|
||||
@ -158,7 +158,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
||||
infcx: &BorrowckInferCtxt<'_, 'tcx>,
|
||||
universal_regions: UniversalRegions<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
promoted: &IndexVec<Promoted, Body<'tcx>>,
|
||||
promoted: &IndexSlice<Promoted, Body<'tcx>>,
|
||||
location_table: &LocationTable,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
flow_inits: &mut ResultsCursor<'cx, 'tcx, MaybeInitializedPlaces<'cx, 'tcx>>,
|
||||
|
@ -7,7 +7,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::graph::scc::Sccs;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir::def_id::CRATE_DEF_ID;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_infer::infer::outlives::test_type_match;
|
||||
use rustc_infer::infer::region_constraints::{GenericKind, VarInfos, VerifyBound, VerifyIfEq};
|
||||
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin};
|
||||
@ -399,7 +399,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// the minimum, or narrowest, universe.
|
||||
fn compute_scc_universes(
|
||||
constraint_sccs: &Sccs<RegionVid, ConstraintSccIndex>,
|
||||
definitions: &IndexVec<RegionVid, RegionDefinition<'tcx>>,
|
||||
definitions: &IndexSlice<RegionVid, RegionDefinition<'tcx>>,
|
||||
) -> IndexVec<ConstraintSccIndex, ty::UniverseIndex> {
|
||||
let num_sccs = constraint_sccs.num_sccs();
|
||||
let mut scc_universes = IndexVec::from_elem_n(ty::UniverseIndex::MAX, num_sccs);
|
||||
@ -486,7 +486,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// more details.
|
||||
fn compute_scc_representatives(
|
||||
constraints_scc: &Sccs<RegionVid, ConstraintSccIndex>,
|
||||
definitions: &IndexVec<RegionVid, RegionDefinition<'tcx>>,
|
||||
definitions: &IndexSlice<RegionVid, RegionDefinition<'tcx>>,
|
||||
) -> IndexVec<ConstraintSccIndex, ty::RegionVid> {
|
||||
let num_sccs = constraints_scc.num_sccs();
|
||||
let next_region_vid = definitions.next_index();
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
use crate::BorrowckInferCtxt;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_infer::infer::NllRegionVariableOrigin;
|
||||
use rustc_middle::mir::visit::{MutVisitor, TyContext};
|
||||
use rustc_middle::mir::Constant;
|
||||
@ -16,7 +16,7 @@ use rustc_span::{Span, Symbol};
|
||||
pub fn renumber_mir<'tcx>(
|
||||
infcx: &BorrowckInferCtxt<'_, 'tcx>,
|
||||
body: &mut Body<'tcx>,
|
||||
promoted: &mut IndexVec<Promoted, Body<'tcx>>,
|
||||
promoted: &mut IndexSlice<Promoted, Body<'tcx>>,
|
||||
) {
|
||||
debug!(?body.arg_count);
|
||||
|
||||
|
@ -125,7 +125,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
||||
infcx: &BorrowckInferCtxt<'_, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
promoted: &IndexVec<Promoted, Body<'tcx>>,
|
||||
promoted: &IndexSlice<Promoted, Body<'tcx>>,
|
||||
universal_regions: &Rc<UniversalRegions<'tcx>>,
|
||||
location_table: &LocationTable,
|
||||
borrow_set: &BorrowSet<'tcx>,
|
||||
@ -292,7 +292,7 @@ enum FieldAccessError {
|
||||
/// is a problem.
|
||||
struct TypeVerifier<'a, 'b, 'tcx> {
|
||||
cx: &'a mut TypeChecker<'b, 'tcx>,
|
||||
promoted: &'b IndexVec<Promoted, Body<'tcx>>,
|
||||
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
|
||||
last_span: Span,
|
||||
errors_reported: bool,
|
||||
}
|
||||
@ -493,7 +493,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
|
||||
impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
||||
fn new(
|
||||
cx: &'a mut TypeChecker<'b, 'tcx>,
|
||||
promoted: &'b IndexVec<Promoted, Body<'tcx>>,
|
||||
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
|
||||
) -> Self {
|
||||
TypeVerifier { promoted, last_span: cx.body.span, cx, errors_reported: false }
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use rustc_codegen_ssa::debuginfo::{
|
||||
wants_c_like_enum_debuginfo,
|
||||
};
|
||||
use rustc_hir::def::CtorKind;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_middle::{
|
||||
bug,
|
||||
mir::{GeneratorLayout, GeneratorSavedLocal},
|
||||
@ -323,7 +323,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
|
||||
generator_type_and_layout: TyAndLayout<'tcx>,
|
||||
generator_type_di_node: &'ll DIType,
|
||||
generator_layout: &GeneratorLayout<'tcx>,
|
||||
state_specific_upvar_names: &IndexVec<GeneratorSavedLocal, Option<Symbol>>,
|
||||
state_specific_upvar_names: &IndexSlice<GeneratorSavedLocal, Option<Symbol>>,
|
||||
common_upvar_names: &[String],
|
||||
) -> &'ll DIType {
|
||||
let variant_name = GeneratorSubsts::variant_name(variant_index);
|
||||
|
@ -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] {
|
||||
|
@ -21,7 +21,7 @@ use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::{self, List, TyCtxt, TypeVisitableExt};
|
||||
use rustc_span::Span;
|
||||
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::{cmp, iter, mem};
|
||||
@ -184,7 +184,7 @@ pub fn collect_temps_and_candidates<'tcx>(
|
||||
/// This wraps an `Item`, and has access to all fields of that `Item` via `Deref` coercion.
|
||||
struct Validator<'a, 'tcx> {
|
||||
ccx: &'a ConstCx<'a, 'tcx>,
|
||||
temps: &'a mut IndexVec<Local, TempState>,
|
||||
temps: &'a mut IndexSlice<Local, TempState>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> std::ops::Deref for Validator<'a, 'tcx> {
|
||||
@ -669,7 +669,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
||||
// FIXME(eddyb) remove the differences for promotability in `static`, `const`, `const fn`.
|
||||
pub fn validate_candidates(
|
||||
ccx: &ConstCx<'_, '_>,
|
||||
temps: &mut IndexVec<Local, TempState>,
|
||||
temps: &mut IndexSlice<Local, TempState>,
|
||||
candidates: &[Candidate],
|
||||
) -> Vec<Candidate> {
|
||||
let mut validator = Validator { ccx, temps };
|
||||
|
@ -10,7 +10,7 @@
|
||||
//! <https://www.cs.princeton.edu/courses/archive/spr03/cs423/download/dominators.pdf>
|
||||
|
||||
use super::ControlFlowGraph;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
#[cfg(test)]
|
||||
@ -256,10 +256,10 @@ pub fn dominators<G: ControlFlowGraph>(graph: G) -> Dominators<G::Node> {
|
||||
/// where `+>` is a proper ancestor and `*>` is just an ancestor.
|
||||
#[inline]
|
||||
fn eval(
|
||||
ancestor: &mut IndexVec<PreorderIndex, PreorderIndex>,
|
||||
ancestor: &mut IndexSlice<PreorderIndex, PreorderIndex>,
|
||||
lastlinked: Option<PreorderIndex>,
|
||||
semi: &IndexVec<PreorderIndex, PreorderIndex>,
|
||||
label: &mut IndexVec<PreorderIndex, PreorderIndex>,
|
||||
semi: &IndexSlice<PreorderIndex, PreorderIndex>,
|
||||
label: &mut IndexSlice<PreorderIndex, PreorderIndex>,
|
||||
node: PreorderIndex,
|
||||
) -> PreorderIndex {
|
||||
if is_processed(node, lastlinked) {
|
||||
@ -277,10 +277,10 @@ fn is_processed(v: PreorderIndex, lastlinked: Option<PreorderIndex>) -> bool {
|
||||
|
||||
#[inline]
|
||||
fn compress(
|
||||
ancestor: &mut IndexVec<PreorderIndex, PreorderIndex>,
|
||||
ancestor: &mut IndexSlice<PreorderIndex, PreorderIndex>,
|
||||
lastlinked: Option<PreorderIndex>,
|
||||
semi: &IndexVec<PreorderIndex, PreorderIndex>,
|
||||
label: &mut IndexVec<PreorderIndex, PreorderIndex>,
|
||||
semi: &IndexSlice<PreorderIndex, PreorderIndex>,
|
||||
label: &mut IndexSlice<PreorderIndex, PreorderIndex>,
|
||||
v: PreorderIndex,
|
||||
) {
|
||||
assert!(is_processed(v, lastlinked));
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::{DirectedGraph, WithNumNodes, WithStartNode, WithSuccessors};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
#[cfg(test)]
|
||||
@ -31,7 +31,7 @@ fn post_order_walk<G: DirectedGraph + WithSuccessors + WithNumNodes>(
|
||||
graph: &G,
|
||||
node: G::Node,
|
||||
result: &mut Vec<G::Node>,
|
||||
visited: &mut IndexVec<G::Node, bool>,
|
||||
visited: &mut IndexSlice<G::Node, bool>,
|
||||
) {
|
||||
struct PostOrderFrame<Node, Iter> {
|
||||
node: Node,
|
||||
|
@ -8,7 +8,7 @@
|
||||
use crate::fx::FxHashSet;
|
||||
use crate::graph::vec_graph::VecGraph;
|
||||
use crate::graph::{DirectedGraph, GraphSuccessors, WithNumEdges, WithNumNodes, WithSuccessors};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use std::ops::Range;
|
||||
|
||||
#[cfg(test)]
|
||||
@ -43,7 +43,7 @@ impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
|
||||
SccsConstruction::construct(graph)
|
||||
}
|
||||
|
||||
pub fn scc_indices(&self) -> &IndexVec<N, S> {
|
||||
pub fn scc_indices(&self) -> &IndexSlice<N, S> {
|
||||
&self.scc_indices
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ impl<S: Idx> SccData<S> {
|
||||
self.ranges.len()
|
||||
}
|
||||
|
||||
pub fn ranges(&self) -> &IndexVec<S, Range<usize>> {
|
||||
pub fn ranges(&self) -> &IndexSlice<S, Range<usize>> {
|
||||
&self.ranges
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#[cfg(feature = "rustc_serialize")]
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
@ -51,6 +52,12 @@ impl Idx for u32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// An owned contiguous collection of `T`s, indexed by `I` rather than by `usize`.
|
||||
///
|
||||
/// While it's possible to use `u32` or `usize` directly for `I`,
|
||||
/// you almost certainly want to use a [`newtype_index!`]-generated type instead.
|
||||
///
|
||||
/// [`newtype_index!`]: ../macro.newtype_index.html
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct IndexVec<I: Idx, T> {
|
||||
@ -58,6 +65,13 @@ pub struct IndexVec<I: Idx, T> {
|
||||
_marker: PhantomData<fn(&I)>,
|
||||
}
|
||||
|
||||
/// A view into contiguous `T`s, indexed by `I` rather than by `usize`.
|
||||
///
|
||||
/// One common pattern you'll see is code that uses [`IndexVec::from_elem`]
|
||||
/// to create the storage needed for a particular "universe" (aka the set of all
|
||||
/// the possible keys that need an associated value) then passes that working
|
||||
/// area as `&mut IndexSlice<I, T>` to clarify that nothing will be added nor
|
||||
/// removed during processing (and, as a bonus, to chase fewer pointers).
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct IndexSlice<I: Idx, T> {
|
||||
@ -116,7 +130,7 @@ impl<I: Idx, T> IndexVec<I, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_elem<S>(elem: T, universe: &IndexVec<I, S>) -> Self
|
||||
pub fn from_elem<S>(elem: T, universe: &IndexSlice<I, S>) -> Self
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
@ -244,6 +258,30 @@ impl<I: Idx, T> DerefMut for IndexVec<I, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Idx, T> Borrow<IndexSlice<I, T>> for IndexVec<I, T> {
|
||||
fn borrow(&self) -> &IndexSlice<I, T> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Idx, T> BorrowMut<IndexSlice<I, T>> for IndexVec<I, T> {
|
||||
fn borrow_mut(&mut self) -> &mut IndexSlice<I, T> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Idx, T: Clone> ToOwned for IndexSlice<I, T> {
|
||||
type Owned = IndexVec<I, T>;
|
||||
|
||||
fn to_owned(&self) -> IndexVec<I, T> {
|
||||
IndexVec::from_raw(self.raw.to_owned())
|
||||
}
|
||||
|
||||
fn clone_into(&self, target: &mut IndexVec<I, T>) {
|
||||
self.raw.clone_into(&mut target.raw)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Idx, T> IndexSlice<I, T> {
|
||||
#[inline]
|
||||
pub fn from_raw(raw: &[T]) -> &Self {
|
||||
@ -388,7 +426,7 @@ impl<I: Idx, T: Clone> IndexVec<I, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Idx, T: Ord> IndexVec<I, T> {
|
||||
impl<I: Idx, T: Ord> IndexSlice<I, T> {
|
||||
#[inline]
|
||||
pub fn binary_search(&self, value: &T) -> Result<I, I> {
|
||||
match self.raw.binary_search(value) {
|
||||
|
@ -13,7 +13,7 @@ use rustc_data_structures::graph::implementation::{
|
||||
Direction, Graph, NodeIndex, INCOMING, OUTGOING,
|
||||
};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::PlaceholderRegion;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
@ -723,7 +723,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
||||
fn collect_error_for_expanding_node(
|
||||
&self,
|
||||
graph: &RegionGraph<'tcx>,
|
||||
dup_vec: &mut IndexVec<RegionVid, Option<RegionVid>>,
|
||||
dup_vec: &mut IndexSlice<RegionVid, Option<RegionVid>>,
|
||||
node_idx: RegionVid,
|
||||
errors: &mut Vec<RegionResolutionError<'tcx>>,
|
||||
) {
|
||||
@ -846,7 +846,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
||||
graph: &RegionGraph<'tcx>,
|
||||
orig_node_idx: RegionVid,
|
||||
dir: Direction,
|
||||
mut dup_vec: Option<&mut IndexVec<RegionVid, Option<RegionVid>>>,
|
||||
mut dup_vec: Option<&mut IndexSlice<RegionVid, Option<RegionVid>>>,
|
||||
) -> (Vec<RegionAndOrigin<'tcx>>, FxHashSet<RegionVid>, bool) {
|
||||
struct WalkState<'tcx> {
|
||||
set: FxHashSet<RegionVid>,
|
||||
|
@ -6,7 +6,7 @@ use rustc_data_structures::graph;
|
||||
use rustc_data_structures::graph::dominators::{dominators, Dominators};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::OnceCell;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
@ -124,10 +124,10 @@ impl<'tcx> BasicBlocks<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> std::ops::Deref for BasicBlocks<'tcx> {
|
||||
type Target = IndexVec<BasicBlock, BasicBlockData<'tcx>>;
|
||||
type Target = IndexSlice<BasicBlock, BasicBlockData<'tcx>>;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &IndexVec<BasicBlock, BasicBlockData<'tcx>> {
|
||||
fn deref(&self) -> &IndexSlice<BasicBlock, BasicBlockData<'tcx>> {
|
||||
&self.basic_blocks
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use polonius_engine::Atom;
|
||||
pub use rustc_ast::Mutability;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_serialize::{Decodable, Encodable};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
@ -70,12 +70,19 @@ pub use self::pretty::{
|
||||
};
|
||||
|
||||
/// Types for locals
|
||||
pub type LocalDecls<'tcx> = IndexVec<Local, LocalDecl<'tcx>>;
|
||||
pub type LocalDecls<'tcx> = IndexSlice<Local, LocalDecl<'tcx>>;
|
||||
|
||||
pub trait HasLocalDecls<'tcx> {
|
||||
fn local_decls(&self) -> &LocalDecls<'tcx>;
|
||||
}
|
||||
|
||||
impl<'tcx> HasLocalDecls<'tcx> for IndexVec<Local, LocalDecl<'tcx>> {
|
||||
#[inline]
|
||||
fn local_decls(&self) -> &LocalDecls<'tcx> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> HasLocalDecls<'tcx> for LocalDecls<'tcx> {
|
||||
#[inline]
|
||||
fn local_decls(&self) -> &LocalDecls<'tcx> {
|
||||
@ -250,7 +257,7 @@ pub struct Body<'tcx> {
|
||||
/// The first local is the return value pointer, followed by `arg_count`
|
||||
/// locals for the function arguments, followed by any user-declared
|
||||
/// variables and temporaries.
|
||||
pub local_decls: LocalDecls<'tcx>,
|
||||
pub local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||
|
||||
/// User type annotations.
|
||||
pub user_type_annotations: ty::CanonicalUserTypeAnnotations<'tcx>,
|
||||
@ -311,7 +318,7 @@ impl<'tcx> Body<'tcx> {
|
||||
source: MirSource<'tcx>,
|
||||
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
|
||||
local_decls: LocalDecls<'tcx>,
|
||||
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
|
||||
user_type_annotations: ty::CanonicalUserTypeAnnotations<'tcx>,
|
||||
arg_count: usize,
|
||||
var_debug_info: Vec<VarDebugInfo<'tcx>>,
|
||||
@ -1779,7 +1786,7 @@ impl SourceScope {
|
||||
/// from the function that was inlined instead of the function call site.
|
||||
pub fn lint_root(
|
||||
self,
|
||||
source_scopes: &IndexVec<SourceScope, SourceScopeData<'_>>,
|
||||
source_scopes: &IndexSlice<SourceScope, SourceScopeData<'_>>,
|
||||
) -> Option<HirId> {
|
||||
let mut data = &source_scopes[self];
|
||||
// FIXME(oli-obk): we should be able to just walk the `inlined_parent_scope`, but it
|
||||
@ -1799,7 +1806,7 @@ impl SourceScope {
|
||||
#[inline]
|
||||
pub fn inlined_instance<'tcx>(
|
||||
self,
|
||||
source_scopes: &IndexVec<SourceScope, SourceScopeData<'tcx>>,
|
||||
source_scopes: &IndexSlice<SourceScope, SourceScopeData<'tcx>>,
|
||||
) -> Option<ty::Instance<'tcx>> {
|
||||
let scope_data = &source_scopes[self];
|
||||
if let Some((inlined_instance, _)) = scope_data.inlined {
|
||||
|
@ -116,7 +116,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Place<'tcx> {
|
||||
pub fn ty_from<D>(
|
||||
pub fn ty_from<D: ?Sized>(
|
||||
local: Local,
|
||||
projection: &[PlaceElem<'tcx>],
|
||||
local_decls: &D,
|
||||
@ -132,7 +132,7 @@ impl<'tcx> Place<'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
@ -141,7 +141,7 @@ impl<'tcx> Place<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> PlaceRef<'tcx> {
|
||||
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
@ -155,7 +155,7 @@ pub enum RvalueInitializationState {
|
||||
}
|
||||
|
||||
impl<'tcx> Rvalue<'tcx> {
|
||||
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
@ -217,7 +217,7 @@ impl<'tcx> Rvalue<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Operand<'tcx> {
|
||||
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
|
||||
///
|
||||
/// A Postorder traversal of this graph is `D B C A` or `D C B A`
|
||||
pub struct Postorder<'a, 'tcx> {
|
||||
basic_blocks: &'a IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
basic_blocks: &'a IndexSlice<BasicBlock, BasicBlockData<'tcx>>,
|
||||
visited: BitSet<BasicBlock>,
|
||||
visit_stack: Vec<(BasicBlock, Successors<'a>)>,
|
||||
root_is_start_block: bool,
|
||||
@ -109,7 +109,7 @@ pub struct Postorder<'a, 'tcx> {
|
||||
|
||||
impl<'a, 'tcx> Postorder<'a, 'tcx> {
|
||||
pub fn new(
|
||||
basic_blocks: &'a IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
basic_blocks: &'a IndexSlice<BasicBlock, BasicBlockData<'tcx>>,
|
||||
root: BasicBlock,
|
||||
) -> Postorder<'a, 'tcx> {
|
||||
let mut po = Postorder {
|
||||
|
@ -10,7 +10,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
use rustc_session::DataTypeKind;
|
||||
use rustc_span::symbol::sym;
|
||||
@ -168,7 +168,7 @@ impl<'tcx> AdtDef<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn variants(self) -> &'tcx IndexVec<VariantIdx, VariantDef> {
|
||||
pub fn variants(self) -> &'tcx IndexSlice<VariantIdx, VariantDef> {
|
||||
&self.0.0.variants
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -128,7 +128,7 @@ fn split_block(
|
||||
|
||||
fn insert_alignment_check<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
local_decls: &mut LocalDecls<'tcx>,
|
||||
local_decls: &mut IndexVec<Local, LocalDecl<'tcx>>,
|
||||
block_data: &mut BasicBlockData<'tcx>,
|
||||
pointer: Place<'tcx>,
|
||||
pointee_ty: Ty<'tcx>,
|
||||
|
@ -7,7 +7,7 @@ use rustc_const_eval::const_eval::CheckAlignment;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::visit::{
|
||||
MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor,
|
||||
};
|
||||
@ -127,7 +127,7 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
|
||||
|
||||
let dummy_body = &Body::new(
|
||||
body.source,
|
||||
(*body.basic_blocks).clone(),
|
||||
(*body.basic_blocks).to_owned(),
|
||||
body.source_scopes.clone(),
|
||||
body.local_decls.clone(),
|
||||
Default::default(),
|
||||
@ -319,7 +319,7 @@ struct ConstPropagator<'mir, 'tcx> {
|
||||
ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
local_decls: &'mir IndexVec<Local, LocalDecl<'tcx>>,
|
||||
local_decls: &'mir IndexSlice<Local, LocalDecl<'tcx>>,
|
||||
}
|
||||
|
||||
impl<'tcx> LayoutOfHelpers<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||
|
@ -9,7 +9,7 @@ use rustc_const_eval::interpret::{
|
||||
};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout};
|
||||
@ -103,7 +103,7 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
|
||||
|
||||
let dummy_body = &Body::new(
|
||||
body.source,
|
||||
(*body.basic_blocks).clone(),
|
||||
(*body.basic_blocks).to_owned(),
|
||||
body.source_scopes.clone(),
|
||||
body.local_decls.clone(),
|
||||
Default::default(),
|
||||
@ -130,8 +130,8 @@ struct ConstPropagator<'mir, 'tcx> {
|
||||
ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
source_scopes: &'mir IndexVec<SourceScope, SourceScopeData<'tcx>>,
|
||||
local_decls: &'mir IndexVec<Local, LocalDecl<'tcx>>,
|
||||
source_scopes: &'mir IndexSlice<SourceScope, SourceScopeData<'tcx>>,
|
||||
local_decls: &'mir IndexSlice<Local, LocalDecl<'tcx>>,
|
||||
// Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
|
||||
// the last known `SourceInfo` here and just keep revisiting it.
|
||||
source_info: Option<SourceInfo>,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_middle::mir::visit::*;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -102,7 +102,7 @@ struct Replacer<'a, 'tcx> {
|
||||
fully_moved: BitSet<Local>,
|
||||
storage_to_remove: BitSet<Local>,
|
||||
borrowed_locals: BitSet<Local>,
|
||||
copy_classes: &'a IndexVec<Local, Local>,
|
||||
copy_classes: &'a IndexSlice<Local, Local>,
|
||||
}
|
||||
|
||||
impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
|
||||
|
@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::graph::dominators::{self, Dominators};
|
||||
use rustc_data_structures::graph::{self, GraphSuccessors, WithNumNodes, WithStartNode};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::{IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::coverage::*;
|
||||
use rustc_middle::mir::{self, BasicBlock, BasicBlockData, Terminator, TerminatorKind};
|
||||
|
||||
@ -176,10 +176,10 @@ impl CoverageGraph {
|
||||
|
||||
fn add_basic_coverage_block(
|
||||
bcbs: &mut IndexVec<BasicCoverageBlock, BasicCoverageBlockData>,
|
||||
bb_to_bcb: &mut IndexVec<BasicBlock, Option<BasicCoverageBlock>>,
|
||||
bb_to_bcb: &mut IndexSlice<BasicBlock, Option<BasicCoverageBlock>>,
|
||||
basic_blocks: Vec<BasicBlock>,
|
||||
) {
|
||||
let bcb = BasicCoverageBlock::from_usize(bcbs.len());
|
||||
let bcb = bcbs.next_index();
|
||||
for &bb in basic_blocks.iter() {
|
||||
bb_to_bcb[bb] = Some(bcb);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
use crate::MirPass;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_index::vec::IndexSlice;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
||||
@ -42,7 +42,7 @@ struct SliceLenPatchInformation<'tcx> {
|
||||
fn lower_slice_len_call<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
block: &mut BasicBlockData<'tcx>,
|
||||
local_decls: &IndexVec<Local, LocalDecl<'tcx>>,
|
||||
local_decls: &IndexSlice<Local, LocalDecl<'tcx>>,
|
||||
slice_len_fn_item_def_id: DefId,
|
||||
) {
|
||||
let mut patch_found: Option<SliceLenPatchInformation<'_>> = None;
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
use crate::MirPass;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_index::vec::{Idx, IndexSlice, IndexVec};
|
||||
use rustc_middle::mir::coverage::*;
|
||||
use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
@ -67,7 +67,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyCfg {
|
||||
}
|
||||
|
||||
pub struct CfgSimplifier<'a, 'tcx> {
|
||||
basic_blocks: &'a mut IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
basic_blocks: &'a mut IndexSlice<BasicBlock, BasicBlockData<'tcx>>,
|
||||
pred_count: IndexVec<BasicBlock, u32>,
|
||||
}
|
||||
|
||||
@ -369,8 +369,8 @@ pub fn remove_dead_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
/// instances in a single body, so the strategy described above is applied to
|
||||
/// coverage counters from each instance individually.
|
||||
fn save_unreachable_coverage(
|
||||
basic_blocks: &mut IndexVec<BasicBlock, BasicBlockData<'_>>,
|
||||
source_scopes: &IndexVec<SourceScope, SourceScopeData<'_>>,
|
||||
basic_blocks: &mut IndexSlice<BasicBlock, BasicBlockData<'_>>,
|
||||
source_scopes: &IndexSlice<SourceScope, SourceScopeData<'_>>,
|
||||
first_dead_block: usize,
|
||||
) {
|
||||
// Identify instances that still have some live coverage counters left.
|
||||
@ -489,7 +489,7 @@ fn make_local_map<V>(
|
||||
local_decls: &mut IndexVec<Local, V>,
|
||||
used_locals: &UsedLocals,
|
||||
) -> IndexVec<Local, Option<Local>> {
|
||||
let mut map: IndexVec<Local, Option<Local>> = IndexVec::from_elem(None, &*local_decls);
|
||||
let mut map: IndexVec<Local, Option<Local>> = IndexVec::from_elem(None, local_decls);
|
||||
let mut used = Local::new(0);
|
||||
|
||||
for alive_index in local_decls.indices() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use either::Either;
|
||||
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::middle::resolve_bound_vars::Set1;
|
||||
use rustc_middle::mir::visit::*;
|
||||
use rustc_middle::mir::*;
|
||||
@ -135,7 +135,7 @@ impl SsaLocals {
|
||||
/// _d => _a // transitively through _c
|
||||
///
|
||||
/// Exception: we do not see through the return place, as it cannot be substituted.
|
||||
pub fn copy_classes(&self) -> &IndexVec<Local, Local> {
|
||||
pub fn copy_classes(&self) -> &IndexSlice<Local, Local> {
|
||||
&self.copy_classes
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user