Skip to content

Commit

Permalink
Make impl_wf_check incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Jan 29, 2019
1 parent 73b8f1d commit 2a4eeba
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/librustc/dep_graph/dep_node.rs
Expand Up @@ -479,6 +479,7 @@ define_dep_nodes!( <'tcx>
[] CheckModPrivacy(DefId),
[] CheckModIntrinsics(DefId),
[] CheckModLiveness(DefId),
[] CheckModImplWf(DefId),
[] CollectModItemTypes(DefId),

[] Reachability,
Expand Down
9 changes: 9 additions & 0 deletions src/librustc/ty/query/config.rs
Expand Up @@ -136,6 +136,15 @@ impl<'tcx> QueryDescription<'tcx> for queries::check_mod_liveness<'tcx> {
}
}

impl<'tcx> QueryDescription<'tcx> for queries::check_mod_impl_wf<'tcx> {
fn describe(
tcx: TyCtxt<'_, '_, '_>,
key: DefId,
) -> Cow<'static, str> {
format!("checking that impls are well-formed in {}", key.describe_as_module(tcx)).into()
}
}

impl<'tcx> QueryDescription<'tcx> for queries::collect_mod_item_types<'tcx> {
fn describe(
tcx: TyCtxt<'_, '_, '_>,
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/ty/query/mod.rs
Expand Up @@ -270,6 +270,8 @@ define_queries! { <'tcx>

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

[] fn check_mod_impl_wf: CheckModImplWf(DefId) -> (),

[] fn collect_mod_item_types: CollectModItemTypes(DefId) -> (),

/// Caches CoerceUnsized kinds for impls on custom types.
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/query/plumbing.rs
Expand Up @@ -1260,6 +1260,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind::CheckModPrivacy => { force!(check_mod_privacy, def_id!()); }
DepKind::CheckModIntrinsics => { force!(check_mod_intrinsics, def_id!()); }
DepKind::CheckModLiveness => { force!(check_mod_liveness, def_id!()); }
DepKind::CheckModImplWf => { force!(check_mod_impl_wf, def_id!()); }
DepKind::CollectModItemTypes => { force!(collect_mod_item_types, def_id!()); }
DepKind::Reachability => { force!(reachable_set, LOCAL_CRATE); }
DepKind::MirKeys => { force!(mir_keys, LOCAL_CRATE); }
Expand Down
19 changes: 18 additions & 1 deletion src/librustc_typeck/impl_wf_check.rs
Expand Up @@ -13,6 +13,7 @@ use rustc::hir;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::def_id::DefId;
use rustc::ty::{self, TyCtxt};
use rustc::ty::query::Providers;
use rustc::util::nodemap::{FxHashMap, FxHashSet};
use std::collections::hash_map::Entry::{Occupied, Vacant};

Expand Down Expand Up @@ -52,7 +53,23 @@ pub fn impl_wf_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
// We will tag this as part of the WF check -- logically, it is,
// but it's one that we must perform earlier than the rest of
// WfCheck.
tcx.hir().krate().visit_all_item_likes(&mut ImplWfCheck { tcx });
for &module in tcx.hir().krate().modules.keys() {
tcx.ensure().check_mod_impl_wf(tcx.hir().local_def_id(module));
}
}

fn check_mod_impl_wf<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut ImplWfCheck { tcx }
);
}

pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
check_mod_impl_wf,
..*providers
};
}

struct ImplWfCheck<'a, 'tcx: 'a> {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/lib.rs
Expand Up @@ -318,6 +318,7 @@ pub fn provide(providers: &mut Providers) {
check::provide(providers);
variance::provide(providers);
outlives::provide(providers);
impl_wf_check::provide(providers);
}

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

0 comments on commit 2a4eeba

Please sign in to comment.