Skip to content

Commit 2a4eeba

Browse files
committed
Make impl_wf_check incremental
1 parent 73b8f1d commit 2a4eeba

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ define_dep_nodes!( <'tcx>
479479
[] CheckModPrivacy(DefId),
480480
[] CheckModIntrinsics(DefId),
481481
[] CheckModLiveness(DefId),
482+
[] CheckModImplWf(DefId),
482483
[] CollectModItemTypes(DefId),
483484

484485
[] Reachability,

src/librustc/ty/query/config.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ impl<'tcx> QueryDescription<'tcx> for queries::check_mod_liveness<'tcx> {
136136
}
137137
}
138138

139+
impl<'tcx> QueryDescription<'tcx> for queries::check_mod_impl_wf<'tcx> {
140+
fn describe(
141+
tcx: TyCtxt<'_, '_, '_>,
142+
key: DefId,
143+
) -> Cow<'static, str> {
144+
format!("checking that impls are well-formed in {}", key.describe_as_module(tcx)).into()
145+
}
146+
}
147+
139148
impl<'tcx> QueryDescription<'tcx> for queries::collect_mod_item_types<'tcx> {
140149
fn describe(
141150
tcx: TyCtxt<'_, '_, '_>,

src/librustc/ty/query/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ define_queries! { <'tcx>
270270

271271
[] fn check_mod_liveness: CheckModLiveness(DefId) -> (),
272272

273+
[] fn check_mod_impl_wf: CheckModImplWf(DefId) -> (),
274+
273275
[] fn collect_mod_item_types: CollectModItemTypes(DefId) -> (),
274276

275277
/// Caches CoerceUnsized kinds for impls on custom types.

src/librustc/ty/query/plumbing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
12601260
DepKind::CheckModPrivacy => { force!(check_mod_privacy, def_id!()); }
12611261
DepKind::CheckModIntrinsics => { force!(check_mod_intrinsics, def_id!()); }
12621262
DepKind::CheckModLiveness => { force!(check_mod_liveness, def_id!()); }
1263+
DepKind::CheckModImplWf => { force!(check_mod_impl_wf, def_id!()); }
12631264
DepKind::CollectModItemTypes => { force!(collect_mod_item_types, def_id!()); }
12641265
DepKind::Reachability => { force!(reachable_set, LOCAL_CRATE); }
12651266
DepKind::MirKeys => { force!(mir_keys, LOCAL_CRATE); }

src/librustc_typeck/impl_wf_check.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc::hir;
1313
use rustc::hir::itemlikevisit::ItemLikeVisitor;
1414
use rustc::hir::def_id::DefId;
1515
use rustc::ty::{self, TyCtxt};
16+
use rustc::ty::query::Providers;
1617
use rustc::util::nodemap::{FxHashMap, FxHashSet};
1718
use std::collections::hash_map::Entry::{Occupied, Vacant};
1819

@@ -52,7 +53,23 @@ pub fn impl_wf_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
5253
// We will tag this as part of the WF check -- logically, it is,
5354
// but it's one that we must perform earlier than the rest of
5455
// WfCheck.
55-
tcx.hir().krate().visit_all_item_likes(&mut ImplWfCheck { tcx });
56+
for &module in tcx.hir().krate().modules.keys() {
57+
tcx.ensure().check_mod_impl_wf(tcx.hir().local_def_id(module));
58+
}
59+
}
60+
61+
fn check_mod_impl_wf<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
62+
tcx.hir().visit_item_likes_in_module(
63+
module_def_id,
64+
&mut ImplWfCheck { tcx }
65+
);
66+
}
67+
68+
pub fn provide(providers: &mut Providers<'_>) {
69+
*providers = Providers {
70+
check_mod_impl_wf,
71+
..*providers
72+
};
5673
}
5774

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

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ pub fn provide(providers: &mut Providers) {
318318
check::provide(providers);
319319
variance::provide(providers);
320320
outlives::provide(providers);
321+
impl_wf_check::provide(providers);
321322
}
322323

323324
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)

0 commit comments

Comments
 (0)