Skip to content

Commit 47f1494

Browse files
committed
Instrument the passes to push/pop what we are currently doing.
1 parent ed71ba4 commit 47f1494

File tree

25 files changed

+114
-49
lines changed

25 files changed

+114
-49
lines changed

src/librustc/lint/context.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//! for all lint attributes.
2626
use self::TargetLint::*;
2727

28+
use dep_graph::DepNode;
2829
use middle::privacy::AccessLevels;
2930
use middle::ty::{self, Ty};
3031
use session::{early_error, Session};
@@ -1025,6 +1026,8 @@ impl LateLintPass for GatherNodeLevels {
10251026
///
10261027
/// Consumes the `lint_store` field of the `Session`.
10271028
pub fn check_crate(tcx: &ty::ctxt, access_levels: &AccessLevels) {
1029+
let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck);
1030+
10281031
let krate = tcx.map.krate();
10291032
let mut cx = LateContext::new(tcx, krate, access_levels);
10301033

src/librustc/middle/check_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// - It's not possible to take the address of a static item with unsafe interior. This is enforced
2525
// by borrowck::gather_loans
2626

27+
use dep_graph::DepNode;
2728
use middle::ty::cast::{CastKind};
2829
use middle::const_eval::{self, ConstEvalErr};
2930
use middle::const_eval::ErrKind::IndexOpFeatureGated;
@@ -840,13 +841,12 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
840841
}
841842

842843
pub fn check_crate(tcx: &ty::ctxt) {
843-
tcx.map.krate().visit_all_items(&mut CheckCrateVisitor {
844+
tcx.visit_all_items_in_krate(DepNode::CheckConst, &mut CheckCrateVisitor {
844845
tcx: tcx,
845846
mode: Mode::Var,
846847
qualif: ConstQualif::NOT_CONST,
847848
rvalue_borrows: NodeMap()
848849
});
849-
850850
tcx.sess.abort_if_errors();
851851
}
852852

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub use self::Constructor::*;
1212
use self::Usefulness::*;
1313
use self::WitnessPreference::*;
1414

15+
use dep_graph::DepNode;
1516
use middle::const_eval::{compare_const_vals, ConstVal};
1617
use middle::const_eval::{eval_const_expr, eval_const_expr_partial};
1718
use middle::const_eval::{const_expr_to_pat, lookup_const_by_id};
@@ -155,7 +156,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
155156
}
156157

157158
pub fn check_crate(tcx: &ty::ctxt) {
158-
tcx.map.krate().visit_all_items(&mut MatchCheckCtxt {
159+
tcx.visit_all_items_in_krate(DepNode::MatchCheck, &mut MatchCheckCtxt {
159160
tcx: tcx,
160161
param_env: tcx.empty_parameter_environment(),
161162
});

src/librustc/middle/check_rvalues.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
// Checks that all rvalues in a crate have statically known size. check_crate
1212
// is the public starting point.
1313

14+
use dep_graph::DepNode;
1415
use middle::expr_use_visitor as euv;
1516
use middle::infer;
1617
use middle::mem_categorization as mc;
1718
use middle::ty::ParameterEnvironment;
1819
use middle::ty;
1920

20-
use syntax::ast;
2121
use rustc_front::hir;
22-
use syntax::codemap::Span;
2322
use rustc_front::intravisit;
23+
use syntax::ast;
24+
use syntax::codemap::Span;
2425

25-
pub fn check_crate(tcx: &ty::ctxt,
26-
krate: &hir::Crate) {
26+
pub fn check_crate(tcx: &ty::ctxt) {
2727
let mut rvcx = RvalueContext { tcx: tcx };
28-
krate.visit_all_items(&mut rvcx);
28+
tcx.visit_all_items_in_krate(DepNode::RvalueCheck, &mut rvcx);
2929
}
3030

3131
struct RvalueContext<'a, 'tcx: 'a> {

src/librustc/middle/dead.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// closely. The idea is that all reachable symbols are live, codes called
1313
// from live codes are live, and everything else is dead.
1414

15+
use dep_graph::DepNode;
1516
use front::map as ast_map;
1617
use rustc_front::hir;
1718
use rustc_front::intravisit::{self, Visitor};
@@ -590,6 +591,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
590591
}
591592

592593
pub fn check_crate(tcx: &ty::ctxt, access_levels: &privacy::AccessLevels) {
594+
let _task = tcx.dep_graph.in_task(DepNode::DeadCheck);
593595
let krate = tcx.map.krate();
594596
let live_symbols = find_live(tcx, access_levels, krate);
595597
let mut visitor = DeadVisitor { tcx: tcx, live_symbols: live_symbols };

src/librustc/middle/intrinsicck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use dep_graph::DepNode;
1112
use middle::def::DefFn;
1213
use middle::def_id::DefId;
1314
use middle::subst::{Subst, Substs, EnumeratedItems};
@@ -29,7 +30,7 @@ pub fn check_crate(tcx: &ctxt) {
2930
dummy_sized_ty: tcx.types.isize,
3031
dummy_unsized_ty: tcx.mk_slice(tcx.types.isize),
3132
};
32-
tcx.map.krate().visit_all_items(&mut visitor);
33+
tcx.visit_all_items_in_krate(DepNode::IntrinsicCheck, &mut visitor);
3334
}
3435

3536
struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> {

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// makes all other generics or inline functions that it references
1616
// reachable as well.
1717

18+
use dep_graph::DepNode;
1819
use front::map as ast_map;
1920
use middle::def;
2021
use middle::def_id::DefId;
@@ -349,6 +350,7 @@ impl<'a, 'v> Visitor<'v> for CollectPrivateImplItemsVisitor<'a> {
349350
pub fn find_reachable(tcx: &ty::ctxt,
350351
access_levels: &privacy::AccessLevels)
351352
-> NodeSet {
353+
let _task = tcx.dep_graph.in_task(DepNode::Reachability);
352354

353355
let mut reachable_context = ReachableContext::new(tcx);
354356

src/librustc/middle/stability.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1414
pub use self::StabilityLevel::*;
1515

16+
use dep_graph::DepNode;
1617
use session::Session;
1718
use lint;
1819
use middle::cstore::{CrateStore, LOCAL_CRATE};
@@ -301,6 +302,7 @@ impl<'tcx> Index<'tcx> {
301302
/// features used.
302303
pub fn check_unstable_api_usage(tcx: &ty::ctxt)
303304
-> FnvHashMap<InternedString, StabilityLevel> {
305+
let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck);
304306
let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
305307

306308
// Put the active features into a map for quick lookup
@@ -314,8 +316,7 @@ pub fn check_unstable_api_usage(tcx: &ty::ctxt)
314316
};
315317
intravisit::walk_crate(&mut checker, tcx.map.krate());
316318

317-
let used_features = checker.used_features;
318-
return used_features;
319+
checker.used_features
319320
}
320321

321322
struct Checker<'a, 'tcx: 'a> {

src/librustc_borrowck/borrowck/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub use self::MovedValueUseKind::*;
2020

2121
use self::InteriorKind::*;
2222

23+
use rustc::dep_graph::DepNode;
2324
use rustc::front::map as hir_map;
2425
use rustc::front::map::blocks::FnParts;
2526
use rustc::middle::cfg;
@@ -108,7 +109,7 @@ pub fn check_crate(tcx: &ty::ctxt) {
108109
}
109110
};
110111

111-
tcx.map.krate().visit_all_items(&mut bccx);
112+
tcx.visit_all_items_in_krate(DepNode::BorrowCheck, &mut bccx);
112113

113114
if tcx.sess.borrowck_stats() {
114115
println!("--- borrowck stats ---");

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
791791

792792
time(time_passes,
793793
"rvalue checking",
794-
|| middle::check_rvalues::check_crate(tcx, krate));
794+
|| middle::check_rvalues::check_crate(tcx));
795795

796796
// Avoid overwhelming user with errors if type checking failed.
797797
// I'm not sure how helpful this is, to be honest, but it avoids

0 commit comments

Comments
 (0)