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
16 changed files with 142 additions and 121 deletions
|
@ -60,7 +60,7 @@
|
||||||
//! user of the `DepNode` API of having to know how to compute the expected
|
//! user of the `DepNode` API of having to know how to compute the expected
|
||||||
//! fingerprint for a given set of node parameters.
|
//! 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::map::DefPathHash;
|
||||||
use hir::{HirId, ItemLocalId};
|
use hir::{HirId, ItemLocalId};
|
||||||
|
|
||||||
|
@ -528,8 +528,8 @@ define_dep_nodes!( <'tcx>
|
||||||
[] ExternCrate(DefId),
|
[] ExternCrate(DefId),
|
||||||
[] LintLevels,
|
[] LintLevels,
|
||||||
[] Specializes { impl1: DefId, impl2: DefId },
|
[] Specializes { impl1: DefId, impl2: DefId },
|
||||||
[] InScopeTraits(HirId),
|
[] InScopeTraits(DefIndex),
|
||||||
[] ModuleExports(HirId),
|
[] ModuleExports(DefId),
|
||||||
[] IsSanitizerRuntime(CrateNum),
|
[] IsSanitizerRuntime(CrateNum),
|
||||||
[] IsProfilerRuntime(CrateNum),
|
[] IsProfilerRuntime(CrateNum),
|
||||||
[] GetPanicStrategy(CrateNum),
|
[] GetPanicStrategy(CrateNum),
|
||||||
|
@ -551,15 +551,15 @@ define_dep_nodes!( <'tcx>
|
||||||
[] NativeLibraryKind(DefId),
|
[] NativeLibraryKind(DefId),
|
||||||
[] LinkArgs,
|
[] LinkArgs,
|
||||||
|
|
||||||
[] NamedRegion(HirId),
|
[] NamedRegion(DefIndex),
|
||||||
[] IsLateBound(HirId),
|
[] IsLateBound(DefIndex),
|
||||||
[] ObjectLifetimeDefaults(HirId),
|
[] ObjectLifetimeDefaults(DefIndex),
|
||||||
|
|
||||||
[] Visibility(DefId),
|
[] Visibility(DefId),
|
||||||
[] DepKind(CrateNum),
|
[] DepKind(CrateNum),
|
||||||
[] CrateName(CrateNum),
|
[] CrateName(CrateNum),
|
||||||
[] ItemChildren(DefId),
|
[] ItemChildren(DefId),
|
||||||
[] ExternModStmtCnum(HirId),
|
[] ExternModStmtCnum(DefId),
|
||||||
[] GetLangItems,
|
[] GetLangItems,
|
||||||
[] DefinedLangItems(CrateNum),
|
[] DefinedLangItems(CrateNum),
|
||||||
[] MissingLangItems(CrateNum),
|
[] MissingLangItems(CrateNum),
|
||||||
|
@ -570,8 +570,8 @@ define_dep_nodes!( <'tcx>
|
||||||
[] UsedCrateSource(CrateNum),
|
[] UsedCrateSource(CrateNum),
|
||||||
[] PostorderCnums,
|
[] PostorderCnums,
|
||||||
|
|
||||||
[] Freevars(HirId),
|
[] Freevars(DefId),
|
||||||
[] MaybeUnusedTraitImport(HirId),
|
[] MaybeUnusedTraitImport(DefId),
|
||||||
[] MaybeUnusedExternCrates,
|
[] MaybeUnusedExternCrates,
|
||||||
[] StabilityIndex,
|
[] StabilityIndex,
|
||||||
[] AllCrateNums,
|
[] AllCrateNums,
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use hir::def_id::DefId;
|
use hir::def_id::DefId;
|
||||||
use util::nodemap::NodeMap;
|
use util::nodemap::{NodeMap, DefIdMap};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ext::base::MacroKind;
|
use syntax::ext::base::MacroKind;
|
||||||
use syntax_pos::Span;
|
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
|
/// This is the replacement export map. It maps a module to all of the exports
|
||||||
/// within.
|
/// within.
|
||||||
pub type ExportMap = NodeMap<Vec<Export>>;
|
pub type ExportMap = DefIdMap<Vec<Export>>;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Export {
|
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,
|
fn hash_stable<W: StableHasherResult>(&self,
|
||||||
hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
|
hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
|
||||||
hasher: &mut StableHasher<W>) {
|
hasher: &mut StableHasher<W>) {
|
||||||
|
let hir_id = hcx.tcx.hir.node_to_hir_id(*self);
|
||||||
match hcx.node_id_hashing_mode {
|
match hcx.node_id_hashing_mode {
|
||||||
NodeIdHashingMode::Ignore => {
|
NodeIdHashingMode::Ignore => {
|
||||||
// Most NodeIds in the HIR can be ignored, but if there is a
|
// Most NodeIds in the HIR can be ignored, but if there is a
|
||||||
// corresponding entry in the `trait_map` we need to hash that.
|
// corresponding entry in the `trait_map` we need to hash that.
|
||||||
// Make sure we don't ignore too much by checking that there is
|
// Make sure we don't ignore too much by checking that there is
|
||||||
// no entry in a debug_assert!().
|
// 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());
|
debug_assert!(hcx.tcx.in_scope_traits(hir_id).is_none());
|
||||||
}
|
}
|
||||||
NodeIdHashingMode::HashDefPath => {
|
NodeIdHashingMode::HashDefPath => {
|
||||||
hcx.tcx.hir.definitions().node_to_hir_id(*self).hash_stable(hcx, hasher);
|
hir_id.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
NodeIdHashingMode::HashTraitsInScope => {
|
NodeIdHashingMode::HashTraitsInScope => {
|
||||||
let hir_id = hcx.tcx.hir.node_to_hir_id(*self);
|
|
||||||
if let Some(traits) = hcx.tcx.in_scope_traits(hir_id) {
|
if let Some(traits) = hcx.tcx.in_scope_traits(hir_id) {
|
||||||
// The ordering of the candidates is not fixed. So we hash
|
// The ordering of the candidates is not fixed. So we hash
|
||||||
// the def-ids and then sort them and hash the collection.
|
// 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.
|
// compiler-generated `extern crate` items have a dummy span.
|
||||||
if item.span == DUMMY_SP { return }
|
if item.span == DUMMY_SP { return }
|
||||||
|
|
||||||
let hir_id = self.tcx.hir.node_to_hir_id(item.id);
|
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
let cnum = match self.tcx.extern_mod_stmt_cnum(hir_id) {
|
let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) {
|
||||||
Some(cnum) => cnum,
|
Some(cnum) => cnum,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,9 +14,9 @@ use dep_graph::DepGraph;
|
||||||
use errors::DiagnosticBuilder;
|
use errors::DiagnosticBuilder;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use middle;
|
use middle;
|
||||||
use hir::{TraitCandidate, HirId};
|
use hir::{TraitCandidate, HirId, ItemLocalId};
|
||||||
use hir::def::{Def, Export};
|
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 as hir_map;
|
||||||
use hir::map::DefPathHash;
|
use hir::map::DefPathHash;
|
||||||
use lint::{self, Lint};
|
use lint::{self, Lint};
|
||||||
|
@ -817,10 +817,10 @@ pub struct GlobalCtxt<'tcx> {
|
||||||
|
|
||||||
/// Map indicating what traits are in scope for places where this
|
/// Map indicating what traits are in scope for places where this
|
||||||
/// is relevant; generated by resolve.
|
/// 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 produced by name resolution.
|
||||||
export_map: FxHashMap<HirId, Rc<Vec<Export>>>,
|
export_map: FxHashMap<DefId, Rc<Vec<Export>>>,
|
||||||
|
|
||||||
named_region_map: NamedRegionMap,
|
named_region_map: NamedRegionMap,
|
||||||
|
|
||||||
|
@ -837,11 +837,11 @@ pub struct GlobalCtxt<'tcx> {
|
||||||
// Records the free variables refrenced by every closure
|
// Records the free variables refrenced by every closure
|
||||||
// expression. Do not track deps for this, just recompute it from
|
// expression. Do not track deps for this, just recompute it from
|
||||||
// scratch every time.
|
// 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.
|
// Internal cache for metadata decoding. No need to track deps on this.
|
||||||
pub rcache: RefCell<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
|
pub rcache: RefCell<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
|
||||||
|
@ -1032,6 +1032,35 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
None
|
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 {
|
tls::enter_global(GlobalCtxt {
|
||||||
sess: s,
|
sess: s,
|
||||||
trans_trait_caches: traits::trans::TransTraitCaches::new(dep_graph.clone()),
|
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(),
|
dep_graph: dep_graph.clone(),
|
||||||
types: common_types,
|
types: common_types,
|
||||||
named_region_map: NamedRegionMap {
|
named_region_map: NamedRegionMap {
|
||||||
defs:
|
defs,
|
||||||
named_region_map.defs
|
late_bound,
|
||||||
.into_iter()
|
object_lifetime_defaults,
|
||||||
.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(),
|
|
||||||
},
|
},
|
||||||
trait_map: resolutions.trait_map.into_iter().map(|(k, v)| {
|
trait_map,
|
||||||
(hir.node_to_hir_id(k), Rc::new(v))
|
|
||||||
}).collect(),
|
|
||||||
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
|
export_map: resolutions.export_map.into_iter().map(|(k, v)| {
|
||||||
(hir.node_to_hir_id(k), Rc::new(v))
|
(k, Rc::new(v))
|
||||||
}).collect(),
|
}).collect(),
|
||||||
freevars: resolutions.freevars.into_iter().map(|(k, v)| {
|
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(),
|
}).collect(),
|
||||||
maybe_unused_trait_imports:
|
maybe_unused_trait_imports:
|
||||||
resolutions.maybe_unused_trait_imports
|
resolutions.maybe_unused_trait_imports
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|id| hir.node_to_hir_id(id))
|
.map(|id| hir.local_def_id(id))
|
||||||
.collect(),
|
.collect(),
|
||||||
maybe_unused_extern_crates:
|
maybe_unused_extern_crates:
|
||||||
resolutions.maybe_unused_extern_crates
|
resolutions.maybe_unused_extern_crates
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(id, sp)| (hir.node_to_hir_id(id), sp))
|
.map(|(id, sp)| (hir.local_def_id(id), sp))
|
||||||
.collect(),
|
.collect(),
|
||||||
hir,
|
hir,
|
||||||
def_path_hash_to_def_id,
|
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);
|
let (level, src) = self.lint_level_at_node(lint, id);
|
||||||
lint::struct_lint_level(self.sess, lint, level, src, None, msg)
|
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> {
|
pub trait InternAs<T: ?Sized, R> {
|
||||||
|
@ -2014,20 +2052,24 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NamedRegionMap {
|
struct NamedRegionMap {
|
||||||
defs: FxHashMap<HirId, resolve_lifetime::Region>,
|
defs: FxHashMap<DefIndex, Rc<FxHashMap<ItemLocalId, resolve_lifetime::Region>>>,
|
||||||
late_bound: FxHashSet<HirId>,
|
late_bound: FxHashMap<DefIndex, Rc<FxHashSet<ItemLocalId>>>,
|
||||||
object_lifetime_defaults: FxHashMap<HirId, Rc<Vec<ObjectLifetimeDefault>>>,
|
object_lifetime_defaults:
|
||||||
|
FxHashMap<
|
||||||
|
DefIndex,
|
||||||
|
Rc<FxHashMap<ItemLocalId, Rc<Vec<ObjectLifetimeDefault>>>>,
|
||||||
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut ty::maps::Providers) {
|
pub fn provide(providers: &mut ty::maps::Providers) {
|
||||||
// FIXME(#44234) - almost all of these queries have no sub-queries and
|
// FIXME(#44234) - almost all of these queries have no sub-queries and
|
||||||
// therefore no actual inputs, they're just reading tables calculated in
|
// therefore no actual inputs, they're just reading tables calculated in
|
||||||
// resolve! Does this work? Unsure! That's what the issue is about
|
// 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.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.named_region_map = |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.is_late_bound_map = |tcx, id| tcx.gcx.named_region_map.late_bound.get(&id).cloned();
|
||||||
providers.object_lifetime_defaults = |tcx, id| {
|
providers.object_lifetime_defaults_map = |tcx, id| {
|
||||||
tcx.gcx.named_region_map.object_lifetime_defaults.get(&id).cloned()
|
tcx.gcx.named_region_map.object_lifetime_defaults.get(&id).cloned()
|
||||||
};
|
};
|
||||||
providers.crate_name = |tcx, id| {
|
providers.crate_name = |tcx, id| {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dep_graph::{DepConstructor, DepNode, DepNodeIndex};
|
||||||
use errors::{Diagnostic, DiagnosticBuilder};
|
use errors::{Diagnostic, DiagnosticBuilder};
|
||||||
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex};
|
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex};
|
||||||
use hir::def::{Def, Export};
|
use hir::def::{Def, Export};
|
||||||
use hir::{self, TraitCandidate, HirId};
|
use hir::{self, TraitCandidate, ItemLocalId};
|
||||||
use hir::svh::Svh;
|
use hir::svh::Svh;
|
||||||
use lint;
|
use lint;
|
||||||
use middle::const_val;
|
use middle::const_val;
|
||||||
|
@ -39,7 +39,7 @@ use util::common::{profq_msg, ProfileQueriesMsg};
|
||||||
use rustc_data_structures::indexed_set::IdxSetBuf;
|
use rustc_data_structures::indexed_set::IdxSetBuf;
|
||||||
use rustc_back::PanicStrategy;
|
use rustc_back::PanicStrategy;
|
||||||
use rustc_data_structures::indexed_vec::IndexVec;
|
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::cell::{RefCell, RefMut, Cell};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::hash::Hash;
|
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 {
|
fn map_crate(&self) -> CrateNum {
|
||||||
LOCAL_CRATE
|
LOCAL_CRATE
|
||||||
}
|
}
|
||||||
|
@ -556,15 +556,9 @@ impl<'tcx> QueryDescription for queries::specializes<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> QueryDescription for queries::in_scope_traits<'tcx> {
|
impl<'tcx> QueryDescription for queries::in_scope_traits_map<'tcx> {
|
||||||
fn describe(_tcx: TyCtxt, _: HirId) -> String {
|
fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
|
||||||
format!("fetching the traits in scope at a particular ast node")
|
format!("traits in scope at a block")
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> QueryDescription for queries::module_exports<'tcx> {
|
|
||||||
fn describe(_tcx: TyCtxt, _: HirId) -> String {
|
|
||||||
format!("fetching the exported items for a module")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,21 +646,21 @@ impl<'tcx> QueryDescription for queries::link_args<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> QueryDescription for queries::named_region<'tcx> {
|
impl<'tcx> QueryDescription for queries::named_region_map<'tcx> {
|
||||||
fn describe(_tcx: TyCtxt, _: HirId) -> String {
|
fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
|
||||||
format!("fetching info about a named region")
|
format!("looking up a named region")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> QueryDescription for queries::is_late_bound<'tcx> {
|
impl<'tcx> QueryDescription for queries::is_late_bound_map<'tcx> {
|
||||||
fn describe(_tcx: TyCtxt, _: HirId) -> String {
|
fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
|
||||||
format!("testing whether a lifetime is late bound")
|
format!("testing if a region is late boudn")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> QueryDescription for queries::object_lifetime_defaults<'tcx> {
|
impl<'tcx> QueryDescription for queries::object_lifetime_defaults_map<'tcx> {
|
||||||
fn describe(_tcx: TyCtxt, _: HirId) -> String {
|
fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
|
||||||
format!("fetching a list of ObjectLifetimeDefault for a lifetime")
|
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> {
|
impl<'tcx> QueryDescription for queries::get_lang_items<'tcx> {
|
||||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||||
format!("calculating the lang items map")
|
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> {
|
impl<'tcx> QueryDescription for queries::maybe_unused_extern_crates<'tcx> {
|
||||||
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
|
||||||
format!("looking up all possibly unused extern crates")
|
format!("looking up all possibly unused extern crates")
|
||||||
|
@ -1331,8 +1307,9 @@ define_maps! { <'tcx>
|
||||||
[] fn extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
|
[] fn extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
|
||||||
|
|
||||||
[] fn specializes: specializes_node((DefId, DefId)) -> bool,
|
[] fn specializes: specializes_node((DefId, DefId)) -> bool,
|
||||||
[] fn in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
|
[] fn in_scope_traits_map: InScopeTraits(DefIndex)
|
||||||
[] fn module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
|
-> 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 lint_levels: lint_levels_node(CrateNum) -> Rc<lint::LintLevelMap>,
|
||||||
|
|
||||||
[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
|
[] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
|
||||||
|
@ -1355,16 +1332,18 @@ define_maps! { <'tcx>
|
||||||
-> Option<NativeLibraryKind>,
|
-> Option<NativeLibraryKind>,
|
||||||
[] fn link_args: link_args_node(CrateNum) -> Rc<Vec<String>>,
|
[] fn link_args: link_args_node(CrateNum) -> Rc<Vec<String>>,
|
||||||
|
|
||||||
[] fn named_region: NamedRegion(HirId) -> Option<Region>,
|
[] fn named_region_map: NamedRegion(DefIndex) ->
|
||||||
[] fn is_late_bound: IsLateBound(HirId) -> bool,
|
Option<Rc<FxHashMap<ItemLocalId, Region>>>,
|
||||||
[] fn object_lifetime_defaults: ObjectLifetimeDefaults(HirId)
|
[] fn is_late_bound_map: IsLateBound(DefIndex) ->
|
||||||
-> Option<Rc<Vec<ObjectLifetimeDefault>>>,
|
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 visibility: Visibility(DefId) -> ty::Visibility,
|
||||||
[] fn dep_kind: DepKind(CrateNum) -> DepKind,
|
[] fn dep_kind: DepKind(CrateNum) -> DepKind,
|
||||||
[] fn crate_name: CrateName(CrateNum) -> Symbol,
|
[] fn crate_name: CrateName(CrateNum) -> Symbol,
|
||||||
[] fn item_children: ItemChildren(DefId) -> Rc<Vec<Export>>,
|
[] 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 get_lang_items: get_lang_items_node(CrateNum) -> Rc<LanguageItems>,
|
||||||
[] fn defined_lang_items: DefinedLangItems(CrateNum) -> Rc<Vec<(DefIndex, usize)>>,
|
[] 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 used_crate_source: UsedCrateSource(CrateNum) -> Rc<CrateSource>,
|
||||||
[] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Rc<Vec<CrateNum>>,
|
[] fn postorder_cnums: postorder_cnums_node(CrateNum) -> Rc<Vec<CrateNum>>,
|
||||||
|
|
||||||
[] fn freevars: Freevars(HirId) -> Option<Rc<Vec<hir::Freevar>>>,
|
[] fn freevars: Freevars(DefId) -> Option<Rc<Vec<hir::Freevar>>>,
|
||||||
[] fn maybe_unused_trait_import: MaybeUnusedTraitImport(HirId) -> bool,
|
[] fn maybe_unused_trait_import: MaybeUnusedTraitImport(DefId) -> bool,
|
||||||
[] fn maybe_unused_extern_crates: maybe_unused_extern_crates_node(CrateNum)
|
[] 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 stability_index: stability_index_node(CrateNum) -> Rc<stability::Index<'tcx>>,
|
||||||
[] fn all_crate_nums: all_crate_nums_node(CrateNum) -> Rc<Vec<CrateNum>>,
|
[] 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
|
pub fn with_freevars<T, F>(self, fid: NodeId, f: F) -> T where
|
||||||
F: FnOnce(&[hir::Freevar]) -> T,
|
F: FnOnce(&[hir::Freevar]) -> T,
|
||||||
{
|
{
|
||||||
let hir_id = self.hir.node_to_hir_id(fid);
|
let def_id = self.hir.local_def_id(fid);
|
||||||
match self.freevars(hir_id) {
|
match self.freevars(def_id) {
|
||||||
None => f(&[]),
|
None => f(&[]),
|
||||||
Some(d) => f(&d),
|
Some(d) => f(&d),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1066,8 +1066,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let hir_id = cx.tcx.hir.node_to_hir_id(it.id);
|
let def_id = cx.tcx.hir.local_def_id(it.id);
|
||||||
let prfn = match cx.tcx.extern_mod_stmt_cnum(hir_id) {
|
let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) {
|
||||||
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
|
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
|
||||||
None => {
|
None => {
|
||||||
// Probably means we aren't linking the crate for some reason.
|
// 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))
|
Rc::new(link_args::collect(tcx))
|
||||||
},
|
},
|
||||||
extern_mod_stmt_cnum: |tcx, id| {
|
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)
|
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)>)
|
&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.module_exports(hir_id) {
|
reexports: match tcx.module_exports(def_id) {
|
||||||
Some(ref 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())
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// 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() {
|
||||||
let hir_id = self.tcx.hir.node_to_hir_id(id);
|
let def_id = self.tcx.hir.local_def_id(id);
|
||||||
if let Some(exports) = self.tcx.module_exports(hir_id) {
|
if let Some(exports) = self.tcx.module_exports(def_id) {
|
||||||
for export in exports.iter() {
|
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));
|
||||||
|
|
|
@ -1443,7 +1443,7 @@ impl<'a> Resolver<'a> {
|
||||||
def_map: NodeMap(),
|
def_map: NodeMap(),
|
||||||
freevars: NodeMap(),
|
freevars: NodeMap(),
|
||||||
freevars_seen: NodeMap(),
|
freevars_seen: NodeMap(),
|
||||||
export_map: NodeMap(),
|
export_map: FxHashMap(),
|
||||||
trait_map: NodeMap(),
|
trait_map: NodeMap(),
|
||||||
module_map,
|
module_map,
|
||||||
block_map: NodeMap(),
|
block_map: NodeMap(),
|
||||||
|
|
|
@ -892,8 +892,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||||
|
|
||||||
if reexports.len() > 0 {
|
if reexports.len() > 0 {
|
||||||
if let Some(def_id) = module.def_id() {
|
if let Some(def_id) = module.def_id() {
|
||||||
let node_id = self.definitions.as_local_node_id(def_id).unwrap();
|
self.export_map.insert(def_id, reexports);
|
||||||
self.export_map.insert(node_id, reexports);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ struct CheckVisitor<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> CheckVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> CheckVisitor<'a, 'tcx> {
|
||||||
fn check_import(&self, id: ast::NodeId, span: Span) {
|
fn check_import(&self, id: ast::NodeId, span: Span) {
|
||||||
let hir_id = self.tcx.hir.node_to_hir_id(id);
|
let def_id = self.tcx.hir.local_def_id(id);
|
||||||
if !self.tcx.maybe_unused_trait_import(hir_id) {
|
if !self.tcx.maybe_unused_trait_import(def_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
let mut visitor = CheckVisitor { tcx, used_trait_imports };
|
let mut visitor = CheckVisitor { tcx, used_trait_imports };
|
||||||
tcx.hir.krate().visit_all_item_likes(&mut visitor);
|
tcx.hir.krate().visit_all_item_likes(&mut visitor);
|
||||||
|
|
||||||
for &(hir_id, span) in tcx.maybe_unused_extern_crates(LOCAL_CRATE).iter() {
|
for &(def_id, span) in tcx.maybe_unused_extern_crates(LOCAL_CRATE).iter() {
|
||||||
let cnum = tcx.extern_mod_stmt_cnum(hir_id).unwrap();
|
let cnum = tcx.extern_mod_stmt_cnum(def_id).unwrap();
|
||||||
if tcx.is_compiler_builtins(cnum) {
|
if tcx.is_compiler_builtins(cnum) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,8 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
if tcx.has_global_allocator(cnum) {
|
if tcx.has_global_allocator(cnum) {
|
||||||
continue
|
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 id = tcx.hir.definitions().find_node_for_hir_id(hir_id);
|
||||||
let lint = lint::builtin::UNUSED_EXTERN_CRATES;
|
let lint = lint::builtin::UNUSED_EXTERN_CRATES;
|
||||||
let msg = "unused extern crate";
|
let msg = "unused extern crate";
|
||||||
|
|
|
@ -24,6 +24,7 @@ fn main() {
|
||||||
.file("../rt/hoedown/src/html_smartypants.c")
|
.file("../rt/hoedown/src/html_smartypants.c")
|
||||||
.file("../rt/hoedown/src/stack.c")
|
.file("../rt/hoedown/src/stack.c")
|
||||||
.file("../rt/hoedown/src/version.c")
|
.file("../rt/hoedown/src/version.c")
|
||||||
|
.warnings(false)
|
||||||
.include(src_dir)
|
.include(src_dir)
|
||||||
.compile("libhoedown.a");
|
.compile("libhoedown.a");
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,8 +199,8 @@ 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;
|
||||||
let hir_id = self.cx.tcx.hir.node_to_hir_id(id);
|
let def_id = self.cx.tcx.hir.local_def_id(id);
|
||||||
if let Some(exports) = self.cx.tcx.module_exports(hir_id) {
|
if let Some(exports) = self.cx.tcx.module_exports(def_id) {
|
||||||
for export in exports.iter() {
|
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) {
|
||||||
|
@ -372,9 +372,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
_ if self.inlining && item.vis != hir::Public => {}
|
_ if self.inlining && item.vis != hir::Public => {}
|
||||||
hir::ItemGlobalAsm(..) => {}
|
hir::ItemGlobalAsm(..) => {}
|
||||||
hir::ItemExternCrate(ref p) => {
|
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 {
|
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),
|
.unwrap_or(LOCAL_CRATE),
|
||||||
name,
|
name,
|
||||||
path: p.map(|x|x.to_string()),
|
path: p.map(|x|x.to_string()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue