diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index e7dd7ea1217dc..27561bddd295b 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -60,7 +60,7 @@ //! user of the `DepNode` API of having to know how to compute the expected //! fingerprint for a given set of node parameters. -use hir::def_id::{CrateNum, DefId}; +use hir::def_id::{CrateNum, DefId, DefIndex}; use hir::map::DefPathHash; use hir::{HirId, ItemLocalId}; @@ -528,8 +528,8 @@ define_dep_nodes!( <'tcx> [] ExternCrate(DefId), [] LintLevels, [] Specializes { impl1: DefId, impl2: DefId }, - [] InScopeTraits(HirId), - [] ModuleExports(HirId), + [] InScopeTraits(DefIndex), + [] ModuleExports(DefId), [] IsSanitizerRuntime(CrateNum), [] IsProfilerRuntime(CrateNum), [] GetPanicStrategy(CrateNum), @@ -551,15 +551,15 @@ define_dep_nodes!( <'tcx> [] NativeLibraryKind(DefId), [] LinkArgs, - [] NamedRegion(HirId), - [] IsLateBound(HirId), - [] ObjectLifetimeDefaults(HirId), + [] NamedRegion(DefIndex), + [] IsLateBound(DefIndex), + [] ObjectLifetimeDefaults(DefIndex), [] Visibility(DefId), [] DepKind(CrateNum), [] CrateName(CrateNum), [] ItemChildren(DefId), - [] ExternModStmtCnum(HirId), + [] ExternModStmtCnum(DefId), [] GetLangItems, [] DefinedLangItems(CrateNum), [] MissingLangItems(CrateNum), @@ -570,8 +570,8 @@ define_dep_nodes!( <'tcx> [] UsedCrateSource(CrateNum), [] PostorderCnums, - [] Freevars(HirId), - [] MaybeUnusedTraitImport(HirId), + [] Freevars(DefId), + [] MaybeUnusedTraitImport(DefId), [] MaybeUnusedExternCrates, [] StabilityIndex, [] AllCrateNums, diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index c797f78fc7e3e..4e0c6479abf14 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -9,7 +9,7 @@ // except according to those terms. use hir::def_id::DefId; -use util::nodemap::NodeMap; +use util::nodemap::{NodeMap, DefIdMap}; use syntax::ast; use syntax::ext::base::MacroKind; use syntax_pos::Span; @@ -115,7 +115,7 @@ pub type DefMap = NodeMap; /// This is the replacement export map. It maps a module to all of the exports /// within. -pub type ExportMap = NodeMap>; +pub type ExportMap = DefIdMap>; #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)] pub struct Export { diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 9c841022fcb82..81cf20cfc77f0 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -199,20 +199,19 @@ impl<'a, 'gcx, 'tcx> HashStable> for ast::N fn hash_stable(&self, hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>, hasher: &mut StableHasher) { + let hir_id = hcx.tcx.hir.node_to_hir_id(*self); match hcx.node_id_hashing_mode { NodeIdHashingMode::Ignore => { // Most NodeIds in the HIR can be ignored, but if there is a // corresponding entry in the `trait_map` we need to hash that. // Make sure we don't ignore too much by checking that there is // no entry in a debug_assert!(). - let hir_id = hcx.tcx.hir.node_to_hir_id(*self); debug_assert!(hcx.tcx.in_scope_traits(hir_id).is_none()); } NodeIdHashingMode::HashDefPath => { - hcx.tcx.hir.definitions().node_to_hir_id(*self).hash_stable(hcx, hasher); + hir_id.hash_stable(hcx, hasher); } NodeIdHashingMode::HashTraitsInScope => { - let hir_id = hcx.tcx.hir.node_to_hir_id(*self); if let Some(traits) = hcx.tcx.in_scope_traits(hir_id) { // The ordering of the candidates is not fixed. So we hash // the def-ids and then sort them and hash the collection. diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 1cf96a4c56db5..5ca235b2ad3ec 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -612,8 +612,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // compiler-generated `extern crate` items have a dummy span. if item.span == DUMMY_SP { return } - let hir_id = self.tcx.hir.node_to_hir_id(item.id); - let cnum = match self.tcx.extern_mod_stmt_cnum(hir_id) { + let def_id = self.tcx.hir.local_def_id(item.id); + let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) { Some(cnum) => cnum, None => return, }; diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2a0dc455f470f..d8e2ec18d6517 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -14,9 +14,9 @@ use dep_graph::DepGraph; use errors::DiagnosticBuilder; use session::Session; use middle; -use hir::{TraitCandidate, HirId}; +use hir::{TraitCandidate, HirId, ItemLocalId}; use hir::def::{Def, Export}; -use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE}; use hir::map as hir_map; use hir::map::DefPathHash; use lint::{self, Lint}; @@ -817,10 +817,10 @@ pub struct GlobalCtxt<'tcx> { /// Map indicating what traits are in scope for places where this /// is relevant; generated by resolve. - trait_map: FxHashMap>>, + trait_map: FxHashMap>>>>, /// Export map produced by name resolution. - export_map: FxHashMap>>, + export_map: FxHashMap>>, named_region_map: NamedRegionMap, @@ -837,11 +837,11 @@ pub struct GlobalCtxt<'tcx> { // Records the free variables refrenced by every closure // expression. Do not track deps for this, just recompute it from // scratch every time. - freevars: FxHashMap>>, + freevars: FxHashMap>>, - maybe_unused_trait_imports: FxHashSet, + maybe_unused_trait_imports: FxHashSet, - maybe_unused_extern_crates: Vec<(HirId, Span)>, + maybe_unused_extern_crates: Vec<(DefId, Span)>, // Internal cache for metadata decoding. No need to track deps on this. pub rcache: RefCell>>, @@ -1032,6 +1032,35 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { None }; + let mut trait_map = FxHashMap(); + for (k, v) in resolutions.trait_map { + let hir_id = hir.node_to_hir_id(k); + let map = trait_map.entry(hir_id.owner) + .or_insert_with(|| Rc::new(FxHashMap())); + Rc::get_mut(map).unwrap().insert(hir_id.local_id, Rc::new(v)); + } + let mut defs = FxHashMap(); + for (k, v) in named_region_map.defs { + let hir_id = hir.node_to_hir_id(k); + let map = defs.entry(hir_id.owner) + .or_insert_with(|| Rc::new(FxHashMap())); + Rc::get_mut(map).unwrap().insert(hir_id.local_id, v); + } + let mut late_bound = FxHashMap(); + for k in named_region_map.late_bound { + let hir_id = hir.node_to_hir_id(k); + let map = late_bound.entry(hir_id.owner) + .or_insert_with(|| Rc::new(FxHashSet())); + Rc::get_mut(map).unwrap().insert(hir_id.local_id); + } + let mut object_lifetime_defaults = FxHashMap(); + for (k, v) in named_region_map.object_lifetime_defaults { + let hir_id = hir.node_to_hir_id(k); + let map = object_lifetime_defaults.entry(hir_id.owner) + .or_insert_with(|| Rc::new(FxHashMap())); + Rc::get_mut(map).unwrap().insert(hir_id.local_id, Rc::new(v)); + } + tls::enter_global(GlobalCtxt { sess: s, trans_trait_caches: traits::trans::TransTraitCaches::new(dep_graph.clone()), @@ -1040,40 +1069,26 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { dep_graph: dep_graph.clone(), types: common_types, named_region_map: NamedRegionMap { - defs: - named_region_map.defs - .into_iter() - .map(|(k, v)| (hir.node_to_hir_id(k), v)) - .collect(), - late_bound: - named_region_map.late_bound - .into_iter() - .map(|k| hir.node_to_hir_id(k)) - .collect(), - object_lifetime_defaults: - named_region_map.object_lifetime_defaults - .into_iter() - .map(|(k, v)| (hir.node_to_hir_id(k), Rc::new(v))) - .collect(), + defs, + late_bound, + object_lifetime_defaults, }, - trait_map: resolutions.trait_map.into_iter().map(|(k, v)| { - (hir.node_to_hir_id(k), Rc::new(v)) - }).collect(), + trait_map, export_map: resolutions.export_map.into_iter().map(|(k, v)| { - (hir.node_to_hir_id(k), Rc::new(v)) + (k, Rc::new(v)) }).collect(), freevars: resolutions.freevars.into_iter().map(|(k, v)| { - (hir.node_to_hir_id(k), Rc::new(v)) + (hir.local_def_id(k), Rc::new(v)) }).collect(), maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports .into_iter() - .map(|id| hir.node_to_hir_id(id)) + .map(|id| hir.local_def_id(id)) .collect(), maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates .into_iter() - .map(|(id, sp)| (hir.node_to_hir_id(id), sp)) + .map(|(id, sp)| (hir.local_def_id(id), sp)) .collect(), hir, def_path_hash_to_def_id, @@ -1967,6 +1982,29 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let (level, src) = self.lint_level_at_node(lint, id); lint::struct_lint_level(self.sess, lint, level, src, None, msg) } + + pub fn in_scope_traits(self, id: HirId) -> Option>> { + self.in_scope_traits_map(id.owner) + .and_then(|map| map.get(&id.local_id).cloned()) + } + + pub fn named_region(self, id: HirId) -> Option { + self.named_region_map(id.owner) + .and_then(|map| map.get(&id.local_id).cloned()) + } + + pub fn is_late_bound(self, id: HirId) -> bool { + self.is_late_bound_map(id.owner) + .map(|set| set.contains(&id.local_id)) + .unwrap_or(false) + } + + pub fn object_lifetime_defaults(self, id: HirId) + -> Option>> + { + self.object_lifetime_defaults_map(id.owner) + .and_then(|map| map.get(&id.local_id).cloned()) + } } pub trait InternAs { @@ -2014,20 +2052,24 @@ impl InternIteratorElement for Result { } struct NamedRegionMap { - defs: FxHashMap, - late_bound: FxHashSet, - object_lifetime_defaults: FxHashMap>>, + defs: FxHashMap>>, + late_bound: FxHashMap>>, + object_lifetime_defaults: + FxHashMap< + DefIndex, + Rc>>>, + >, } pub fn provide(providers: &mut ty::maps::Providers) { // FIXME(#44234) - almost all of these queries have no sub-queries and // therefore no actual inputs, they're just reading tables calculated in // resolve! Does this work? Unsure! That's what the issue is about - providers.in_scope_traits = |tcx, id| tcx.gcx.trait_map.get(&id).cloned(); + providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id).cloned(); providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).cloned(); - providers.named_region = |tcx, id| tcx.gcx.named_region_map.defs.get(&id).cloned(); - providers.is_late_bound = |tcx, id| tcx.gcx.named_region_map.late_bound.contains(&id); - providers.object_lifetime_defaults = |tcx, id| { + providers.named_region_map = |tcx, id| tcx.gcx.named_region_map.defs.get(&id).cloned(); + providers.is_late_bound_map = |tcx, id| tcx.gcx.named_region_map.late_bound.get(&id).cloned(); + providers.object_lifetime_defaults_map = |tcx, id| { tcx.gcx.named_region_map.object_lifetime_defaults.get(&id).cloned() }; providers.crate_name = |tcx, id| { diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 48b92d101edb3..5e5b222b5c61e 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -12,7 +12,7 @@ use dep_graph::{DepConstructor, DepNode, DepNodeIndex}; use errors::{Diagnostic, DiagnosticBuilder}; use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex}; use hir::def::{Def, Export}; -use hir::{self, TraitCandidate, HirId}; +use hir::{self, TraitCandidate, ItemLocalId}; use hir::svh::Svh; use lint; use middle::const_val; @@ -39,7 +39,7 @@ use util::common::{profq_msg, ProfileQueriesMsg}; use rustc_data_structures::indexed_set::IdxSetBuf; use rustc_back::PanicStrategy; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use std::cell::{RefCell, RefMut, Cell}; use std::fmt::Debug; use std::hash::Hash; @@ -87,7 +87,7 @@ impl Key for CrateNum { } } -impl Key for HirId { +impl Key for DefIndex { fn map_crate(&self) -> CrateNum { LOCAL_CRATE } @@ -556,15 +556,9 @@ impl<'tcx> QueryDescription for queries::specializes<'tcx> { } } -impl<'tcx> QueryDescription for queries::in_scope_traits<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("fetching the traits in scope at a particular ast node") - } -} - -impl<'tcx> QueryDescription for queries::module_exports<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("fetching the exported items for a module") +impl<'tcx> QueryDescription for queries::in_scope_traits_map<'tcx> { + fn describe(_tcx: TyCtxt, _: DefIndex) -> String { + format!("traits in scope at a block") } } @@ -652,21 +646,21 @@ impl<'tcx> QueryDescription for queries::link_args<'tcx> { } } -impl<'tcx> QueryDescription for queries::named_region<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("fetching info about a named region") +impl<'tcx> QueryDescription for queries::named_region_map<'tcx> { + fn describe(_tcx: TyCtxt, _: DefIndex) -> String { + format!("looking up a named region") } } -impl<'tcx> QueryDescription for queries::is_late_bound<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("testing whether a lifetime is late bound") +impl<'tcx> QueryDescription for queries::is_late_bound_map<'tcx> { + fn describe(_tcx: TyCtxt, _: DefIndex) -> String { + format!("testing if a region is late boudn") } } -impl<'tcx> QueryDescription for queries::object_lifetime_defaults<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("fetching a list of ObjectLifetimeDefault for a lifetime") +impl<'tcx> QueryDescription for queries::object_lifetime_defaults_map<'tcx> { + fn describe(_tcx: TyCtxt, _: DefIndex) -> String { + format!("looking up lifetime defaults for a region") } } @@ -682,12 +676,6 @@ impl<'tcx> QueryDescription for queries::crate_name<'tcx> { } } -impl<'tcx> QueryDescription for queries::extern_mod_stmt_cnum<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("looking up the CrateNum for an `extern mod` statement") - } -} - impl<'tcx> QueryDescription for queries::get_lang_items<'tcx> { fn describe(_tcx: TyCtxt, _: CrateNum) -> String { format!("calculating the lang items map") @@ -730,18 +718,6 @@ impl<'tcx> QueryDescription for queries::postorder_cnums<'tcx> { } } -impl<'tcx> QueryDescription for queries::freevars<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("looking up free variables for a node") - } -} - -impl<'tcx> QueryDescription for queries::maybe_unused_trait_import<'tcx> { - fn describe(_tcx: TyCtxt, _: HirId) -> String { - format!("testing if a trait import is unused") - } -} - impl<'tcx> QueryDescription for queries::maybe_unused_extern_crates<'tcx> { fn describe(_tcx: TyCtxt, _: CrateNum) -> String { format!("looking up all possibly unused extern crates") @@ -1331,8 +1307,9 @@ define_maps! { <'tcx> [] fn extern_crate: ExternCrate(DefId) -> Rc>, [] fn specializes: specializes_node((DefId, DefId)) -> bool, - [] fn in_scope_traits: InScopeTraits(HirId) -> Option>>, - [] fn module_exports: ModuleExports(HirId) -> Option>>, + [] fn in_scope_traits_map: InScopeTraits(DefIndex) + -> Option>>>>, + [] fn module_exports: ModuleExports(DefId) -> Option>>, [] fn lint_levels: lint_levels_node(CrateNum) -> Rc, [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness, @@ -1355,16 +1332,18 @@ define_maps! { <'tcx> -> Option, [] fn link_args: link_args_node(CrateNum) -> Rc>, - [] fn named_region: NamedRegion(HirId) -> Option, - [] fn is_late_bound: IsLateBound(HirId) -> bool, - [] fn object_lifetime_defaults: ObjectLifetimeDefaults(HirId) - -> Option>>, + [] fn named_region_map: NamedRegion(DefIndex) -> + Option>>, + [] fn is_late_bound_map: IsLateBound(DefIndex) -> + Option>>, + [] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex) + -> Option>>>>, [] fn visibility: Visibility(DefId) -> ty::Visibility, [] fn dep_kind: DepKind(CrateNum) -> DepKind, [] fn crate_name: CrateName(CrateNum) -> Symbol, [] fn item_children: ItemChildren(DefId) -> Rc>, - [] fn extern_mod_stmt_cnum: ExternModStmtCnum(HirId) -> Option, + [] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option, [] fn get_lang_items: get_lang_items_node(CrateNum) -> Rc, [] fn defined_lang_items: DefinedLangItems(CrateNum) -> Rc>, @@ -1376,10 +1355,10 @@ define_maps! { <'tcx> [] fn used_crate_source: UsedCrateSource(CrateNum) -> Rc, [] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Rc>, - [] fn freevars: Freevars(HirId) -> Option>>, - [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(HirId) -> bool, + [] fn freevars: Freevars(DefId) -> Option>>, + [] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool, [] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum) - -> Rc>, + -> Rc>, [] fn stability_index: stability_index_node(CrateNum) -> Rc>, [] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Rc>, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 8b7ae79f151cc..5f5f763430489 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2325,8 +2325,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn with_freevars(self, fid: NodeId, f: F) -> T where F: FnOnce(&[hir::Freevar]) -> T, { - let hir_id = self.hir.node_to_hir_id(fid); - match self.freevars(hir_id) { + let def_id = self.hir.local_def_id(fid); + match self.freevars(def_id) { None => f(&[]), Some(d) => f(&d), } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 75dfaf5ed9be3..f3bf37c11a546 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1066,8 +1066,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary { _ => return, }; - let hir_id = cx.tcx.hir.node_to_hir_id(it.id); - let prfn = match cx.tcx.extern_mod_stmt_cnum(hir_id) { + let def_id = cx.tcx.hir.local_def_id(it.id); + let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) { Some(cnum) => cx.tcx.plugin_registrar_fn(cnum), None => { // Probably means we aren't linking the crate for some reason. diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index c3742fc1d03d8..b1a5029a735a5 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -276,7 +276,7 @@ pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) { Rc::new(link_args::collect(tcx)) }, extern_mod_stmt_cnum: |tcx, id| { - let id = tcx.hir.definitions().find_node_for_hir_id(id); + let id = tcx.hir.as_local_node_id(id).unwrap(); tcx.sess.cstore.extern_mod_stmt_cnum_untracked(id) }, diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 3b07177b1b5c8..641a567b56c10 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -548,12 +548,11 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { &hir::Visibility)>) -> Entry<'tcx> { let tcx = self.tcx; - let hir_id = tcx.hir.node_to_hir_id(id); let def_id = tcx.hir.local_def_id(id); debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id); let data = ModData { - reexports: match tcx.module_exports(hir_id) { + reexports: match tcx.module_exports(def_id) { Some(ref exports) if *vis == hir::Public => { self.lazy_seq_from_slice(exports.as_slice()) } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 139cb61bd9bd7..0d5ad6f47c9ad 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -325,8 +325,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { // This code is here instead of in visit_item so that the // crate module gets processed as well. if self.prev_level.is_some() { - let hir_id = self.tcx.hir.node_to_hir_id(id); - if let Some(exports) = self.tcx.module_exports(hir_id) { + let def_id = self.tcx.hir.local_def_id(id); + if let Some(exports) = self.tcx.module_exports(def_id) { for export in exports.iter() { if let Some(node_id) = self.tcx.hir.as_local_node_id(export.def.def_id()) { self.update(node_id, Some(AccessLevel::Exported)); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index bc1d900a984dd..8f920e792b33c 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1443,7 +1443,7 @@ impl<'a> Resolver<'a> { def_map: NodeMap(), freevars: NodeMap(), freevars_seen: NodeMap(), - export_map: NodeMap(), + export_map: FxHashMap(), trait_map: NodeMap(), module_map, block_map: NodeMap(), diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 7524b7e8c6c21..18f8370c1b3f5 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -892,8 +892,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { if reexports.len() > 0 { if let Some(def_id) = module.def_id() { - let node_id = self.definitions.as_local_node_id(def_id).unwrap(); - self.export_map.insert(node_id, reexports); + self.export_map.insert(def_id, reexports); } } } diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 93f15775b1560..0c35b5e6834de 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -26,8 +26,8 @@ struct CheckVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> CheckVisitor<'a, 'tcx> { fn check_import(&self, id: ast::NodeId, span: Span) { - let hir_id = self.tcx.hir.node_to_hir_id(id); - if !self.tcx.maybe_unused_trait_import(hir_id) { + let def_id = self.tcx.hir.local_def_id(id); + if !self.tcx.maybe_unused_trait_import(def_id) { return; } @@ -75,8 +75,8 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = CheckVisitor { tcx, used_trait_imports }; tcx.hir.krate().visit_all_item_likes(&mut visitor); - for &(hir_id, span) in tcx.maybe_unused_extern_crates(LOCAL_CRATE).iter() { - let cnum = tcx.extern_mod_stmt_cnum(hir_id).unwrap(); + for &(def_id, span) in tcx.maybe_unused_extern_crates(LOCAL_CRATE).iter() { + let cnum = tcx.extern_mod_stmt_cnum(def_id).unwrap(); if tcx.is_compiler_builtins(cnum) { continue } @@ -86,6 +86,8 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { if tcx.has_global_allocator(cnum) { continue } + assert_eq!(def_id.krate, LOCAL_CRATE); + let hir_id = tcx.hir.definitions().def_index_to_hir_id(def_id.index); let id = tcx.hir.definitions().find_node_for_hir_id(hir_id); let lint = lint::builtin::UNUSED_EXTERN_CRATES; let msg = "unused extern crate"; diff --git a/src/librustdoc/build.rs b/src/librustdoc/build.rs index 130c6fd01a8d8..507393bed8a1a 100644 --- a/src/librustdoc/build.rs +++ b/src/librustdoc/build.rs @@ -24,6 +24,7 @@ fn main() { .file("../rt/hoedown/src/html_smartypants.c") .file("../rt/hoedown/src/stack.c") .file("../rt/hoedown/src/version.c") + .warnings(false) .include(src_dir) .compile("libhoedown.a"); } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index d354d726ff703..b74bac7a85b0b 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -199,8 +199,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { self.visit_item(item, None, &mut om); } self.inside_public_path = orig_inside_public_path; - let hir_id = self.cx.tcx.hir.node_to_hir_id(id); - if let Some(exports) = self.cx.tcx.module_exports(hir_id) { + let def_id = self.cx.tcx.hir.local_def_id(id); + if let Some(exports) = self.cx.tcx.module_exports(def_id) { for export in exports.iter() { if let Def::Macro(def_id, ..) = export.def { if def_id.krate == LOCAL_CRATE || self.reexported_macros.contains(&def_id) { @@ -372,9 +372,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { _ if self.inlining && item.vis != hir::Public => {} hir::ItemGlobalAsm(..) => {} hir::ItemExternCrate(ref p) => { - let hir_id = self.cx.tcx.hir.node_to_hir_id(item.id); + let def_id = self.cx.tcx.hir.local_def_id(item.id); om.extern_crates.push(ExternCrate { - cnum: self.cx.tcx.extern_mod_stmt_cnum(hir_id) + cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id) .unwrap_or(LOCAL_CRATE), name, path: p.map(|x|x.to_string()),