diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-01-26 12:18:32 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-01-29 21:10:34 +0100 |
| commit | 2a4eeba70f6c9017cf34936f9a49e05c31b575b5 (patch) | |
| tree | d0f4e4d2b6c63a42ffec95f97e9f24b9388f0f27 | |
| parent | 73b8f1d90ce75bea8e89b3572ff1e9943efcf436 (diff) | |
| download | rust-2a4eeba70f6c9017cf34936f9a49e05c31b575b5.tar.gz rust-2a4eeba70f6c9017cf34936f9a49e05c31b575b5.zip | |
Make impl_wf_check incremental
| -rw-r--r-- | src/librustc/dep_graph/dep_node.rs | 1 | ||||
| -rw-r--r-- | src/librustc/ty/query/config.rs | 9 | ||||
| -rw-r--r-- | src/librustc/ty/query/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/query/plumbing.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/impl_wf_check.rs | 19 | ||||
| -rw-r--r-- | src/librustc_typeck/lib.rs | 1 |
6 files changed, 32 insertions, 1 deletions
diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 05f331145af..cda469657ed 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -479,6 +479,7 @@ define_dep_nodes!( <'tcx> [] CheckModPrivacy(DefId), [] CheckModIntrinsics(DefId), [] CheckModLiveness(DefId), + [] CheckModImplWf(DefId), [] CollectModItemTypes(DefId), [] Reachability, diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index c4757574ffe..68dd5d533c8 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -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<'_, '_, '_>, diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 195bec11ee5..d4884e712b8 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -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. diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 783a4646540..26762f5d1f7 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -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); } diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index d5e15b28fb0..07f5fca6fe6 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -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}; @@ -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> { diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 5149f460bac..b51c2900399 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -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>) |
