Skip to content

Commit

Permalink
Auto merge of #64778 - csmoe:index, r=eddyb
Browse files Browse the repository at this point in the history
Introduce librustc_index crate

Closes #50592
  • Loading branch information
bors committed Sep 30, 2019
2 parents e0436d9 + 64f61c7 commit 22bc9e1
Show file tree
Hide file tree
Showing 148 changed files with 249 additions and 203 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock
Expand Up @@ -3081,6 +3081,7 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_fs_util",
"rustc_index",
"rustc_macros",
"rustc_target",
"scoped-tls",
Expand Down Expand Up @@ -3361,6 +3362,7 @@ dependencies = [
"rustc_errors",
"rustc_fs_util",
"rustc_incremental",
"rustc_index",
"rustc_target",
"serialize",
"syntax",
Expand Down Expand Up @@ -3399,6 +3401,7 @@ dependencies = [
"rustc-hash",
"rustc-rayon",
"rustc-rayon-core",
"rustc_index",
"serialize",
"smallvec",
"stable_deref_trait",
Expand Down Expand Up @@ -3462,6 +3465,14 @@ dependencies = [
"syntax_pos",
]

[[package]]
name = "rustc_index"
version = "0.0.0"
dependencies = [
"serialize",
"smallvec",
]

[[package]]
name = "rustc_interface"
version = "0.0.0"
Expand Down Expand Up @@ -3506,6 +3517,7 @@ dependencies = [
"log",
"rustc",
"rustc_data_structures",
"rustc_index",
"rustc_target",
"syntax",
"syntax_pos",
Expand Down Expand Up @@ -3551,6 +3563,7 @@ dependencies = [
"rustc",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_target",
"serialize",
"smallvec",
Expand All @@ -3573,6 +3586,7 @@ dependencies = [
"rustc_apfloat",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"serialize",
Expand Down Expand Up @@ -3672,6 +3686,7 @@ dependencies = [
"bitflags",
"log",
"rustc_data_structures",
"rustc_index",
"serialize",
"syntax_pos",
]
Expand Down Expand Up @@ -3720,6 +3735,7 @@ dependencies = [
"rustc",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_target",
"smallvec",
"syntax",
Expand Down Expand Up @@ -4236,6 +4252,7 @@ dependencies = [
"log",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"scoped-tls",
Expand Down Expand Up @@ -4265,6 +4282,7 @@ dependencies = [
"arena",
"cfg-if",
"rustc_data_structures",
"rustc_index",
"rustc_macros",
"scoped-tls",
"serialize",
Expand Down
1 change: 1 addition & 0 deletions src/librustc/Cargo.toml
Expand Up @@ -25,6 +25,7 @@ rustc_apfloat = { path = "../librustc_apfloat" }
rustc_target = { path = "../librustc_target" }
rustc_macros = { path = "../librustc_macros" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_index = { path = "../librustc_index" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
syntax = { path = "../libsyntax" }
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/arena.rs
Expand Up @@ -26,12 +26,12 @@ macro_rules! arena_types {
[] steal_mir: rustc::ty::steal::Steal<rustc::mir::Body<$tcx>>,
[] mir: rustc::mir::Body<$tcx>,
[] steal_promoted: rustc::ty::steal::Steal<
rustc_data_structures::indexed_vec::IndexVec<
rustc_index::vec::IndexVec<
rustc::mir::Promoted,
rustc::mir::Body<$tcx>
>
>,
[] promoted: rustc_data_structures::indexed_vec::IndexVec<
[] promoted: rustc_index::vec::IndexVec<
rustc::mir::Promoted,
rustc::mir::Body<$tcx>
>,
Expand All @@ -45,7 +45,7 @@ macro_rules! arena_types {
[decode] specialization_graph: rustc::traits::specialization_graph::Graph,
[] region_scope_tree: rustc::middle::region::ScopeTree,
[] item_local_set: rustc::util::nodemap::ItemLocalSet,
[decode] mir_const_qualif: rustc_data_structures::bit_set::BitSet<rustc::mir::Local>,
[decode] mir_const_qualif: rustc_index::bit_set::BitSet<rustc::mir::Local>,
[] trait_impls_of: rustc::ty::trait_def::TraitImpls,
[] dropck_outlives:
rustc::infer::canonical::Canonical<'tcx,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/dep_graph/graph.rs
@@ -1,7 +1,7 @@
use errors::Diagnostic;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_index::vec::{Idx, IndexVec};
use smallvec::SmallVec;
use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, Ordering};
use std::env;
Expand All @@ -26,7 +26,7 @@ pub struct DepGraph {
data: Option<Lrc<DepGraphData>>,
}

newtype_index! {
rustc_index::newtype_index! {
pub struct DepNodeIndex { .. }
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/dep_graph/serialized.rs
Expand Up @@ -2,9 +2,9 @@

use crate::dep_graph::DepNode;
use crate::ich::Fingerprint;
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use rustc_index::vec::{IndexVec, Idx};

newtype_index! {
rustc_index::newtype_index! {
pub struct SerializedDepNodeIndex { .. }
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/def_id.rs
@@ -1,9 +1,9 @@
use crate::ty::{self, TyCtxt};
use rustc_data_structures::indexed_vec::Idx;
use rustc_index::vec::Idx;
use std::fmt;
use std::u32;

newtype_index! {
rustc_index::newtype_index! {
pub struct CrateId {
ENCODABLE = custom
}
Expand Down Expand Up @@ -87,7 +87,7 @@ impl fmt::Display for CrateNum {
impl rustc_serialize::UseSpecializedEncodable for CrateNum {}
impl rustc_serialize::UseSpecializedDecodable for CrateNum {}

newtype_index! {
rustc_index::newtype_index! {
/// A DefIndex is an index into the hir-map for a crate, identifying a
/// particular definition. It should really be considered an interned
/// shorthand for a particular DefPath.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/lowering.rs
Expand Up @@ -52,7 +52,7 @@ use crate::util::common::FN_OUTPUT_NAME;
use crate::util::nodemap::{DefIdMap, NodeMap};
use errors::Applicability;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::IndexVec;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_data_structures::sync::Lrc;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Expand Up @@ -5,7 +5,7 @@ use crate::hir::map::HirEntryMap;
use crate::hir::def_id::{LOCAL_CRATE, CrateNum};
use crate::hir::intravisit::{Visitor, NestedVisitorMap};
use rustc_data_structures::svh::Svh;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::IndexVec;
use crate::ich::Fingerprint;
use crate::middle::cstore::CrateStore;
use crate::session::CrateDisambiguator;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/definitions.rs
Expand Up @@ -11,7 +11,7 @@ use crate::session::CrateDisambiguator;
use crate::util::nodemap::NodeMap;

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::{IndexVec};
use rustc_index::vec::{IndexVec};
use rustc_data_structures::stable_hasher::StableHasher;
use std::borrow::Borrow;
use std::fmt::Write;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Expand Up @@ -17,7 +17,7 @@ use crate::util::common::time;

use rustc_target::spec::abi::Abi;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::IndexVec;
use syntax::ast::{self, Name, NodeId};
use syntax::source_map::Spanned;
use syntax::ext::base::MacroKind;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/mod.rs
Expand Up @@ -122,9 +122,9 @@ impl fmt::Display for HirId {

// Hack to ensure that we don't try to access the private parts of `ItemLocalId` in this module.
mod item_local_id_inner {
use rustc_data_structures::indexed_vec::Idx;
use rustc_index::vec::Idx;
use rustc_macros::HashStable;
newtype_index! {
rustc_index::newtype_index! {
/// An `ItemLocalId` uniquely identifies something within a given "item-like";
/// that is, within a `hir::Item`, `hir::TraitItem`, or `hir::ImplItem`. There is no
/// guarantee that the numerical value of a given `ItemLocalId` corresponds to
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/canonicalizer.rs
Expand Up @@ -18,7 +18,7 @@ use crate::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags};
use crate::ty::flags::FlagComputation;

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx;
use rustc_index::vec::Idx;
use smallvec::SmallVec;

impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/canonical/mod.rs
Expand Up @@ -25,7 +25,7 @@ use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVari
use crate::infer::{ConstVariableOrigin, ConstVariableOriginKind};
use crate::infer::region_constraints::MemberConstraint;
use crate::mir::interpret::ConstValue;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::IndexVec;
use rustc_macros::HashStable;
use rustc_serialize::UseSpecializedDecodable;
use smallvec::SmallVec;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/canonical/query_response.rs
Expand Up @@ -17,8 +17,8 @@ use crate::infer::region_constraints::{Constraint, RegionConstraintData};
use crate::infer::InferCtxtBuilder;
use crate::infer::{InferCtxt, InferOk, InferResult};
use crate::mir::interpret::ConstValue;
use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::Idx;
use rustc_index::vec::IndexVec;
use std::fmt::Debug;
use syntax_pos::DUMMY_SP;
use crate::traits::query::{Fallible, NoSolution};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/lexical_region_resolve/mod.rs
Expand Up @@ -19,7 +19,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::graph::implementation::{
Direction, Graph, NodeIndex, INCOMING, OUTGOING,
};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_index::vec::{Idx, IndexVec};
use smallvec::SmallVec;
use std::fmt;
use syntax_pos::Span;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/region_constraints/mod.rs
Expand Up @@ -7,7 +7,7 @@ use super::unify_key;
use super::{MiscVariable, RegionVariableOrigin, SubregionOrigin};

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::IndexVec;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::unify as ut;
use crate::hir::def_id::DefId;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/intrinsicck.rs
Expand Up @@ -5,7 +5,7 @@ use crate::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx};
use crate::ty::query::Providers;

use rustc_target::spec::abi::Abi::RustIntrinsic;
use rustc_data_structures::indexed_vec::Idx;
use rustc_index::vec::Idx;
use syntax_pos::{Span, sym};
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
use crate::hir;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/region.rs
Expand Up @@ -16,8 +16,8 @@ use crate::util::nodemap::{FxHashMap, FxHashSet};
use crate::ty::{self, DefIdTree, TyCtxt};
use crate::ty::query::Providers;

use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_index::vec::Idx;
use rustc_macros::HashStable;
use syntax::source_map;
use syntax_pos::{Span, DUMMY_SP};
Expand Down Expand Up @@ -131,7 +131,7 @@ pub enum ScopeData {
Remainder(FirstStatementIndex)
}

newtype_index! {
rustc_index::newtype_index! {
/// Represents a subscope of `block` for a binding that is introduced
/// by `block.stmts[first_statement_index]`. Such subscopes represent
/// a suffix of the block. Note that each subscope does not include
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/cache.rs
@@ -1,4 +1,4 @@
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_index::vec::IndexVec;
use rustc_data_structures::sync::{RwLock, MappedReadGuard, ReadGuard};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/mir/mod.rs
Expand Up @@ -20,11 +20,11 @@ use crate::ty::{
};

use polonius_engine::Atom;
use rustc_data_structures::bit_set::BitMatrix;
use rustc_index::bit_set::BitMatrix;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::graph::dominators::{dominators, Dominators};
use rustc_data_structures::graph::{self, GraphPredecessors, GraphSuccessors};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_index::vec::{Idx, IndexVec};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::sync::MappedReadGuard;
use rustc_macros::HashStable;
Expand Down Expand Up @@ -581,7 +581,7 @@ impl BorrowKind {
///////////////////////////////////////////////////////////////////////////
// Variables and temps

newtype_index! {
rustc_index::newtype_index! {
pub struct Local {
derive [HashStable]
DEBUG_FORMAT = "_{}",
Expand Down Expand Up @@ -994,7 +994,7 @@ pub struct UpvarDebuginfo {
///////////////////////////////////////////////////////////////////////////
// BasicBlock

newtype_index! {
rustc_index::newtype_index! {
pub struct BasicBlock {
derive [HashStable]
DEBUG_FORMAT = "bb{}",
Expand Down Expand Up @@ -1832,7 +1832,7 @@ static_assert_size!(PlaceElem<'_>, 16);
/// need neither the `V` parameter for `Index` nor the `T` for `Field`.
pub type ProjectionKind = ProjectionElem<(), ()>;

newtype_index! {
rustc_index::newtype_index! {
pub struct Field {
derive [HashStable]
DEBUG_FORMAT = "field[{}]"
Expand Down Expand Up @@ -2047,7 +2047,7 @@ impl Debug for PlaceBase<'_> {
///////////////////////////////////////////////////////////////////////////
// Scopes

newtype_index! {
rustc_index::newtype_index! {
pub struct SourceScope {
derive [HashStable]
DEBUG_FORMAT = "scope[{}]",
Expand Down Expand Up @@ -2586,7 +2586,7 @@ impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
}
}

newtype_index! {
rustc_index::newtype_index! {
pub struct Promoted {
derive [HashStable]
DEBUG_FORMAT = "promoted[{}]"
Expand Down Expand Up @@ -2743,7 +2743,7 @@ pub struct UnsafetyCheckResult {
pub unsafe_blocks: Lrc<[(hir::HirId, bool)]>,
}

newtype_index! {
rustc_index::newtype_index! {
pub struct GeneratorSavedLocal {
derive [HashStable]
DEBUG_FORMAT = "_{}",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/traversal.rs
@@ -1,4 +1,4 @@
use rustc_data_structures::bit_set::BitSet;
use rustc_index::bit_set::BitSet;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Expand Up @@ -132,7 +132,7 @@ rustc_queries! {
cache_on_disk_if { key.is_local() }
load_cached(tcx, id) {
let promoted: Option<
rustc_data_structures::indexed_vec::IndexVec<
rustc_index::vec::IndexVec<
crate::mir::Promoted,
crate::mir::Body<'tcx>
>> = tcx.queries.on_disk_cache.try_load_query_result(tcx, id);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/select.rs
Expand Up @@ -40,7 +40,7 @@ use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};

use crate::hir;
use rustc_data_structures::bit_set::GrowableBitSet;
use rustc_index::bit_set::GrowableBitSet;
use rustc_data_structures::sync::Lock;
use rustc_target::spec::abi::Abi;
use syntax::attr;
Expand Down

0 comments on commit 22bc9e1

Please sign in to comment.