diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-06-08 22:15:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-08 22:15:13 +0200 |
| commit | 845b86905012db4e1946238cdbfc0ee02a5ca122 (patch) | |
| tree | b7b5327b225d08f40881d1e9924096f31fa9c4cd /src/librustc_middle | |
| parent | 033f6899f72464f7477092eb4ce872cf2a097114 (diff) | |
| parent | e75922246152e3d9a353e41a643025fc7ffb0f67 (diff) | |
| download | rust-845b86905012db4e1946238cdbfc0ee02a5ca122.tar.gz rust-845b86905012db4e1946238cdbfc0ee02a5ca122.zip | |
Rollup merge of #73090 - marmeladema:resolver-outputs-local-def-id, r=petrochenkov
Use `LocalDefId` directly in `Resolver::export_map` This is to avoid the final conversion from `NodeId` to `HirId` during call to `(clone|into)_outputs` This brings down the post-lowering uses of `NodeId` down to 2 calls to convert the `trait_map`. cc #50928 r? @petrochenkov
Diffstat (limited to 'src/librustc_middle')
| -rw-r--r-- | src/librustc_middle/hir/exports.rs | 5 | ||||
| -rw-r--r-- | src/librustc_middle/query/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc_middle/ty/context.rs | 4 | ||||
| -rw-r--r-- | src/librustc_middle/ty/mod.rs | 2 |
4 files changed, 8 insertions, 7 deletions
diff --git a/src/librustc_middle/hir/exports.rs b/src/librustc_middle/hir/exports.rs index 83baf6cc433..af48c9e94ff 100644 --- a/src/librustc_middle/hir/exports.rs +++ b/src/librustc_middle/hir/exports.rs @@ -1,7 +1,8 @@ use crate::ty; +use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::Res; -use rustc_hir::def_id::DefIdMap; +use rustc_hir::def_id::LocalDefId; use rustc_macros::HashStable; use rustc_span::symbol::Ident; use rustc_span::Span; @@ -10,7 +11,7 @@ use std::fmt::Debug; /// This is the replacement export map. It maps a module to all of the exports /// within. -pub type ExportMap<Id> = DefIdMap<Vec<Export<Id>>>; +pub type ExportMap<Id> = FxHashMap<LocalDefId, Vec<Export<Id>>>; #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct Export<Id> { diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index 5a3ab205fc2..16ed9aff8f2 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -865,8 +865,8 @@ rustc_queries! { } Other { - query module_exports(def_id: DefId) -> Option<&'tcx [Export<hir::HirId>]> { - desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id) } + query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export<LocalDefId>]> { + desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) } eval_always } } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 089a1613e7d..d5be3508d2d 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -2,7 +2,7 @@ use crate::arena::Arena; use crate::dep_graph::{self, DepConstructor, DepGraph}; -use crate::hir::exports::Export; +use crate::hir::exports::ExportMap; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintSource}; @@ -919,7 +919,7 @@ pub struct GlobalCtxt<'tcx> { trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, StableVec<TraitCandidate>>>, /// Export map produced by name resolution. - export_map: FxHashMap<DefId, Vec<Export<hir::HirId>>>, + export_map: ExportMap<LocalDefId>, pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>, pub(crate) definitions: &'tcx Definitions, diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 00c00a63b6b..ffbe3a40297 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -124,7 +124,7 @@ pub struct ResolverOutputs { pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate<hir::HirId>>>, pub maybe_unused_trait_imports: FxHashSet<LocalDefId>, pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>, - pub export_map: ExportMap<hir::HirId>, + pub export_map: ExportMap<LocalDefId>, pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>, /// Extern prelude entries. The value is `true` if the entry was introduced /// via `extern crate` item and not `--extern` option or compiler built-in. |
