From 2f64ab66339405ae4d5636a238268e2cd4a309ff Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 25 Dec 2019 00:22:24 +0100 Subject: [PATCH] {HirId,ItemLocal}{Map,Set} -> rustc::hir & nix rustc::nodemap --- src/librustc/arena.rs | 2 +- src/librustc/hir/mod.rs | 3 +++ src/librustc/lib.rs | 1 - src/librustc/ty/context.rs | 4 ++-- src/librustc/ty/query/mod.rs | 3 +-- src/librustc/util/nodemap.rs | 8 -------- src/librustc_lint/builtin.rs | 5 ++--- src/librustc_mir/build/mod.rs | 4 +--- src/librustc_passes/liveness.rs | 5 +---- src/librustc_passes/reachable.rs | 3 +-- src/librustc_privacy/lib.rs | 3 +-- src/librustc_resolve/lifetimes.rs | 3 +-- src/librustc_typeck/check/mod.rs | 3 +-- src/librustc_typeck/variance/terms.rs | 3 +-- 14 files changed, 16 insertions(+), 34 deletions(-) delete mode 100644 src/librustc/util/nodemap.rs diff --git a/src/librustc/arena.rs b/src/librustc/arena.rs index 0ec8863fa69..1c7d36b7312 100644 --- a/src/librustc/arena.rs +++ b/src/librustc/arena.rs @@ -44,7 +44,7 @@ macro_rules! arena_types { [few, decode] mir_keys: rustc::hir::def_id::DefIdSet, [decode] specialization_graph: rustc::traits::specialization_graph::Graph, [] region_scope_tree: rustc::middle::region::ScopeTree, - [] item_local_set: rustc::util::nodemap::ItemLocalSet, + [] item_local_set: rustc::hir::ItemLocalSet, [decode] mir_const_qualif: rustc_index::bit_set::BitSet, [] trait_impls_of: rustc::ty::trait_def::TraitImpls, [] dropck_outlives: diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index ff025f48dc4..ce1b8ca2f88 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -93,6 +93,9 @@ impl fmt::Display for HirId { } } +rustc_data_structures::define_id_collections!(HirIdMap, HirIdSet, HirId); +rustc_data_structures::define_id_collections!(ItemLocalMap, ItemLocalSet, ItemLocalId); + // 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_index::vec::Idx; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 76588dfa5e2..9882b021ff3 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -105,7 +105,6 @@ pub mod util { pub mod bug; pub mod captures; pub mod common; - pub mod nodemap; } // Allows macros to refer to this crate as `::rustc` diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 5bac49ca492..842728e5a9f 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -7,7 +7,8 @@ use crate::hir::def::{DefKind, Export, Res}; use crate::hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex, LOCAL_CRATE}; use crate::hir::map as hir_map; use crate::hir::map::DefPathHash; -use crate::hir::{self, HirId, ItemKind, ItemLocalId, Node, TraitCandidate}; +use crate::hir::{self, HirId, Node, TraitCandidate}; +use crate::hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet}; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::infer::outlives::free_region_map::FreeRegionMap; @@ -46,7 +47,6 @@ use crate::ty::{ExistentialPredicate, InferTy, ParamTy, PolyFnSig, Predicate, Pr use crate::ty::{InferConst, ParamConst}; use crate::ty::{List, TyKind, TyS}; use crate::util::common::ErrorReported; -use crate::util::nodemap::{ItemLocalMap, ItemLocalSet}; use arena::SyncDroplessArena; use errors::DiagnosticBuilder; diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index f8cad3437b4..a29d78318a0 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -1,7 +1,7 @@ use crate::dep_graph::{self, DepNode}; use crate::hir::def::{DefKind, Export}; use crate::hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex}; -use crate::hir::{self, ItemLocalId, TraitCandidate}; +use crate::hir::{self, HirIdSet, ItemLocalId, TraitCandidate}; use crate::infer::canonical::{self, Canonical}; use crate::lint; use crate::middle::codegen_fn_attrs::CodegenFnAttrs; @@ -37,7 +37,6 @@ use crate::ty::subst::SubstsRef; use crate::ty::util::NeedsDrop; use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; use crate::util::common::ErrorReported; -use crate::util::nodemap::HirIdSet; use rustc_data_structures::profiling::ProfileCategory::*; use rustc_data_structures::fingerprint::Fingerprint; diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs deleted file mode 100644 index a7d79b9f341..00000000000 --- a/src/librustc/util/nodemap.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! An efficient hash map for `NodeId`s. - -use crate::hir::{HirId, ItemLocalId}; - -use rustc_data_structures::define_id_collections; - -define_id_collections!(HirIdMap, HirIdSet, HirId); -define_id_collections!(ItemLocalMap, ItemLocalSet, ItemLocalId); diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 90d87e34e48..5e107b2f72d 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -23,15 +23,14 @@ use std::fmt::Write; -use hir::Node; use lint::{EarlyContext, EarlyLintPass, LateLintPass, LintPass}; use lint::{LateContext, LintArray, LintContext}; use rustc::hir::def::{DefKind, Res}; use rustc::hir::def_id::DefId; +use rustc::hir::{HirIdSet, Node}; +use rustc::lint; use rustc::lint::FutureIncompatibleInfo; use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt}; -use rustc::{lint, util}; -use util::nodemap::HirIdSet; use rustc_data_structures::fx::FxHashSet; use rustc_feature::Stability; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index b265ab6b7be..39edcc981a0 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -4,15 +4,13 @@ use crate::hair::cx::Cx; use crate::hair::{BindingMode, LintLevel, PatKind}; use crate::transform::MirSource; use crate::util as mir_util; -use rustc::hir; use rustc::hir::def_id::DefId; -use rustc::hir::{GeneratorKind, Node}; +use rustc::hir::{self, GeneratorKind, HirIdMap, Node}; use rustc::middle::lang_items; use rustc::middle::region; use rustc::mir::*; use rustc::ty::subst::Subst; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::util::nodemap::HirIdMap; use rustc_index::vec::{Idx, IndexVec}; use rustc_span::symbol::kw; use rustc_span::Span; diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 49664be9c77..6a38524720e 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -96,16 +96,13 @@ use self::LiveNodeKind::*; use self::VarKind::*; -use rustc::hir; use rustc::hir::def::*; use rustc::hir::def_id::DefId; use rustc::hir::intravisit::{self, FnKind, NestedVisitorMap, Visitor}; -use rustc::hir::Node; -use rustc::hir::{Expr, HirId}; +use rustc::hir::{self, Expr, HirId, HirIdMap, HirIdSet, Node}; use rustc::lint; use rustc::ty::query::Providers; use rustc::ty::{self, TyCtxt}; -use rustc::util::nodemap::{HirIdMap, HirIdSet}; use errors::Applicability; use rustc_data_structures::fx::FxIndexMap; diff --git a/src/librustc_passes/reachable.rs b/src/librustc_passes/reachable.rs index 1c8733ab44d..4bcba96910b 100644 --- a/src/librustc_passes/reachable.rs +++ b/src/librustc_passes/reachable.rs @@ -5,7 +5,6 @@ // makes all other generics or inline functions that it references // reachable as well. -use rustc::hir; use rustc::hir::def::{DefKind, Res}; use rustc::hir::def_id::LOCAL_CRATE; use rustc::hir::def_id::{CrateNum, DefId}; @@ -13,12 +12,12 @@ use rustc::hir::intravisit; use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::Node; +use rustc::hir::{self, HirIdSet}; use rustc::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc::middle::privacy; use rustc::session::config; use rustc::ty::query::Providers; use rustc::ty::{self, TyCtxt}; -use rustc::util::nodemap::HirIdSet; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi::Abi; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index c4b113d7a93..1b91f48d78f 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -11,14 +11,13 @@ use rustc::hir::def::{DefKind, Res}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::itemlikevisit::DeepVisitor; -use rustc::hir::{self, AssocItemKind, Node, PatKind}; +use rustc::hir::{self, AssocItemKind, HirIdSet, Node, PatKind}; use rustc::lint; use rustc::middle::privacy::{AccessLevel, AccessLevels}; use rustc::ty::fold::TypeVisitor; use rustc::ty::query::Providers; use rustc::ty::subst::InternalSubsts; use rustc::ty::{self, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable}; -use rustc::util::nodemap::HirIdSet; use rustc_data_structures::fx::FxHashSet; use rustc_span::hygiene::Transparency; use rustc_span::symbol::{kw, sym}; diff --git a/src/librustc_resolve/lifetimes.rs b/src/librustc_resolve/lifetimes.rs index a5afd73c28b..5d82c177259 100644 --- a/src/librustc_resolve/lifetimes.rs +++ b/src/librustc_resolve/lifetimes.rs @@ -10,13 +10,12 @@ use rustc::hir::def::{DefKind, Res}; use rustc::hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::map::Map; -use rustc::hir::{self, GenericParamKind, LifetimeParamKind}; +use rustc::hir::{self, GenericParamKind, HirIdMap, HirIdSet, LifetimeParamKind}; use rustc::hir::{GenericArg, GenericParam, LifetimeName, Node, ParamName, QPath}; use rustc::lint; use rustc::middle::resolve_lifetime::*; use rustc::session::Session; use rustc::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; -use rustc::util::nodemap::{HirIdMap, HirIdSet}; use rustc::{bug, span_bug}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_span::symbol::{kw, sym}; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 51574063093..312208626cf 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -95,7 +95,7 @@ use rustc::hir::def::{CtorOf, DefKind, Res}; use rustc::hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LOCAL_CRATE}; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::hir::itemlikevisit::ItemLikeVisitor; -use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath}; +use rustc::hir::{self, ExprKind, GenericArg, HirIdMap, ItemKind, Node, PatKind, QPath}; use rustc::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; use rustc::infer::error_reporting::TypeAnnotationNeeded::E0282; use rustc::infer::opaque_types::OpaqueTypeDecl; @@ -145,7 +145,6 @@ use crate::session::config::EntryFnType; use crate::session::Session; use crate::util::captures::Captures; use crate::util::common::{indenter, ErrorReported}; -use crate::util::nodemap::HirIdMap; use crate::TypeAndSubsts; use self::autoderef::Autoderef; diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index 090c4ed7590..db3e7a2b134 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -9,10 +9,9 @@ // `InferredIndex` is a newtype'd int representing the index of such // a variable. -use crate::util::nodemap::HirIdMap; use arena::TypedArena; -use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; +use rustc::hir::{self, HirIdMap}; use rustc::ty::{self, TyCtxt}; use std::fmt;