Instrument a bunch of tasks that employ the HIR map in one way or
another and were not previously instrumented.
This commit is contained in:
parent
d09fd1a529
commit
35b6e2b0bb
17 changed files with 123 additions and 42 deletions
|
@ -40,8 +40,21 @@ pub enum DepNode {
|
||||||
Hir(DefId),
|
Hir(DefId),
|
||||||
|
|
||||||
// Represents different phases in the compiler.
|
// Represents different phases in the compiler.
|
||||||
|
CrateReader,
|
||||||
|
CollectLanguageItems,
|
||||||
|
CheckStaticRecursion,
|
||||||
|
ResolveLifetimes,
|
||||||
|
RegionResolveCrate,
|
||||||
|
CheckLoops,
|
||||||
|
PluginRegistrar,
|
||||||
|
StabilityIndex,
|
||||||
CollectItem(DefId),
|
CollectItem(DefId),
|
||||||
Coherence,
|
Coherence,
|
||||||
|
EffectCheck,
|
||||||
|
Liveness,
|
||||||
|
Resolve,
|
||||||
|
EntryPoint,
|
||||||
|
CheckEntryFn,
|
||||||
CoherenceCheckImpl(DefId),
|
CoherenceCheckImpl(DefId),
|
||||||
CoherenceOverlapCheck(DefId),
|
CoherenceOverlapCheck(DefId),
|
||||||
CoherenceOverlapCheckSpecial(DefId),
|
CoherenceOverlapCheckSpecial(DefId),
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
//! `unsafe`.
|
//! `unsafe`.
|
||||||
use self::RootUnsafeContext::*;
|
use self::RootUnsafeContext::*;
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
use middle::def::Def;
|
use middle::def::Def;
|
||||||
use middle::ty::{self, Ty};
|
use middle::ty::{self, Ty};
|
||||||
use middle::ty::MethodCall;
|
use middle::ty::MethodCall;
|
||||||
|
@ -182,6 +183,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate(tcx: &ty::ctxt) {
|
pub fn check_crate(tcx: &ty::ctxt) {
|
||||||
|
let _task = tcx.dep_graph.in_task(DepNode::EffectCheck);
|
||||||
|
|
||||||
let mut visitor = EffectCheckVisitor {
|
let mut visitor = EffectCheckVisitor {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
unsafe_context: UnsafeContext::new(SafeContext),
|
unsafe_context: UnsafeContext::new(SafeContext),
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
use front::map as ast_map;
|
use front::map as ast_map;
|
||||||
use middle::def_id::{CRATE_DEF_INDEX};
|
use middle::def_id::{CRATE_DEF_INDEX};
|
||||||
use session::{config, Session};
|
use session::{config, Session};
|
||||||
|
@ -48,6 +49,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EntryContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
|
pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
|
||||||
|
let _task = ast_map.dep_graph.in_task(DepNode::EntryPoint);
|
||||||
|
|
||||||
let any_exe = session.crate_types.borrow().iter().any(|ty| {
|
let any_exe = session.crate_types.borrow().iter().any(|ty| {
|
||||||
*ty == config::CrateTypeExecutable
|
*ty == config::CrateTypeExecutable
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
pub use self::LangItem::*;
|
pub use self::LangItem::*;
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
use front::map as hir_map;
|
use front::map as hir_map;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use middle::cstore::CrateStore;
|
use middle::cstore::CrateStore;
|
||||||
|
@ -234,6 +235,7 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
|
||||||
pub fn collect_language_items(session: &Session,
|
pub fn collect_language_items(session: &Session,
|
||||||
map: &hir_map::Map)
|
map: &hir_map::Map)
|
||||||
-> LanguageItems {
|
-> LanguageItems {
|
||||||
|
let _task = map.dep_graph.in_task(DepNode::CollectLanguageItems);
|
||||||
let krate: &hir::Crate = map.krate();
|
let krate: &hir::Crate = map.krate();
|
||||||
let mut collector = LanguageItemCollector::new(session, map);
|
let mut collector = LanguageItemCollector::new(session, map);
|
||||||
collector.collect(krate);
|
collector.collect(krate);
|
||||||
|
|
|
@ -109,6 +109,7 @@ use self::LoopKind::*;
|
||||||
use self::LiveNodeKind::*;
|
use self::LiveNodeKind::*;
|
||||||
use self::VarKind::*;
|
use self::VarKind::*;
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
use middle::def::*;
|
use middle::def::*;
|
||||||
use middle::pat_util;
|
use middle::pat_util;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
|
@ -192,6 +193,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IrMaps<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate(tcx: &ty::ctxt) {
|
pub fn check_crate(tcx: &ty::ctxt) {
|
||||||
|
let _task = tcx.dep_graph.in_task(DepNode::Liveness);
|
||||||
tcx.map.krate().visit_all_items(&mut IrMaps::new(tcx));
|
tcx.map.krate().visit_all_items(&mut IrMaps::new(tcx));
|
||||||
tcx.sess.abort_if_errors();
|
tcx.sess.abort_if_errors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
//! Most of the documentation on regions can be found in
|
//! Most of the documentation on regions can be found in
|
||||||
//! `middle/infer/region_inference/README.md`
|
//! `middle/infer/region_inference/README.md`
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
use front::map as ast_map;
|
use front::map as ast_map;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
|
use util::nodemap::{FnvHashMap, NodeMap, NodeSet};
|
||||||
|
@ -1224,7 +1225,10 @@ impl<'a, 'v> Visitor<'v> for RegionResolutionVisitor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_crate(sess: &Session, krate: &hir::Crate) -> RegionMaps {
|
pub fn resolve_crate(sess: &Session, map: &ast_map::Map) -> RegionMaps {
|
||||||
|
let _task = map.dep_graph.in_task(DepNode::RegionResolveCrate);
|
||||||
|
let krate = map.krate();
|
||||||
|
|
||||||
let maps = RegionMaps {
|
let maps = RegionMaps {
|
||||||
code_extents: RefCell::new(vec![]),
|
code_extents: RefCell::new(vec![]),
|
||||||
code_extent_interner: RefCell::new(FnvHashMap()),
|
code_extent_interner: RefCell::new(FnvHashMap()),
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
pub use self::DefRegion::*;
|
pub use self::DefRegion::*;
|
||||||
use self::ScopeChain::*;
|
use self::ScopeChain::*;
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
|
use front::map::Map;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use middle::def::{Def, DefMap};
|
use middle::def::{Def, DefMap};
|
||||||
use middle::region;
|
use middle::region;
|
||||||
|
@ -94,9 +96,11 @@ type Scope<'a> = &'a ScopeChain<'a>;
|
||||||
static ROOT_SCOPE: ScopeChain<'static> = RootScope;
|
static ROOT_SCOPE: ScopeChain<'static> = RootScope;
|
||||||
|
|
||||||
pub fn krate(sess: &Session,
|
pub fn krate(sess: &Session,
|
||||||
krate: &hir::Crate,
|
hir_map: &Map,
|
||||||
def_map: &DefMap)
|
def_map: &DefMap)
|
||||||
-> Result<NamedRegionMap, usize> {
|
-> Result<NamedRegionMap, usize> {
|
||||||
|
let _task = hir_map.dep_graph.in_task(DepNode::ResolveLifetimes);
|
||||||
|
let krate = hir_map.krate();
|
||||||
let mut named_region_map = NodeMap();
|
let mut named_region_map = NodeMap();
|
||||||
try!(sess.track_errors(|| {
|
try!(sess.track_errors(|| {
|
||||||
krate.visit_all_items(&mut LifetimeContext {
|
krate.visit_all_items(&mut LifetimeContext {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
pub use self::StabilityLevel::*;
|
pub use self::StabilityLevel::*;
|
||||||
|
|
||||||
use dep_graph::DepNode;
|
use dep_graph::DepNode;
|
||||||
|
use front::map as hir_map;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
use lint;
|
use lint;
|
||||||
use middle::cstore::{CrateStore, LOCAL_CRATE};
|
use middle::cstore::{CrateStore, LOCAL_CRATE};
|
||||||
|
@ -30,7 +31,7 @@ use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods};
|
||||||
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
|
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
|
||||||
|
|
||||||
use rustc_front::hir;
|
use rustc_front::hir;
|
||||||
use rustc_front::hir::{Crate, Item, Generics, StructField, Variant};
|
use rustc_front::hir::{Item, Generics, StructField, Variant};
|
||||||
use rustc_front::intravisit::{self, Visitor};
|
use rustc_front::intravisit::{self, Visitor};
|
||||||
|
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
|
@ -278,7 +279,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> {
|
||||||
|
|
||||||
impl<'tcx> Index<'tcx> {
|
impl<'tcx> Index<'tcx> {
|
||||||
/// Construct the stability index for a crate being compiled.
|
/// Construct the stability index for a crate being compiled.
|
||||||
pub fn build(&mut self, tcx: &ty::ctxt<'tcx>, krate: &Crate, access_levels: &AccessLevels) {
|
pub fn build(&mut self, tcx: &ty::ctxt<'tcx>, access_levels: &AccessLevels) {
|
||||||
|
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
|
||||||
|
let krate = tcx.map.krate();
|
||||||
let mut annotator = Annotator {
|
let mut annotator = Annotator {
|
||||||
tcx: tcx,
|
tcx: tcx,
|
||||||
index: self,
|
index: self,
|
||||||
|
@ -291,7 +294,10 @@ impl<'tcx> Index<'tcx> {
|
||||||
|v| intravisit::walk_crate(v, krate));
|
|v| intravisit::walk_crate(v, krate));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(krate: &Crate) -> Index<'tcx> {
|
pub fn new(hir_map: &hir_map::Map) -> Index<'tcx> {
|
||||||
|
let _task = hir_map.dep_graph.in_task(DepNode::StabilityIndex);
|
||||||
|
let krate = hir_map.krate();
|
||||||
|
|
||||||
let mut is_staged_api = false;
|
let mut is_staged_api = false;
|
||||||
for attr in &krate.attrs {
|
for attr in &krate.attrs {
|
||||||
if attr.name() == "stable" || attr.name() == "unstable" {
|
if attr.name() == "stable" || attr.name() == "unstable" {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
use rustc::dep_graph::DepGraph;
|
||||||
use rustc::front;
|
use rustc::front;
|
||||||
use rustc::front::map as hir_map;
|
use rustc::front::map as hir_map;
|
||||||
use rustc_mir as mir;
|
use rustc_mir as mir;
|
||||||
|
@ -115,9 +116,11 @@ pub fn compile_input(sess: &Session,
|
||||||
let expanded_crate = assign_node_ids(sess, expanded_crate);
|
let expanded_crate = assign_node_ids(sess, expanded_crate);
|
||||||
// Lower ast -> hir.
|
// Lower ast -> hir.
|
||||||
let lcx = LoweringContext::new(sess, Some(&expanded_crate));
|
let lcx = LoweringContext::new(sess, Some(&expanded_crate));
|
||||||
|
let dep_graph = DepGraph::new(sess.opts.build_dep_graph);
|
||||||
let mut hir_forest = time(sess.time_passes(),
|
let mut hir_forest = time(sess.time_passes(),
|
||||||
"lowering ast -> hir",
|
"lowering ast -> hir",
|
||||||
|| hir_map::Forest::new(lower_crate(&lcx, &expanded_crate)));
|
|| hir_map::Forest::new(lower_crate(&lcx, &expanded_crate),
|
||||||
|
dep_graph));
|
||||||
|
|
||||||
// Discard MTWT tables that aren't required past lowering to HIR.
|
// Discard MTWT tables that aren't required past lowering to HIR.
|
||||||
if !sess.opts.debugging_opts.keep_mtwt_tables &&
|
if !sess.opts.debugging_opts.keep_mtwt_tables &&
|
||||||
|
@ -130,17 +133,20 @@ pub fn compile_input(sess: &Session,
|
||||||
|
|
||||||
write_out_deps(sess, &outputs, &id);
|
write_out_deps(sess, &outputs, &id);
|
||||||
|
|
||||||
controller_entry_point!(after_write_deps,
|
{
|
||||||
sess,
|
let _ignore = hir_map.dep_graph.in_ignore();
|
||||||
CompileState::state_after_write_deps(input,
|
controller_entry_point!(after_write_deps,
|
||||||
sess,
|
sess,
|
||||||
outdir,
|
CompileState::state_after_write_deps(input,
|
||||||
&hir_map,
|
sess,
|
||||||
&expanded_crate,
|
outdir,
|
||||||
&hir_map.krate(),
|
&hir_map,
|
||||||
&id[..],
|
&expanded_crate,
|
||||||
&lcx),
|
&hir_map.krate(),
|
||||||
Ok(()));
|
&id[..],
|
||||||
|
&lcx),
|
||||||
|
Ok(()));
|
||||||
|
}
|
||||||
|
|
||||||
time(sess.time_passes(), "attribute checking", || {
|
time(sess.time_passes(), "attribute checking", || {
|
||||||
front::check_attr::check_crate(sess, &expanded_crate);
|
front::check_attr::check_crate(sess, &expanded_crate);
|
||||||
|
@ -166,6 +172,9 @@ pub fn compile_input(sess: &Session,
|
||||||
control.make_glob_map,
|
control.make_glob_map,
|
||||||
|tcx, mir_map, analysis, result| {
|
|tcx, mir_map, analysis, result| {
|
||||||
{
|
{
|
||||||
|
// Eventually, we will want to track plugins.
|
||||||
|
let _ignore = tcx.dep_graph.in_ignore();
|
||||||
|
|
||||||
let state = CompileState::state_after_analysis(input,
|
let state = CompileState::state_after_analysis(input,
|
||||||
&tcx.sess,
|
&tcx.sess,
|
||||||
outdir,
|
outdir,
|
||||||
|
@ -735,11 +744,10 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
let time_passes = sess.time_passes();
|
let time_passes = sess.time_passes();
|
||||||
let krate = hir_map.krate();
|
|
||||||
|
|
||||||
time(time_passes,
|
time(time_passes,
|
||||||
"external crate/lib resolution",
|
"external crate/lib resolution",
|
||||||
|| LocalCrateReader::new(sess, cstore, &hir_map).read_crates(krate));
|
|| LocalCrateReader::new(sess, cstore, &hir_map).read_crates());
|
||||||
|
|
||||||
let lang_items = try!(time(time_passes, "language item collection", || {
|
let lang_items = try!(time(time_passes, "language item collection", || {
|
||||||
sess.track_errors(|| {
|
sess.track_errors(|| {
|
||||||
|
@ -769,7 +777,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
let named_region_map = try!(time(time_passes,
|
let named_region_map = try!(time(time_passes,
|
||||||
"lifetime resolution",
|
"lifetime resolution",
|
||||||
|| middle::resolve_lifetime::krate(sess,
|
|| middle::resolve_lifetime::krate(sess,
|
||||||
krate,
|
&hir_map,
|
||||||
&def_map.borrow())));
|
&def_map.borrow())));
|
||||||
|
|
||||||
time(time_passes,
|
time(time_passes,
|
||||||
|
@ -777,20 +785,22 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
|| middle::entry::find_entry_point(sess, &hir_map));
|
|| middle::entry::find_entry_point(sess, &hir_map));
|
||||||
|
|
||||||
sess.plugin_registrar_fn.set(time(time_passes, "looking for plugin registrar", || {
|
sess.plugin_registrar_fn.set(time(time_passes, "looking for plugin registrar", || {
|
||||||
plugin::build::find_plugin_registrar(sess.diagnostic(), krate)
|
plugin::build::find_plugin_registrar(sess.diagnostic(), &hir_map)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let region_map = time(time_passes,
|
let region_map = time(time_passes,
|
||||||
"region resolution",
|
"region resolution",
|
||||||
|| middle::region::resolve_crate(sess, krate));
|
|| middle::region::resolve_crate(sess, &hir_map));
|
||||||
|
|
||||||
time(time_passes,
|
time(time_passes,
|
||||||
"loop checking",
|
"loop checking",
|
||||||
|| loops::check_crate(sess, krate));
|
|| loops::check_crate(sess, &hir_map));
|
||||||
|
|
||||||
try!(time(time_passes,
|
try!(time(time_passes,
|
||||||
"static item recursion checking",
|
"static item recursion checking",
|
||||||
|| static_recursion::check_crate(sess, krate, &def_map.borrow(), &hir_map)));
|
|| static_recursion::check_crate(sess, &def_map.borrow(), &hir_map)));
|
||||||
|
|
||||||
|
let index = stability::Index::new(&hir_map);
|
||||||
|
|
||||||
ty::ctxt::create_and_enter(sess,
|
ty::ctxt::create_and_enter(sess,
|
||||||
arenas,
|
arenas,
|
||||||
|
@ -800,7 +810,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
freevars,
|
freevars,
|
||||||
region_map,
|
region_map,
|
||||||
lang_items,
|
lang_items,
|
||||||
stability::Index::new(krate),
|
index,
|
||||||
|tcx| {
|
|tcx| {
|
||||||
// passes are timed inside typeck
|
// passes are timed inside typeck
|
||||||
try_with_f!(typeck::check_crate(tcx, trait_map), (tcx, None, analysis));
|
try_with_f!(typeck::check_crate(tcx, trait_map), (tcx, None, analysis));
|
||||||
|
@ -818,7 +828,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||||
|
|
||||||
// Do not move this check past lint
|
// Do not move this check past lint
|
||||||
time(time_passes, "stability index", || {
|
time(time_passes, "stability index", || {
|
||||||
tcx.stability.borrow_mut().build(tcx, krate, &analysis.access_levels)
|
tcx.stability.borrow_mut().build(tcx, &analysis.access_levels)
|
||||||
});
|
});
|
||||||
|
|
||||||
time(time_passes,
|
time(time_passes,
|
||||||
|
|
|
@ -19,6 +19,7 @@ use rustc_trans::back::link;
|
||||||
|
|
||||||
use {driver, abort_on_err};
|
use {driver, abort_on_err};
|
||||||
|
|
||||||
|
use rustc::dep_graph::DepGraph;
|
||||||
use rustc::middle::ty;
|
use rustc::middle::ty;
|
||||||
use rustc::middle::cfg;
|
use rustc::middle::cfg;
|
||||||
use rustc::middle::cfg::graphviz::LabelledCFG;
|
use rustc::middle::cfg::graphviz::LabelledCFG;
|
||||||
|
@ -183,7 +184,7 @@ impl PpSourceMode {
|
||||||
sess: sess,
|
sess: sess,
|
||||||
ast_map: Some(ast_map.clone()),
|
ast_map: Some(ast_map.clone()),
|
||||||
};
|
};
|
||||||
f(&annotation, payload, &ast_map.forest.krate)
|
f(&annotation, payload, ast_map.forest.krate())
|
||||||
}
|
}
|
||||||
|
|
||||||
PpmIdentified => {
|
PpmIdentified => {
|
||||||
|
@ -191,7 +192,7 @@ impl PpSourceMode {
|
||||||
sess: sess,
|
sess: sess,
|
||||||
ast_map: Some(ast_map.clone()),
|
ast_map: Some(ast_map.clone()),
|
||||||
};
|
};
|
||||||
f(&annotation, payload, &ast_map.forest.krate)
|
f(&annotation, payload, ast_map.forest.krate())
|
||||||
}
|
}
|
||||||
PpmTyped => {
|
PpmTyped => {
|
||||||
abort_on_err(driver::phase_3_run_analysis_passes(sess,
|
abort_on_err(driver::phase_3_run_analysis_passes(sess,
|
||||||
|
@ -207,7 +208,7 @@ impl PpSourceMode {
|
||||||
let _ignore = tcx.dep_graph.in_ignore();
|
let _ignore = tcx.dep_graph.in_ignore();
|
||||||
f(&annotation,
|
f(&annotation,
|
||||||
payload,
|
payload,
|
||||||
&ast_map.forest.krate)
|
ast_map.forest.krate())
|
||||||
}), sess)
|
}), sess)
|
||||||
}
|
}
|
||||||
_ => panic!("Should use call_with_pp_support"),
|
_ => panic!("Should use call_with_pp_support"),
|
||||||
|
@ -706,8 +707,10 @@ pub fn pretty_print_input(sess: Session,
|
||||||
let mut hir_forest;
|
let mut hir_forest;
|
||||||
let lcx = LoweringContext::new(&sess, Some(&krate));
|
let lcx = LoweringContext::new(&sess, Some(&krate));
|
||||||
let arenas = ty::CtxtArenas::new();
|
let arenas = ty::CtxtArenas::new();
|
||||||
|
let dep_graph = DepGraph::new(false);
|
||||||
|
let _ignore = dep_graph.in_ignore();
|
||||||
let ast_map = if compute_ast_map {
|
let ast_map = if compute_ast_map {
|
||||||
hir_forest = hir_map::Forest::new(lower_crate(&lcx, &krate));
|
hir_forest = hir_map::Forest::new(lower_crate(&lcx, &krate), dep_graph.clone());
|
||||||
let map = driver::make_map(&sess, &mut hir_forest);
|
let map = driver::make_map(&sess, &mut hir_forest);
|
||||||
Some(map)
|
Some(map)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
//! # Standalone Tests for the Inference Module
|
//! # Standalone Tests for the Inference Module
|
||||||
|
|
||||||
use driver;
|
use driver;
|
||||||
|
use rustc::dep_graph::DepGraph;
|
||||||
use rustc_lint;
|
use rustc_lint;
|
||||||
use rustc_resolve as resolve;
|
use rustc_resolve as resolve;
|
||||||
use rustc_typeck::middle::lang_items;
|
use rustc_typeck::middle::lang_items;
|
||||||
|
@ -118,17 +119,19 @@ fn test_env<F>(source_string: &str,
|
||||||
|
|
||||||
let krate = driver::assign_node_ids(&sess, krate);
|
let krate = driver::assign_node_ids(&sess, krate);
|
||||||
let lcx = LoweringContext::new(&sess, Some(&krate));
|
let lcx = LoweringContext::new(&sess, Some(&krate));
|
||||||
let mut hir_forest = hir_map::Forest::new(lower_crate(&lcx, &krate));
|
let dep_graph = DepGraph::new(false);
|
||||||
|
let _ignore = dep_graph.in_ignore();
|
||||||
|
let mut hir_forest = hir_map::Forest::new(lower_crate(&lcx, &krate), dep_graph.clone());
|
||||||
let arenas = ty::CtxtArenas::new();
|
let arenas = ty::CtxtArenas::new();
|
||||||
let ast_map = driver::make_map(&sess, &mut hir_forest);
|
let ast_map = driver::make_map(&sess, &mut hir_forest);
|
||||||
let krate = ast_map.krate();
|
|
||||||
|
|
||||||
// run just enough stuff to build a tcx:
|
// run just enough stuff to build a tcx:
|
||||||
let lang_items = lang_items::collect_language_items(&sess, &ast_map);
|
let lang_items = lang_items::collect_language_items(&sess, &ast_map);
|
||||||
let resolve::CrateMap { def_map, freevars, .. } =
|
let resolve::CrateMap { def_map, freevars, .. } =
|
||||||
resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No);
|
resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No);
|
||||||
let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map.borrow());
|
let named_region_map = resolve_lifetime::krate(&sess, &ast_map, &def_map.borrow());
|
||||||
let region_map = region::resolve_crate(&sess, krate);
|
let region_map = region::resolve_crate(&sess, &ast_map);
|
||||||
|
let index = stability::Index::new(&ast_map);
|
||||||
ty::ctxt::create_and_enter(&sess,
|
ty::ctxt::create_and_enter(&sess,
|
||||||
&arenas,
|
&arenas,
|
||||||
def_map,
|
def_map,
|
||||||
|
@ -137,7 +140,7 @@ fn test_env<F>(source_string: &str,
|
||||||
freevars,
|
freevars,
|
||||||
region_map,
|
region_map,
|
||||||
lang_items,
|
lang_items,
|
||||||
stability::Index::new(krate),
|
index,
|
||||||
|tcx| {
|
|tcx| {
|
||||||
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
|
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
|
||||||
body(Env { infcx: &infcx });
|
body(Env { infcx: &infcx });
|
||||||
|
|
|
@ -18,6 +18,7 @@ use decoder;
|
||||||
use loader::{self, CratePaths};
|
use loader::{self, CratePaths};
|
||||||
|
|
||||||
use rustc::back::svh::Svh;
|
use rustc::back::svh::Svh;
|
||||||
|
use rustc::dep_graph::DepNode;
|
||||||
use rustc::session::{config, Session};
|
use rustc::session::{config, Session};
|
||||||
use rustc::session::search_paths::PathKind;
|
use rustc::session::search_paths::PathKind;
|
||||||
use rustc::middle::cstore::{CrateStore, validate_crate_name};
|
use rustc::middle::cstore::{CrateStore, validate_crate_name};
|
||||||
|
@ -723,7 +724,10 @@ impl<'a, 'b> LocalCrateReader<'a, 'b> {
|
||||||
// Traverses an AST, reading all the information about use'd crates and
|
// Traverses an AST, reading all the information about use'd crates and
|
||||||
// extern libraries necessary for later resolving, typechecking, linking,
|
// extern libraries necessary for later resolving, typechecking, linking,
|
||||||
// etc.
|
// etc.
|
||||||
pub fn read_crates(&mut self, krate: &hir::Crate) {
|
pub fn read_crates(&mut self) {
|
||||||
|
let _task = self.ast_map.dep_graph.in_task(DepNode::CrateReader);
|
||||||
|
let krate = self.ast_map.krate();
|
||||||
|
|
||||||
self.process_crate(krate);
|
self.process_crate(krate);
|
||||||
krate.visit_all_items(self);
|
krate.visit_all_items(self);
|
||||||
self.creader.inject_allocator_crate();
|
self.creader.inject_allocator_crate();
|
||||||
|
|
|
@ -11,9 +11,11 @@ use self::Context::*;
|
||||||
|
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
|
|
||||||
use syntax::codemap::Span;
|
use rustc::dep_graph::DepNode;
|
||||||
|
use rustc::front::map::Map;
|
||||||
use rustc_front::intravisit::{self, Visitor};
|
use rustc_front::intravisit::{self, Visitor};
|
||||||
use rustc_front::hir;
|
use rustc_front::hir;
|
||||||
|
use syntax::codemap::Span;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
enum Context {
|
enum Context {
|
||||||
|
@ -26,7 +28,9 @@ struct CheckLoopVisitor<'a> {
|
||||||
cx: Context
|
cx: Context
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate(sess: &Session, krate: &hir::Crate) {
|
pub fn check_crate(sess: &Session, map: &Map) {
|
||||||
|
let _task = map.dep_graph.in_task(DepNode::CheckLoops);
|
||||||
|
let krate = map.krate();
|
||||||
krate.visit_all_items(&mut CheckLoopVisitor { sess: sess, cx: Normal });
|
krate.visit_all_items(&mut CheckLoopVisitor { sess: sess, cx: Normal });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// This compiler pass detects constants that refer to themselves
|
// This compiler pass detects constants that refer to themselves
|
||||||
// recursively.
|
// recursively.
|
||||||
|
|
||||||
|
use rustc::dep_graph::DepNode;
|
||||||
use rustc::front::map as ast_map;
|
use rustc::front::map as ast_map;
|
||||||
use rustc::session::{Session, CompileResult};
|
use rustc::session::{Session, CompileResult};
|
||||||
use rustc::middle::def::{Def, DefMap};
|
use rustc::middle::def::{Def, DefMap};
|
||||||
|
@ -90,9 +91,11 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate<'ast>(sess: &Session,
|
pub fn check_crate<'ast>(sess: &Session,
|
||||||
krate: &'ast hir::Crate,
|
|
||||||
def_map: &DefMap,
|
def_map: &DefMap,
|
||||||
ast_map: &ast_map::Map<'ast>) -> CompileResult {
|
ast_map: &ast_map::Map<'ast>)
|
||||||
|
-> CompileResult {
|
||||||
|
let _task = ast_map.dep_graph.in_task(DepNode::CheckStaticRecursion);
|
||||||
|
|
||||||
let mut visitor = CheckCrateVisitor {
|
let mut visitor = CheckCrateVisitor {
|
||||||
sess: sess,
|
sess: sess,
|
||||||
def_map: def_map,
|
def_map: def_map,
|
||||||
|
@ -100,7 +103,7 @@ pub fn check_crate<'ast>(sess: &Session,
|
||||||
discriminant_map: RefCell::new(NodeMap()),
|
discriminant_map: RefCell::new(NodeMap()),
|
||||||
};
|
};
|
||||||
sess.track_errors(|| {
|
sess.track_errors(|| {
|
||||||
krate.visit_all_items(&mut visitor);
|
ast_map.krate().visit_all_items(&mut visitor);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::errors;
|
use syntax::errors;
|
||||||
|
use rustc::dep_graph::DepNode;
|
||||||
|
use rustc::front::map::Map;
|
||||||
use rustc_front::intravisit::Visitor;
|
use rustc_front::intravisit::Visitor;
|
||||||
use rustc_front::hir;
|
use rustc_front::hir;
|
||||||
|
|
||||||
|
@ -34,8 +36,11 @@ impl<'v> Visitor<'v> for RegistrarFinder {
|
||||||
|
|
||||||
/// Find the function marked with `#[plugin_registrar]`, if any.
|
/// Find the function marked with `#[plugin_registrar]`, if any.
|
||||||
pub fn find_plugin_registrar(diagnostic: &errors::Handler,
|
pub fn find_plugin_registrar(diagnostic: &errors::Handler,
|
||||||
krate: &hir::Crate)
|
hir_map: &Map)
|
||||||
-> Option<ast::NodeId> {
|
-> Option<ast::NodeId> {
|
||||||
|
let _task = hir_map.dep_graph.in_task(DepNode::PluginRegistrar);
|
||||||
|
let krate = hir_map.krate();
|
||||||
|
|
||||||
let mut finder = RegistrarFinder { registrars: Vec::new() };
|
let mut finder = RegistrarFinder { registrars: Vec::new() };
|
||||||
krate.visit_all_items(&mut finder);
|
krate.visit_all_items(&mut finder);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ use self::BareIdentifierPatternResolution::*;
|
||||||
use self::ParentLink::*;
|
use self::ParentLink::*;
|
||||||
use self::FallbackChecks::*;
|
use self::FallbackChecks::*;
|
||||||
|
|
||||||
|
use rustc::dep_graph::DepNode;
|
||||||
use rustc::front::map as hir_map;
|
use rustc::front::map as hir_map;
|
||||||
use rustc::session::Session;
|
use rustc::session::Session;
|
||||||
use rustc::lint;
|
use rustc::lint;
|
||||||
|
@ -3596,6 +3597,15 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
|
||||||
ast_map: &'a hir_map::Map<'tcx>,
|
ast_map: &'a hir_map::Map<'tcx>,
|
||||||
make_glob_map: MakeGlobMap)
|
make_glob_map: MakeGlobMap)
|
||||||
-> CrateMap {
|
-> CrateMap {
|
||||||
|
// Currently, we ignore the name resolution data structures for
|
||||||
|
// the purposes of dependency tracking. Instead we will run name
|
||||||
|
// resolution and include its output in the hash of each item,
|
||||||
|
// much like we do for macro expansion. In other words, the hash
|
||||||
|
// reflects not just its contents but the results of name
|
||||||
|
// resolution on those contents. Hopefully we'll push this back at
|
||||||
|
// some point.
|
||||||
|
let _task = ast_map.dep_graph.in_task(DepNode::Resolve);
|
||||||
|
|
||||||
let krate = ast_map.krate();
|
let krate = ast_map.krate();
|
||||||
let arenas = Resolver::arenas();
|
let arenas = Resolver::arenas();
|
||||||
let mut resolver = create_resolver(session, ast_map, krate, make_glob_map, &arenas, None);
|
let mut resolver = create_resolver(session, ast_map, krate, make_glob_map, &arenas, None);
|
||||||
|
|
|
@ -100,6 +100,7 @@ pub use rustc::middle;
|
||||||
pub use rustc::session;
|
pub use rustc::session;
|
||||||
pub use rustc::util;
|
pub use rustc::util;
|
||||||
|
|
||||||
|
use dep_graph::DepNode;
|
||||||
use front::map as hir_map;
|
use front::map as hir_map;
|
||||||
use middle::def::Def;
|
use middle::def::Def;
|
||||||
use middle::infer::{self, TypeOrigin};
|
use middle::infer::{self, TypeOrigin};
|
||||||
|
@ -312,6 +313,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
||||||
|
|
||||||
fn check_for_entry_fn(ccx: &CrateCtxt) {
|
fn check_for_entry_fn(ccx: &CrateCtxt) {
|
||||||
let tcx = ccx.tcx;
|
let tcx = ccx.tcx;
|
||||||
|
let _task = tcx.dep_graph.in_task(DepNode::CheckEntryFn);
|
||||||
match *tcx.sess.entry_fn.borrow() {
|
match *tcx.sess.entry_fn.borrow() {
|
||||||
Some((id, sp)) => match tcx.sess.entry_type.get() {
|
Some((id, sp)) => match tcx.sess.entry_type.get() {
|
||||||
Some(config::EntryMain) => check_main_fn_ty(ccx, id, sp),
|
Some(config::EntryMain) => check_main_fn_ty(ccx, id, sp),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue