Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce librustc_index crate #64778

Merged
merged 5 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3082,6 +3082,7 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_fs_util",
"rustc_index",
"rustc_macros",
"rustc_target",
"scoped-tls",
Expand Down Expand Up @@ -3362,6 +3363,7 @@ dependencies = [
"rustc_errors",
"rustc_fs_util",
"rustc_incremental",
"rustc_index",
"rustc_target",
"serialize",
"syntax",
Expand Down Expand Up @@ -3400,6 +3402,7 @@ dependencies = [
"rustc-hash",
"rustc-rayon",
"rustc-rayon-core",
"rustc_index",
"serialize",
"smallvec",
"stable_deref_trait",
Expand Down Expand Up @@ -3463,6 +3466,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 @@ -3507,6 +3518,7 @@ dependencies = [
"log",
"rustc",
"rustc_data_structures",
"rustc_index",
"rustc_target",
"syntax",
"syntax_pos",
Expand Down Expand Up @@ -3552,6 +3564,7 @@ dependencies = [
"rustc",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_target",
"serialize",
"smallvec",
Expand All @@ -3574,6 +3587,7 @@ dependencies = [
"rustc_apfloat",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"serialize",
Expand Down Expand Up @@ -3673,6 +3687,7 @@ dependencies = [
"bitflags",
"log",
"rustc_data_structures",
"rustc_index",
"serialize",
"syntax_pos",
]
Expand Down Expand Up @@ -3721,6 +3736,7 @@ dependencies = [
"rustc",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_target",
"smallvec",
"syntax",
Expand Down Expand Up @@ -4237,6 +4253,7 @@ dependencies = [
"log",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_lexer",
"rustc_target",
"scoped-tls",
Expand Down Expand Up @@ -4266,6 +4283,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading