Skip to content

Commit ceaa55e

Browse files
authored
Rollup merge of #41360 - nikomatsakis:incr-comp-issue-40746-visitors, r=eddyb
convert calls to `visit_all_item_likes_in_krate` We no longer need to track the tasks in these cases since these particular tasks have no outputs (except, potentially, errors...) and they always execute. cc #40746 r? @eddyb
2 parents ddf4781 + c842783 commit ceaa55e

File tree

23 files changed

+22
-156
lines changed

23 files changed

+22
-156
lines changed

src/librustc/dep_graph/dep_node.rs

-40
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,15 @@ pub enum DepNode<D: Clone + Debug> {
5656
WorkProduct(Arc<WorkProductId>),
5757

5858
// Represents different phases in the compiler.
59-
CollectLanguageItems,
60-
ResolveLifetimes,
6159
RegionResolveCrate,
62-
PluginRegistrar,
63-
StabilityIndex,
64-
CollectItem(D),
65-
CollectItemSig(D),
6660
Coherence,
6761
Resolve,
68-
EntryPoint,
69-
CheckEntryFn,
7062
CoherenceCheckTrait(D),
7163
CoherenceCheckImpl(D),
7264
CoherenceOverlapCheck(D),
7365
CoherenceOverlapCheckSpecial(D),
74-
CoherenceOrphanCheck(D),
7566
Variance,
76-
WfCheck(D),
77-
TypeckItemType(D),
78-
UnusedTraitCheck,
79-
CheckConst(D),
8067
PrivacyAccessLevels(CrateNum),
81-
IntrinsicCheck(D),
82-
MatchCheck(D),
8368

8469
// Represents the MIR for a fn; also used as the task node for
8570
// things read/modify that MIR.
@@ -91,14 +76,10 @@ pub enum DepNode<D: Clone + Debug> {
9176
BorrowCheck(D),
9277
RvalueCheck(D),
9378
Reachability,
94-
DeadCheck,
95-
StabilityCheck(D),
9679
LateLintCheck,
97-
TransCrate,
9880
TransCrateItem(D),
9981
TransInlinedItem(D),
10082
TransWriteMetadata,
101-
LinkBinary,
10283

10384
// Nodes representing bits of computed IR in the tcx. Each shared
10485
// table in the tcx (or elsewhere) maps to one of these
@@ -184,12 +165,10 @@ impl<D: Clone + Debug> DepNode<D> {
184165
}
185166

186167
check! {
187-
CollectItem,
188168
BorrowCheck,
189169
Hir,
190170
HirBody,
191171
TransCrateItem,
192-
TypeckItemType,
193172
AssociatedItems,
194173
ItemSignature,
195174
AssociatedItemDefIds,
@@ -211,24 +190,14 @@ impl<D: Clone + Debug> DepNode<D> {
211190
BorrowCheckKrate => Some(BorrowCheckKrate),
212191
MirKrate => Some(MirKrate),
213192
TypeckBodiesKrate => Some(TypeckBodiesKrate),
214-
CollectLanguageItems => Some(CollectLanguageItems),
215-
ResolveLifetimes => Some(ResolveLifetimes),
216193
RegionResolveCrate => Some(RegionResolveCrate),
217-
PluginRegistrar => Some(PluginRegistrar),
218-
StabilityIndex => Some(StabilityIndex),
219194
Coherence => Some(Coherence),
220195
Resolve => Some(Resolve),
221-
EntryPoint => Some(EntryPoint),
222-
CheckEntryFn => Some(CheckEntryFn),
223196
Variance => Some(Variance),
224-
UnusedTraitCheck => Some(UnusedTraitCheck),
225197
PrivacyAccessLevels(k) => Some(PrivacyAccessLevels(k)),
226198
Reachability => Some(Reachability),
227-
DeadCheck => Some(DeadCheck),
228199
LateLintCheck => Some(LateLintCheck),
229-
TransCrate => Some(TransCrate),
230200
TransWriteMetadata => Some(TransWriteMetadata),
231-
LinkBinary => Some(LinkBinary),
232201

233202
// work product names do not need to be mapped, because
234203
// they are always absolute.
@@ -237,26 +206,17 @@ impl<D: Clone + Debug> DepNode<D> {
237206
Hir(ref d) => op(d).map(Hir),
238207
HirBody(ref d) => op(d).map(HirBody),
239208
MetaData(ref d) => op(d).map(MetaData),
240-
CollectItem(ref d) => op(d).map(CollectItem),
241-
CollectItemSig(ref d) => op(d).map(CollectItemSig),
242209
CoherenceCheckTrait(ref d) => op(d).map(CoherenceCheckTrait),
243210
CoherenceCheckImpl(ref d) => op(d).map(CoherenceCheckImpl),
244211
CoherenceOverlapCheck(ref d) => op(d).map(CoherenceOverlapCheck),
245212
CoherenceOverlapCheckSpecial(ref d) => op(d).map(CoherenceOverlapCheckSpecial),
246-
CoherenceOrphanCheck(ref d) => op(d).map(CoherenceOrphanCheck),
247-
WfCheck(ref d) => op(d).map(WfCheck),
248-
TypeckItemType(ref d) => op(d).map(TypeckItemType),
249-
CheckConst(ref d) => op(d).map(CheckConst),
250-
IntrinsicCheck(ref d) => op(d).map(IntrinsicCheck),
251-
MatchCheck(ref d) => op(d).map(MatchCheck),
252213
Mir(ref d) => op(d).map(Mir),
253214
MirShim(ref def_ids) => {
254215
let def_ids: Option<Vec<E>> = def_ids.iter().map(op).collect();
255216
def_ids.map(MirShim)
256217
}
257218
BorrowCheck(ref d) => op(d).map(BorrowCheck),
258219
RvalueCheck(ref d) => op(d).map(RvalueCheck),
259-
StabilityCheck(ref d) => op(d).map(StabilityCheck),
260220
TransCrateItem(ref d) => op(d).map(TransCrateItem),
261221
TransInlinedItem(ref d) => op(d).map(TransInlinedItem),
262222
AssociatedItems(ref d) => op(d).map(AssociatedItems),

src/librustc/middle/dead.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
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;
1615
use hir::map as hir_map;
1716
use hir::{self, PatKind};
1817
use hir::intravisit::{self, Visitor, NestedVisitorMap};
@@ -594,7 +593,6 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
594593
}
595594

596595
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
597-
let _task = tcx.dep_graph.in_task(DepNode::DeadCheck);
598596
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
599597
let krate = tcx.hir.krate();
600598
let live_symbols = find_live(tcx, access_levels, krate);

src/librustc/middle/entry.rs

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111

12-
use dep_graph::DepNode;
1312
use hir::map as hir_map;
1413
use hir::def_id::{CRATE_DEF_INDEX};
1514
use session::{config, Session};
@@ -57,8 +56,6 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
5756
}
5857

5958
pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) {
60-
let _task = hir_map.dep_graph.in_task(DepNode::EntryPoint);
61-
6259
let any_exe = session.crate_types.borrow().iter().any(|ty| {
6360
*ty == config::CrateTypeExecutable
6461
});

src/librustc/middle/intrinsicck.rs

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

11-
use dep_graph::DepNode;
1211
use hir::def::Def;
1312
use hir::def_id::DefId;
1413
use infer::InferCtxt;
@@ -25,7 +24,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
2524
let mut visitor = ItemVisitor {
2625
tcx: tcx
2726
};
28-
tcx.visit_all_item_likes_in_krate(DepNode::IntrinsicCheck, &mut visitor.as_deep_visitor());
27+
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
2928
}
3029

3130
struct ItemVisitor<'a, 'tcx: 'a> {

src/librustc/middle/lang_items.rs

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
pub use self::LangItem::*;
2323

24-
use dep_graph::DepNode;
2524
use hir::map as hir_map;
2625
use session::Session;
2726
use hir::def_id::DefId;
@@ -236,7 +235,6 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
236235
pub fn collect_language_items(session: &Session,
237236
map: &hir_map::Map)
238237
-> LanguageItems {
239-
let _task = map.dep_graph.in_task(DepNode::CollectLanguageItems);
240238
let krate: &hir::Crate = map.krate();
241239
let mut collector = LanguageItemCollector::new(session, map);
242240
collector.collect(krate);

src/librustc/middle/resolve_lifetime.rs

-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//! used between functions, and they operate in a purely top-down
1616
//! way. Therefore we break lifetime name resolution into a separate pass.
1717
18-
use dep_graph::DepNode;
1918
use hir::map::Map;
2019
use session::Session;
2120
use hir::def::Def;
@@ -259,7 +258,6 @@ const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;
259258
pub fn krate(sess: &Session,
260259
hir_map: &Map)
261260
-> Result<NamedRegionMap, usize> {
262-
let _task = hir_map.dep_graph.in_task(DepNode::ResolveLifetimes);
263261
let krate = hir_map.krate();
264262
let mut map = NamedRegionMap {
265263
defs: NodeMap(),

src/librustc/middle/stability.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
1414
pub use self::StabilityLevel::*;
1515

16-
use dep_graph::DepNode;
1716
use hir::map as hir_map;
1817
use lint;
1918
use hir::def::Def;
@@ -383,7 +382,6 @@ impl<'a, 'tcx> Index<'tcx> {
383382
// Put the active features into a map for quick lookup
384383
self.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
385384

386-
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
387385
let krate = tcx.hir.krate();
388386
let mut annotator = Annotator {
389387
tcx: tcx,
@@ -397,7 +395,6 @@ impl<'a, 'tcx> Index<'tcx> {
397395
}
398396

399397
pub fn new(hir_map: &hir_map::Map) -> Index<'tcx> {
400-
let _task = hir_map.dep_graph.in_task(DepNode::StabilityIndex);
401398
let krate = hir_map.krate();
402399

403400
let mut is_staged_api = false;
@@ -424,7 +421,7 @@ impl<'a, 'tcx> Index<'tcx> {
424421
/// features and possibly prints errors.
425422
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
426423
let mut checker = Checker { tcx: tcx };
427-
tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck, &mut checker.as_deep_visitor());
424+
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
428425
}
429426

430427
struct Checker<'a, 'tcx: 'a> {
@@ -662,7 +659,6 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
662659
let access_levels = &ty::queries::privacy_access_levels::get(tcx, DUMMY_SP, LOCAL_CRATE);
663660

664661
if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api {
665-
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
666662
let krate = tcx.hir.krate();
667663
let mut missing = MissingStabilityAnnotations {
668664
tcx: tcx,

src/librustc_const_eval/check_match.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use _match::WitnessPreference::*;
1414

1515
use pattern::{Pattern, PatternContext, PatternError, PatternKind};
1616

17-
use rustc::dep_graph::DepNode;
18-
1917
use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor};
2018
use rustc::middle::expr_use_visitor::{LoanCause, MutateMode};
2119
use rustc::middle::expr_use_visitor as euv;
@@ -56,8 +54,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
5654
}
5755

5856
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
59-
tcx.visit_all_item_likes_in_krate(DepNode::MatchCheck,
60-
&mut OuterVisitor { tcx: tcx }.as_deep_visitor());
57+
tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx: tcx }.as_deep_visitor());
6158
tcx.sess.abort_if_errors();
6259
}
6360

src/librustc_driver/derive_registrar.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::dep_graph::DepNode;
1211
use rustc::hir::itemlikevisit::ItemLikeVisitor;
1312
use rustc::hir::map::Map;
1413
use rustc::hir;
1514
use syntax::ast;
1615
use syntax::attr;
1716

1817
pub fn find(hir_map: &Map) -> Option<ast::NodeId> {
19-
let _task = hir_map.dep_graph.in_task(DepNode::PluginRegistrar);
2018
let krate = hir_map.krate();
2119

2220
let mut finder = Finder { registrar: None };

src/librustc_mir/mir_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn build_mir_for_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6868
NestedVisitorMap::None
6969
}
7070
}
71-
tcx.visit_all_item_likes_in_krate(DepNode::Mir, &mut GatherCtors {
71+
tcx.hir.krate().visit_all_item_likes(&mut GatherCtors {
7272
tcx: tcx
7373
}.as_deep_visitor());
7474
}

src/librustc_passes/consts.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
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 rustc::dep_graph::DepNode;
2827
use rustc::ty::cast::CastKind;
2928
use rustc_const_eval::ConstContext;
3029
use rustc::middle::const_val::ConstEvalErr;
@@ -459,15 +458,14 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
459458
}
460459

461460
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
462-
tcx.visit_all_item_likes_in_krate(DepNode::CheckConst,
463-
&mut CheckCrateVisitor {
464-
tcx: tcx,
465-
tables: &ty::TypeckTables::empty(),
466-
in_fn: false,
467-
promotable: false,
468-
mut_rvalue_borrows: NodeSet(),
469-
param_env: tcx.empty_parameter_environment(),
470-
}.as_deep_visitor());
461+
tcx.hir.krate().visit_all_item_likes(&mut CheckCrateVisitor {
462+
tcx: tcx,
463+
tables: &ty::TypeckTables::empty(),
464+
in_fn: false,
465+
promotable: false,
466+
mut_rvalue_borrows: NodeSet(),
467+
param_env: tcx.empty_parameter_environment(),
468+
}.as_deep_visitor());
471469
tcx.sess.abort_if_errors();
472470
}
473471

src/librustc_plugin/build.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use syntax::ast;
1414
use syntax::attr;
1515
use errors;
1616
use syntax_pos::Span;
17-
use rustc::dep_graph::DepNode;
1817
use rustc::hir::map::Map;
1918
use rustc::hir::itemlikevisit::ItemLikeVisitor;
2019
use rustc::hir;
@@ -44,7 +43,6 @@ impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
4443
pub fn find_plugin_registrar(diagnostic: &errors::Handler,
4544
hir_map: &Map)
4645
-> Option<ast::NodeId> {
47-
let _task = hir_map.dep_graph.in_task(DepNode::PluginRegistrar);
4846
let krate = hir_map.krate();
4947

5048
let mut finder = RegistrarFinder { registrars: Vec::new() };

src/librustc_trans/back/link.rs

-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ pub fn link_binary(sess: &Session,
192192
trans: &CrateTranslation,
193193
outputs: &OutputFilenames,
194194
crate_name: &str) -> Vec<PathBuf> {
195-
let _task = sess.dep_graph.in_task(DepNode::LinkBinary);
196-
197195
let mut out_filenames = Vec::new();
198196
for &crate_type in sess.crate_types.borrow().iter() {
199197
// Ignore executable crates if we have -Z no-trans, as they will error.

src/librustc_trans/base.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use rustc::hir::def_id::LOCAL_CRATE;
3838
use middle::lang_items::StartFnLangItem;
3939
use middle::cstore::EncodedMetadata;
4040
use rustc::ty::{self, Ty, TyCtxt};
41-
use rustc::dep_graph::{AssertDepGraphSafe, DepNode};
41+
use rustc::dep_graph::AssertDepGraphSafe;
4242
use rustc::middle::cstore::LinkMeta;
4343
use rustc::hir::map as hir_map;
4444
use rustc::util::common::time;
@@ -1057,8 +1057,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10571057
analysis: ty::CrateAnalysis,
10581058
incremental_hashes_map: &IncrementalHashesMap)
10591059
-> CrateTranslation {
1060-
let _task = tcx.dep_graph.in_task(DepNode::TransCrate);
1061-
10621060
// Be careful with this krate: obviously it gives access to the
10631061
// entire contents of the krate. So if you push any subtasks of
10641062
// `TransCrate`, you need to be careful to register "reads" of the

src/librustc_typeck/check/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ pub use self::compare_method::{compare_impl_method, compare_const_impl};
8282
use self::TupleArgumentsFlag::*;
8383

8484
use astconv::AstConv;
85-
use dep_graph::DepNode;
8685
use fmt_macros::{Parser, Piece, Position};
8786
use hir::def::{Def, CtorKind};
8887
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
@@ -577,14 +576,13 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
577576
pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
578577
tcx.sess.track_errors(|| {
579578
let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx);
580-
tcx.visit_all_item_likes_in_krate(DepNode::WfCheck, &mut visit.as_deep_visitor());
579+
tcx.hir.krate().visit_all_item_likes(&mut visit.as_deep_visitor());
581580
})
582581
}
583582

584583
pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
585584
tcx.sess.track_errors(|| {
586-
tcx.visit_all_item_likes_in_krate(DepNode::TypeckItemType,
587-
&mut CheckItemTypesVisitor { tcx });
585+
tcx.hir.krate().visit_all_item_likes(&mut CheckItemTypesVisitor { tcx });
588586
})
589587
}
590588

src/librustc_typeck/check_unused.rs

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
use lint;
12-
use rustc::dep_graph::DepNode;
1312
use rustc::ty::TyCtxt;
1413

1514
use syntax::ast;
@@ -62,8 +61,6 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CheckVisitor<'a, 'tcx> {
6261
}
6362

6463
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
65-
let _task = tcx.dep_graph.in_task(DepNode::UnusedTraitCheck);
66-
6764
let mut used_trait_imports = DefIdSet();
6865
for &body_id in tcx.hir.krate().bodies.keys() {
6966
let item_id = tcx.hir.body_owner(body_id);

0 commit comments

Comments
 (0)