rustc: Make the export_map
of TyCtxt private
This map, like `trait_map`, is calculated in resolve, but we want to be sure to track it for incremental compliation. Hide it behind a query to get more refactorings later.
This commit is contained in:
parent
32d35e6e9f
commit
942c8dcf19
7 changed files with 33 additions and 10 deletions
|
@ -529,6 +529,7 @@ define_dep_nodes!( <'tcx>
|
||||||
[] ExternCrate(DefId),
|
[] ExternCrate(DefId),
|
||||||
[] LintLevels,
|
[] LintLevels,
|
||||||
[] InScopeTraits(HirId),
|
[] InScopeTraits(HirId),
|
||||||
|
[] ModuleExports(HirId),
|
||||||
);
|
);
|
||||||
|
|
||||||
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use errors::DiagnosticBuilder;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use middle;
|
use middle;
|
||||||
use hir::{TraitCandidate, HirId};
|
use hir::{TraitCandidate, HirId};
|
||||||
use hir::def::{Def, ExportMap};
|
use hir::def::{Def, Export};
|
||||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||||
use hir::map as hir_map;
|
use hir::map as hir_map;
|
||||||
use hir::map::DefPathHash;
|
use hir::map::DefPathHash;
|
||||||
|
@ -822,7 +822,7 @@ pub struct GlobalCtxt<'tcx> {
|
||||||
trait_map: FxHashMap<HirId, Rc<Vec<TraitCandidate>>>,
|
trait_map: FxHashMap<HirId, Rc<Vec<TraitCandidate>>>,
|
||||||
|
|
||||||
/// Export map produced by name resolution.
|
/// Export map produced by name resolution.
|
||||||
pub export_map: ExportMap,
|
export_map: FxHashMap<HirId, Rc<Vec<Export>>>,
|
||||||
|
|
||||||
pub named_region_map: resolve_lifetime::NamedRegionMap,
|
pub named_region_map: resolve_lifetime::NamedRegionMap,
|
||||||
|
|
||||||
|
@ -1081,7 +1081,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
trait_map: resolutions.trait_map.into_iter().map(|(k, v)| {
|
trait_map: resolutions.trait_map.into_iter().map(|(k, v)| {
|
||||||
(hir.node_to_hir_id(k), Rc::new(v))
|
(hir.node_to_hir_id(k), Rc::new(v))
|
||||||
}).collect(),
|
}).collect(),
|
||||||
export_map: resolutions.export_map,
|
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
|
||||||
|
(hir.node_to_hir_id(k), Rc::new(v))
|
||||||
|
}).collect(),
|
||||||
hir,
|
hir,
|
||||||
def_path_hash_to_def_id,
|
def_path_hash_to_def_id,
|
||||||
maps: maps::Maps::new(providers),
|
maps: maps::Maps::new(providers),
|
||||||
|
@ -2006,6 +2008,13 @@ fn in_scope_traits<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: HirId)
|
||||||
tcx.gcx.trait_map.get(&id).cloned()
|
tcx.gcx.trait_map.get(&id).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn module_exports<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: HirId)
|
||||||
|
-> Option<Rc<Vec<Export>>>
|
||||||
|
{
|
||||||
|
tcx.gcx.export_map.get(&id).cloned()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut ty::maps::Providers) {
|
pub fn provide(providers: &mut ty::maps::Providers) {
|
||||||
providers.in_scope_traits = in_scope_traits;
|
providers.in_scope_traits = in_scope_traits;
|
||||||
|
providers.module_exports = module_exports;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use dep_graph::{DepConstructor, DepNode, DepNodeIndex};
|
use dep_graph::{DepConstructor, DepNode, DepNodeIndex};
|
||||||
use errors::{Diagnostic, DiagnosticBuilder};
|
use errors::{Diagnostic, DiagnosticBuilder};
|
||||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||||
use hir::def::Def;
|
use hir::def::{Def, Export};
|
||||||
use hir::{self, TraitCandidate, HirId};
|
use hir::{self, TraitCandidate, HirId};
|
||||||
use lint;
|
use lint;
|
||||||
use middle::const_val;
|
use middle::const_val;
|
||||||
|
@ -555,6 +555,12 @@ impl<'tcx> QueryDescription for queries::in_scope_traits<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> QueryDescription for queries::module_exports<'tcx> {
|
||||||
|
fn describe(_tcx: TyCtxt, _: HirId) -> String {
|
||||||
|
format!("fetching the exported items for a module")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If enabled, send a message to the profile-queries thread
|
// If enabled, send a message to the profile-queries thread
|
||||||
macro_rules! profq_msg {
|
macro_rules! profq_msg {
|
||||||
($tcx:expr, $msg:expr) => {
|
($tcx:expr, $msg:expr) => {
|
||||||
|
@ -1125,6 +1131,7 @@ define_maps! { <'tcx>
|
||||||
[] lint_levels: lint_levels(CrateNum) -> Rc<lint::LintLevelMap>,
|
[] lint_levels: lint_levels(CrateNum) -> Rc<lint::LintLevelMap>,
|
||||||
|
|
||||||
[] in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
|
[] in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
|
||||||
|
[] module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {
|
||||||
|
|
|
@ -548,12 +548,13 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||||
&hir::Visibility)>)
|
&hir::Visibility)>)
|
||||||
-> Entry<'tcx> {
|
-> Entry<'tcx> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
let hir_id = tcx.hir.node_to_hir_id(id);
|
||||||
let def_id = tcx.hir.local_def_id(id);
|
let def_id = tcx.hir.local_def_id(id);
|
||||||
debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id);
|
debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id);
|
||||||
|
|
||||||
let data = ModData {
|
let data = ModData {
|
||||||
reexports: match tcx.export_map.get(&id) {
|
reexports: match tcx.module_exports(hir_id) {
|
||||||
Some(exports) if *vis == hir::Public => {
|
Some(ref exports) if *vis == hir::Public => {
|
||||||
self.lazy_seq_from_slice(exports.as_slice())
|
self.lazy_seq_from_slice(exports.as_slice())
|
||||||
}
|
}
|
||||||
_ => LazySeq::empty(),
|
_ => LazySeq::empty(),
|
||||||
|
|
|
@ -325,8 +325,9 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
// This code is here instead of in visit_item so that the
|
// This code is here instead of in visit_item so that the
|
||||||
// crate module gets processed as well.
|
// crate module gets processed as well.
|
||||||
if self.prev_level.is_some() {
|
if self.prev_level.is_some() {
|
||||||
if let Some(exports) = self.tcx.export_map.get(&id) {
|
let hir_id = self.tcx.hir.node_to_hir_id(id);
|
||||||
for export in exports {
|
if let Some(exports) = self.tcx.module_exports(hir_id) {
|
||||||
|
for export in exports.iter() {
|
||||||
if let Some(node_id) = self.tcx.hir.as_local_node_id(export.def.def_id()) {
|
if let Some(node_id) = self.tcx.hir.as_local_node_id(export.def.def_id()) {
|
||||||
self.update(node_id, Some(AccessLevel::Exported));
|
self.update(node_id, Some(AccessLevel::Exported));
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,6 +662,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
fn assemble_extension_candidates_for_traits_in_scope(&mut self,
|
fn assemble_extension_candidates_for_traits_in_scope(&mut self,
|
||||||
expr_id: ast::NodeId)
|
expr_id: ast::NodeId)
|
||||||
-> Result<(), MethodError<'tcx>> {
|
-> Result<(), MethodError<'tcx>> {
|
||||||
|
if expr_id == ast::DUMMY_NODE_ID {
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
let mut duplicates = FxHashSet();
|
let mut duplicates = FxHashSet();
|
||||||
let expr_hir_id = self.tcx.hir.node_to_hir_id(expr_id);
|
let expr_hir_id = self.tcx.hir.node_to_hir_id(expr_id);
|
||||||
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
||||||
|
|
|
@ -199,8 +199,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
self.visit_item(item, None, &mut om);
|
self.visit_item(item, None, &mut om);
|
||||||
}
|
}
|
||||||
self.inside_public_path = orig_inside_public_path;
|
self.inside_public_path = orig_inside_public_path;
|
||||||
if let Some(exports) = self.cx.tcx.export_map.get(&id) {
|
let hir_id = self.cx.tcx.hir.node_to_hir_id(id);
|
||||||
for export in exports {
|
if let Some(exports) = self.cx.tcx.module_exports(hir_id) {
|
||||||
|
for export in exports.iter() {
|
||||||
if let Def::Macro(def_id, ..) = export.def {
|
if let Def::Macro(def_id, ..) = export.def {
|
||||||
if def_id.krate == LOCAL_CRATE || self.reexported_macros.contains(&def_id) {
|
if def_id.krate == LOCAL_CRATE || self.reexported_macros.contains(&def_id) {
|
||||||
continue // These are `krate.exported_macros`, handled in `self.visit()`.
|
continue // These are `krate.exported_macros`, handled in `self.visit()`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue