Auto merge of #44435 - alexcrichton:in-scope, r=michaelwoerister
rustc: Remove HirId from queries This'll allow us to reconstruct query parameters purely from the `DepNode` they're associated with. Closes #44414
This commit is contained in:
commit
efa3ec67e2
@ -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,
|
||||
|
@ -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<PathResolution>;
|
||||
|
||||
/// This is the replacement export map. It maps a module to all of the exports
|
||||
/// within.
|
||||
pub type ExportMap = NodeMap<Vec<Export>>;
|
||||
pub type ExportMap = DefIdMap<Vec<Export>>;
|
||||
|
||||
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct Export {
|
||||
|
@ -199,20 +199,19 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ast::N
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
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.
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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<HirId, Rc<Vec<TraitCandidate>>>,
|
||||
trait_map: FxHashMap<DefIndex, Rc<FxHashMap<ItemLocalId, Rc<Vec<TraitCandidate>>>>>,
|
||||
|
||||
/// Export map produced by name resolution.
|
||||
export_map: FxHashMap<HirId, Rc<Vec<Export>>>,
|
||||
export_map: FxHashMap<DefId, Rc<Vec<Export>>>,
|
||||
|
||||
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<HirId, Rc<Vec<hir::Freevar>>>,
|
||||
freevars: FxHashMap<DefId, Rc<Vec<hir::Freevar>>>,
|
||||
|
||||
maybe_unused_trait_imports: FxHashSet<HirId>,
|
||||
maybe_unused_trait_imports: FxHashSet<DefId>,
|
||||
|
||||
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<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
|
||||
@ -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<Rc<Vec<TraitCandidate>>> {
|
||||
self.in_scope_traits_map(id.owner)
|
||||
.and_then(|map| map.get(&id.local_id).cloned())
|
||||
}
|
||||
|
||||
pub fn named_region(self, id: HirId) -> Option<resolve_lifetime::Region> {
|
||||
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<Rc<Vec<ObjectLifetimeDefault>>>
|
||||
{
|
||||
self.object_lifetime_defaults_map(id.owner)
|
||||
.and_then(|map| map.get(&id.local_id).cloned())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InternAs<T: ?Sized, R> {
|
||||
@ -2014,20 +2052,24 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
|
||||
}
|
||||
|
||||
struct NamedRegionMap {
|
||||
defs: FxHashMap<HirId, resolve_lifetime::Region>,
|
||||
late_bound: FxHashSet<HirId>,
|
||||
object_lifetime_defaults: FxHashMap<HirId, Rc<Vec<ObjectLifetimeDefault>>>,
|
||||
defs: FxHashMap<DefIndex, Rc<FxHashMap<ItemLocalId, resolve_lifetime::Region>>>,
|
||||
late_bound: FxHashMap<DefIndex, Rc<FxHashSet<ItemLocalId>>>,
|
||||
object_lifetime_defaults:
|
||||
FxHashMap<
|
||||
DefIndex,
|
||||
Rc<FxHashMap<ItemLocalId, Rc<Vec<ObjectLifetimeDefault>>>>,
|
||||
>,
|
||||
}
|
||||
|
||||
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| {
|
||||
|
@ -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<Option<ExternCrate>>,
|
||||
|
||||
[] fn specializes: specializes_node((DefId, DefId)) -> bool,
|
||||
[] fn in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
|
||||
[] fn module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
|
||||
[] fn in_scope_traits_map: InScopeTraits(DefIndex)
|
||||
-> Option<Rc<FxHashMap<ItemLocalId, Rc<Vec<TraitCandidate>>>>>,
|
||||
[] fn module_exports: ModuleExports(DefId) -> Option<Rc<Vec<Export>>>,
|
||||
[] fn lint_levels: lint_levels_node(CrateNum) -> Rc<lint::LintLevelMap>,
|
||||
|
||||
[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
|
||||
@ -1355,16 +1332,18 @@ define_maps! { <'tcx>
|
||||
-> Option<NativeLibraryKind>,
|
||||
[] fn link_args: link_args_node(CrateNum) -> Rc<Vec<String>>,
|
||||
|
||||
[] fn named_region: NamedRegion(HirId) -> Option<Region>,
|
||||
[] fn is_late_bound: IsLateBound(HirId) -> bool,
|
||||
[] fn object_lifetime_defaults: ObjectLifetimeDefaults(HirId)
|
||||
-> Option<Rc<Vec<ObjectLifetimeDefault>>>,
|
||||
[] fn named_region_map: NamedRegion(DefIndex) ->
|
||||
Option<Rc<FxHashMap<ItemLocalId, Region>>>,
|
||||
[] fn is_late_bound_map: IsLateBound(DefIndex) ->
|
||||
Option<Rc<FxHashSet<ItemLocalId>>>,
|
||||
[] fn object_lifetime_defaults_map: ObjectLifetimeDefaults(DefIndex)
|
||||
-> Option<Rc<FxHashMap<ItemLocalId, Rc<Vec<ObjectLifetimeDefault>>>>>,
|
||||
|
||||
[] fn visibility: Visibility(DefId) -> ty::Visibility,
|
||||
[] fn dep_kind: DepKind(CrateNum) -> DepKind,
|
||||
[] fn crate_name: CrateName(CrateNum) -> Symbol,
|
||||
[] fn item_children: ItemChildren(DefId) -> Rc<Vec<Export>>,
|
||||
[] fn extern_mod_stmt_cnum: ExternModStmtCnum(HirId) -> Option<CrateNum>,
|
||||
[] fn extern_mod_stmt_cnum: ExternModStmtCnum(DefId) -> Option<CrateNum>,
|
||||
|
||||
[] fn get_lang_items: get_lang_items_node(CrateNum) -> Rc<LanguageItems>,
|
||||
[] fn defined_lang_items: DefinedLangItems(CrateNum) -> Rc<Vec<(DefIndex, usize)>>,
|
||||
@ -1376,10 +1355,10 @@ define_maps! { <'tcx>
|
||||
[] fn used_crate_source: UsedCrateSource(CrateNum) -> Rc<CrateSource>,
|
||||
[] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Rc<Vec<CrateNum>>,
|
||||
|
||||
[] fn freevars: Freevars(HirId) -> Option<Rc<Vec<hir::Freevar>>>,
|
||||
[] fn maybe_unused_trait_import: MaybeUnusedTraitImport(HirId) -> bool,
|
||||
[] fn freevars: Freevars(DefId) -> Option<Rc<Vec<hir::Freevar>>>,
|
||||
[] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
|
||||
[] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
|
||||
-> Rc<Vec<(HirId, Span)>>,
|
||||
-> Rc<Vec<(DefId, Span)>>,
|
||||
|
||||
[] fn stability_index: stability_index_node(CrateNum) -> Rc<stability::Index<'tcx>>,
|
||||
[] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Rc<Vec<CrateNum>>,
|
||||
|
@ -2325,8 +2325,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn with_freevars<T, F>(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),
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
},
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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(),
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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()),
|
||||
|
Loading…
Reference in New Issue
Block a user