Skip to content

Commit 810e015

Browse files
committed
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.
1 parent e621e1c commit 810e015

File tree

11 files changed

+21
-96
lines changed

11 files changed

+21
-96
lines changed

src/librustc/dep_graph/dep_node.rs

-20
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ pub enum DepNode<D: Clone + Debug> {
6161
RegionResolveCrate,
6262
PluginRegistrar,
6363
StabilityIndex,
64-
CollectItem(D),
65-
CollectItemSig(D),
6664
Coherence,
6765
Resolve,
6866
EntryPoint,
@@ -71,15 +69,9 @@ pub enum DepNode<D: Clone + Debug> {
7169
CoherenceCheckImpl(D),
7270
CoherenceOverlapCheck(D),
7371
CoherenceOverlapCheckSpecial(D),
74-
CoherenceOrphanCheck(D),
7572
Variance,
76-
WfCheck(D),
77-
TypeckItemType(D),
7873
UnusedTraitCheck,
79-
CheckConst(D),
8074
PrivacyAccessLevels(CrateNum),
81-
IntrinsicCheck(D),
82-
MatchCheck(D),
8375

8476
// Represents the MIR for a fn; also used as the task node for
8577
// things read/modify that MIR.
@@ -92,7 +84,6 @@ pub enum DepNode<D: Clone + Debug> {
9284
RvalueCheck(D),
9385
Reachability,
9486
DeadCheck,
95-
StabilityCheck(D),
9687
LateLintCheck,
9788
TransCrate,
9889
TransCrateItem(D),
@@ -184,12 +175,10 @@ impl<D: Clone + Debug> DepNode<D> {
184175
}
185176

186177
check! {
187-
CollectItem,
188178
BorrowCheck,
189179
Hir,
190180
HirBody,
191181
TransCrateItem,
192-
TypeckItemType,
193182
AssociatedItems,
194183
ItemSignature,
195184
AssociatedItemDefIds,
@@ -237,26 +226,17 @@ impl<D: Clone + Debug> DepNode<D> {
237226
Hir(ref d) => op(d).map(Hir),
238227
HirBody(ref d) => op(d).map(HirBody),
239228
MetaData(ref d) => op(d).map(MetaData),
240-
CollectItem(ref d) => op(d).map(CollectItem),
241-
CollectItemSig(ref d) => op(d).map(CollectItemSig),
242229
CoherenceCheckTrait(ref d) => op(d).map(CoherenceCheckTrait),
243230
CoherenceCheckImpl(ref d) => op(d).map(CoherenceCheckImpl),
244231
CoherenceOverlapCheck(ref d) => op(d).map(CoherenceOverlapCheck),
245232
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),
252233
Mir(ref d) => op(d).map(Mir),
253234
MirShim(ref def_ids) => {
254235
let def_ids: Option<Vec<E>> = def_ids.iter().map(op).collect();
255236
def_ids.map(MirShim)
256237
}
257238
BorrowCheck(ref d) => op(d).map(BorrowCheck),
258239
RvalueCheck(ref d) => op(d).map(RvalueCheck),
259-
StabilityCheck(ref d) => op(d).map(StabilityCheck),
260240
TransCrateItem(ref d) => op(d).map(TransCrateItem),
261241
TransInlinedItem(ref d) => op(d).map(TransInlinedItem),
262242
AssociatedItems(ref d) => op(d).map(AssociatedItems),

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/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'a, 'tcx> Index<'tcx> {
424424
/// features and possibly prints errors.
425425
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
426426
let mut checker = Checker { tcx: tcx };
427-
tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck, &mut checker.as_deep_visitor());
427+
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
428428
}
429429

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

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_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_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/coherence/orphan.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
1414
use rustc::traits;
1515
use rustc::ty::{self, TyCtxt};
16-
use rustc::dep_graph::DepNode;
1716
use rustc::hir::itemlikevisit::ItemLikeVisitor;
1817
use rustc::hir;
1918

2019
pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
2120
let mut orphan = OrphanChecker { tcx: tcx };
22-
tcx.visit_all_item_likes_in_krate(DepNode::CoherenceOrphanCheck, &mut orphan);
21+
tcx.hir.krate().visit_all_item_likes(&mut orphan);
2322
}
2423

2524
struct OrphanChecker<'cx, 'tcx: 'cx> {

src/librustc_typeck/coherence/overlap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn check_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
2424

2525
// this secondary walk specifically checks for some other cases,
2626
// like defaulted traits, for which additional overlap rules exist
27-
tcx.visit_all_item_likes_in_krate(DepNode::CoherenceOverlapCheckSpecial, &mut overlap);
27+
tcx.hir.krate().visit_all_item_likes(&mut overlap);
2828
}
2929

3030
pub fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {

src/librustc_typeck/collect.rs

+4-49
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ use rustc::ty::{ToPredicate, ReprOptions};
6464
use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
6565
use rustc::ty::maps::Providers;
6666
use rustc::ty::util::IntTypeExt;
67-
use rustc::dep_graph::DepNode;
6867
use util::nodemap::{NodeMap, FxHashMap};
6968

7069
use rustc_const_math::ConstInt;
@@ -87,7 +86,7 @@ use rustc::hir::def_id::DefId;
8786

8887
pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
8988
let mut visitor = CollectItemTypesVisitor { tcx: tcx };
90-
tcx.visit_all_item_likes_in_krate(DepNode::CollectItem, &mut visitor.as_deep_visitor());
89+
tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
9190
}
9291

9392
pub fn provide(providers: &mut Providers) {
@@ -126,57 +125,13 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
126125
tcx: TyCtxt<'a, 'tcx, 'tcx>
127126
}
128127

129-
impl<'a, 'tcx> CollectItemTypesVisitor<'a, 'tcx> {
130-
/// Collect item types is structured into two tasks. The outer
131-
/// task, `CollectItem`, walks the entire content of an item-like
132-
/// thing, including its body. It also spawns an inner task,
133-
/// `CollectItemSig`, which walks only the signature. This inner
134-
/// task is the one that writes the item-type into the various
135-
/// maps. This setup ensures that the item body is never
136-
/// accessible to the task that computes its signature, so that
137-
/// changes to the body don't affect the signature.
138-
///
139-
/// Consider an example function `foo` that also has a closure in its body:
140-
///
141-
/// ```
142-
/// fn foo(<sig>) {
143-
/// ...
144-
/// let bar = || ...; // we'll label this closure as "bar" below
145-
/// }
146-
/// ```
147-
///
148-
/// This results in a dep-graph like so. I've labeled the edges to
149-
/// document where they arise.
150-
///
151-
/// ```
152-
/// [HirBody(foo)] -2--> [CollectItem(foo)] -4-> [ItemSignature(bar)]
153-
/// ^ ^
154-
/// 1 3
155-
/// [Hir(foo)] -----------+-6-> [CollectItemSig(foo)] -5-> [ItemSignature(foo)]
156-
/// ```
157-
///
158-
/// 1. This is added by the `visit_all_item_likes_in_krate`.
159-
/// 2. This is added when we fetch the item body.
160-
/// 3. This is added because `CollectItem` launches `CollectItemSig`.
161-
/// - it is arguably false; if we refactor the `with_task` system;
162-
/// we could get probably rid of it, but it is also harmless enough.
163-
/// 4. This is added by the code in `visit_expr` when we write to `item_types`.
164-
/// 5. This is added by the code in `convert_item` when we write to `item_types`;
165-
/// note that this write occurs inside the `CollectItemSig` task.
166-
/// 6. Added by reads from within `op`.
167-
fn with_collect_item_sig(&self, id: ast::NodeId, op: fn(TyCtxt<'a, 'tcx, 'tcx>, ast::NodeId)) {
168-
let def_id = self.tcx.hir.local_def_id(id);
169-
self.tcx.dep_graph.with_task(DepNode::CollectItemSig(def_id), self.tcx, id, op);
170-
}
171-
}
172-
173128
impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
174129
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
175130
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
176131
}
177132

178133
fn visit_item(&mut self, item: &'tcx hir::Item) {
179-
self.with_collect_item_sig(item.id, convert_item);
134+
convert_item(self.tcx, item.id);
180135
intravisit::walk_item(self, item);
181136
}
182137

@@ -209,12 +164,12 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
209164
}
210165

211166
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
212-
self.with_collect_item_sig(trait_item.id, convert_trait_item);
167+
convert_trait_item(self.tcx, trait_item.id);
213168
intravisit::walk_trait_item(self, trait_item);
214169
}
215170

216171
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
217-
self.with_collect_item_sig(impl_item.id, convert_impl_item);
172+
convert_impl_item(self.tcx, impl_item.id);
218173
intravisit::walk_impl_item(self, impl_item);
219174
}
220175
}

src/librustc_typeck/impl_wf_check.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
//! fixed, but for the moment it's easier to do these checks early.
2020
2121
use constrained_type_params as ctp;
22-
use rustc::dep_graph::DepNode;
2322
use rustc::hir;
2423
use rustc::hir::itemlikevisit::ItemLikeVisitor;
2524
use rustc::hir::def_id::DefId;
@@ -63,7 +62,7 @@ pub fn impl_wf_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6362
// We will tag this as part of the WF check -- logically, it is,
6463
// but it's one that we must perform earlier than the rest of
6564
// WfCheck.
66-
tcx.visit_all_item_likes_in_krate(DepNode::WfCheck, &mut ImplWfCheck { tcx: tcx });
65+
tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx: tcx });
6766
}
6867

6968
struct ImplWfCheck<'a, 'tcx: 'a> {

0 commit comments

Comments
 (0)