Skip to content

Commit 22f856c

Browse files
committed
more incr stuff
1 parent d01b9ec commit 22f856c

File tree

9 files changed

+85
-10
lines changed

9 files changed

+85
-10
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ define_dep_nodes!( <'tcx>
491491

492492
[] CheckModAttrs(DefId),
493493
[] CheckModLoops(DefId),
494+
[] CheckModUnstableApiUsage(DefId),
495+
[] CheckModItemTypes(DefId),
496+
[] CollectModItemTypes(DefId),
494497

495498
[] Reachability,
496499
[] MirKeys,

src/librustc/middle/stability.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use lint;
1717
use hir::def::Def;
1818
use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
1919
use ty::{self, TyCtxt};
20+
use ty::maps::Providers;
21+
use ty::maps::queries;
2022
use middle::privacy::AccessLevels;
2123
use session::DiagnosticMessageId;
2224
use syntax::symbol::Symbol;
@@ -463,11 +465,23 @@ impl<'a, 'tcx> Index<'tcx> {
463465
}
464466
}
465467

468+
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
469+
for &module in &tcx.hir.krate().modules {
470+
queries::check_mod_unstable_api_usage::ensure(tcx, tcx.hir.local_def_id(module));
471+
}
472+
}
473+
466474
/// Cross-references the feature names of unstable APIs with enabled
467475
/// features and possibly prints errors.
468-
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
469-
let mut checker = Checker { tcx: tcx };
470-
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
476+
pub fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
477+
tcx.hir.visit_module_item_likes(module_def_id, Checker { tcx }.as_deep_visitor());
478+
}
479+
480+
pub fn provide(providers: &mut Providers) {
481+
*providers = Providers {
482+
check_mod_unstable_api_usage,
483+
..*providers
484+
};
471485
}
472486

473487
/// Check whether an item marked with `deprecated(since="X")` is currently

src/librustc/ty/context.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10861086
f: F) -> R
10871087
where F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'tcx>) -> R
10881088
{
1089+
if s.verbose() {
1090+
eprintln!("entering tcx 1");
1091+
}
1092+
10891093
let data_layout = TargetDataLayout::parse(&s.target.target).unwrap_or_else(|err| {
10901094
s.fatal(&err);
10911095
});
@@ -1096,6 +1100,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10961100
let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
10971101
providers[LOCAL_CRATE] = local_providers;
10981102

1103+
if s.verbose() {
1104+
eprintln!("entering tcx 2");
1105+
}
1106+
10991107
let def_path_hash_to_def_id = if s.opts.build_dep_graph() {
11001108
let upstream_def_path_tables: Vec<(CrateNum, Lrc<_>)> = cstore
11011109
.crates_untracked()
@@ -1128,6 +1136,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11281136
None
11291137
};
11301138

1139+
if s.verbose() {
1140+
eprintln!("entering tcx 3");
1141+
}
1142+
11311143
let mut trait_map = FxHashMap();
11321144
for (k, v) in resolutions.trait_map {
11331145
let hir_id = hir.node_to_hir_id(k);
@@ -1138,6 +1150,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11381150
Lrc::new(StableVec::new(v)));
11391151
}
11401152

1153+
if s.verbose() {
1154+
eprintln!("entering tcx 4");
1155+
}
1156+
11411157
let gcx = &GlobalCtxt {
11421158
sess: s,
11431159
cstore,
@@ -1181,6 +1197,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11811197

11821198
sync::assert_send_val(&gcx);
11831199

1200+
if s.verbose() {
1201+
eprintln!("entering tcx 5");
1202+
}
1203+
11841204
tls::enter_global(gcx, f)
11851205
}
11861206

src/librustc/ty/maps/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,15 @@ define_maps! { <'tcx>
195195
/// Checks the attributes in the module
196196
[] fn check_mod_attrs: CheckModAttrs(DefId) -> (),
197197

198+
[] fn check_mod_unstable_api_usage: CheckModUnstableApiUsage(DefId) -> (),
199+
198200
/// Checks the attributes in the module
199201
[] fn check_mod_loops: CheckModLoops(DefId) -> (),
200202

203+
[] fn check_mod_item_types: CheckModItemTypes(DefId) -> (),
204+
205+
[] fn collect_mod_item_types: CollectModItemTypes(DefId) -> (),
206+
201207
/// The signature of functions and closures.
202208
[] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
203209

src/librustc/ty/maps/plumbing.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
586586
span: Span,
587587
dep_node: DepNode
588588
) -> Result<(Q::Value, DepNodeIndex), CycleError<'gcx>> {
589+
if self.sess.verbose() {
590+
eprintln!("forcing queries {} key={:?})",
591+
Q::NAME,
592+
key);
593+
}
594+
589595
// We may be concurrently trying both execute and force a query
590596
// Ensure that only one of them runs the query
591597
let job = match JobOwner::try_get(self, span, &key) {
@@ -1049,6 +1055,9 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
10491055
DepKind::UnsafeDeriveOnReprPacked => { force!(unsafe_derive_on_repr_packed, def_id!()); }
10501056
DepKind::CheckModAttrs => { force!(check_mod_attrs, def_id!()); }
10511057
DepKind::CheckModLoops => { force!(check_mod_loops, def_id!()); }
1058+
DepKind::CheckModUnstableApiUsage => { force!(check_mod_unstable_api_usage, def_id!()); }
1059+
DepKind::CheckModItemTypes => { force!(check_mod_item_types, def_id!()); }
1060+
DepKind::CollectModItemTypes => { force!(collect_mod_item_types, def_id!()); }
10521061
DepKind::Reachability => { force!(reachable_set, LOCAL_CRATE); }
10531062
DepKind::MirKeys => { force!(mir_keys, LOCAL_CRATE); }
10541063
DepKind::CrateVariances => { force!(crate_variances, LOCAL_CRATE); }

src/librustc/util/common.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ pub fn time_ext<T, F>(do_it: bool, sess: Option<&Session>, what: &str, f: F) ->
171171
r
172172
});
173173

174+
if sess.map(|s| s.verbose()).unwrap_or(false) {
175+
let indentation = TIME_DEPTH.with(|slot| slot.get());
176+
println!("{}start time: {}",
177+
repeat(" ").take(indentation).collect::<String>(),
178+
what);
179+
}
180+
174181
if let Some(sess) = sess {
175182
if cfg!(debug_assertions) {
176183
profq_msg(sess, ProfileQueriesMsg::TimeBegin(what.to_string()))

src/librustc_driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ pub fn default_provide(providers: &mut ty::maps::Providers) {
11501150
typeck::provide(providers);
11511151
ty::provide(providers);
11521152
traits::provide(providers);
1153-
reachable::provide(providers);
1153+
stability::provide(providers);
11541154
rustc_passes::provide(providers);
11551155
rustc_traits::provide(providers);
11561156
middle::region::provide(providers);
@@ -1228,7 +1228,7 @@ where
12281228
|tcx| {
12291229
// Do some initialization of the DepGraph that can only be done with the
12301230
// tcx available.
1231-
rustc_incremental::dep_graph_tcx_init(tcx);
1231+
time(sess, "dep graph tcx init", || rustc_incremental::dep_graph_tcx_init(tcx));
12321232

12331233
time(sess, "loop checking", || loops::check_crate(tcx));
12341234

src/librustc_typeck/check/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ use rustc::traits::{self, ObligationCause, ObligationCauseCode, TraitEngine};
9999
use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind, Visibility, ToPredicate, RegionKind};
100100
use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
101101
use rustc::ty::fold::TypeFoldable;
102-
use rustc::ty::maps::Providers;
102+
use rustc::ty::maps::{queries, Providers};
103103
use rustc::ty::util::{Representability, IntTypeExt, Discr};
104104
use errors::{DiagnosticBuilder, DiagnosticId};
105105

@@ -689,10 +689,16 @@ pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorRe
689689

690690
pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> {
691691
tcx.sess.track_errors(|| {
692-
tcx.hir.krate().visit_all_item_likes(&mut CheckItemTypesVisitor { tcx });
692+
for &module in &tcx.hir.krate().modules {
693+
queries::check_mod_item_types::ensure(tcx, tcx.hir.local_def_id(module));
694+
}
693695
})
694696
}
695697

698+
fn check_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
699+
tcx.hir.visit_module_item_likes(module_def_id, CheckItemTypesVisitor { tcx });
700+
}
701+
696702
pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), CompileIncomplete> {
697703
tcx.typeck_item_bodies(LOCAL_CRATE)
698704
}
@@ -731,6 +737,7 @@ pub fn provide(providers: &mut Providers) {
731737
check_item_well_formed,
732738
check_trait_item_well_formed,
733739
check_impl_item_well_formed,
740+
check_mod_item_types,
734741
..*providers
735742
};
736743
}

src/librustc_typeck/collect.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc::mir::mono::Linkage;
3333
use rustc::ty::subst::Substs;
3434
use rustc::ty::{ToPredicate, ReprOptions};
3535
use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
36-
use rustc::ty::maps::Providers;
36+
use rustc::ty::maps::{Providers, queries};
3737
use rustc::ty::util::IntTypeExt;
3838
use rustc::ty::util::Discr;
3939
use rustc::util::captures::Captures;
@@ -57,8 +57,16 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
5757
// Main entry point
5858

5959
pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
60-
let mut visitor = CollectItemTypesVisitor { tcx: tcx };
61-
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
60+
for &module in &tcx.hir.krate().modules {
61+
queries::collect_mod_item_types::ensure(tcx, tcx.hir.local_def_id(module));
62+
}
63+
}
64+
65+
fn collect_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
66+
tcx.hir.visit_module_item_likes(
67+
module_def_id,
68+
CollectItemTypesVisitor { tcx }.as_deep_visitor()
69+
);
6270
}
6371

6472
pub fn provide(providers: &mut Providers) {
@@ -76,6 +84,7 @@ pub fn provide(providers: &mut Providers) {
7684
impl_polarity,
7785
is_foreign_item,
7886
codegen_fn_attrs,
87+
collect_mod_item_types,
7988
..*providers
8089
};
8190
}

0 commit comments

Comments
 (0)