]> git.lizzy.rs Git - rust.git/commitdiff
Queryify check_impl_item_well_formed
authorWesley Wiser <wwiser@gmail.com>
Sat, 10 Mar 2018 22:17:30 +0000 (17:17 -0500)
committerWesley Wiser <wwiser@gmail.com>
Fri, 16 Mar 2018 03:11:09 +0000 (23:11 -0400)
Fixes #46753

src/librustc/dep_graph/dep_node.rs
src/librustc/ty/maps/mod.rs
src/librustc/ty/maps/plumbing.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/wfcheck.rs

index 9cb59da47bd9f96549b77dd60f7b1ec770867ea6..13cf7a9ec8f1ee4e8905dea3320e4cd37c32cf67 100644 (file)
@@ -581,6 +581,7 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
     [] ImplDefaultness(DefId),
     [] CheckItemWellFormed(DefId),
     [] CheckTraitItemWellFormed(DefId),
+    [] CheckImplItemWellFormed(DefId),
     [] ReachableNonGenerics(CrateNum),
     [] NativeLibraries(CrateNum),
     [] PluginRegistrarFn(CrateNum),
index 3e201560474472c3b25ed586141a2ac0a9568aaa..4dcd7c20c33d5d31848f585dcb1fa1a2e3eab4ec 100644 (file)
 
     [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
     [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
+    [] fn check_impl_item_well_formed: CheckImplItemWellFormed(DefId) -> (),
 
     // The DefIds of all non-generic functions and statics in the given crate
     // that can be reached from outside the crate.
index 2eba72a590e3acaaff6684c48e3041a77f0a766f..267d7da5e0c255e5b0752ac218f86c8f3b0531b2 100644 (file)
@@ -873,6 +873,7 @@ macro_rules! force {
         DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); }
         DepKind::CheckItemWellFormed => { force!(check_item_well_formed, def_id!()); }
         DepKind::CheckTraitItemWellFormed => { force!(check_trait_item_well_formed, def_id!()); }
+        DepKind::CheckImplItemWellFormed => { force!(check_impl_item_well_formed, def_id!()); }
         DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); }
         DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
         DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }
index 9ffe029468d3ea79b700ea159ef472c93a7f9d01..5b3a4529f1a099a77cad8dcddf982d79bf098a68 100644 (file)
@@ -726,6 +726,10 @@ fn check_trait_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
     wfcheck::CheckTypeWellFormed::new(tcx).check_trait_item(def_id);
 }
 
+fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
+    wfcheck::CheckTypeWellFormed::new(tcx).check_impl_item(def_id);
+}
+
 pub fn provide(providers: &mut Providers) {
     *providers = Providers {
         typeck_item_bodies,
@@ -735,6 +739,7 @@ pub fn provide(providers: &mut Providers) {
         used_trait_imports,
         check_item_well_formed,
         check_trait_item_well_formed,
+        check_impl_item_well_formed,
         ..*providers
     };
 }
index c80e0b8bba0666dd256c2510f8e142927d53c65e..72f40627b831af038013bcc9d5bdc51fd72ae42f 100644 (file)
@@ -171,6 +171,17 @@ pub fn check_trait_item(&mut self, def_id: DefId) {
             .check_associated_item(trait_item.id, trait_item.span, method_sig);
     }
 
+    pub fn check_impl_item(&mut self, def_id: DefId) {
+        let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
+        let impl_item = self.tcx.hir.expect_impl_item(node_id);
+
+        let method_sig = match impl_item.node {
+            hir::ImplItemKind::Method(ref sig, _) => Some(sig),
+            _ => None
+        };
+        self.check_associated_item(impl_item.id, impl_item.span, method_sig);
+    }
+
     fn check_associated_item(&mut self,
                              item_id: ast::NodeId,
                              span: Span,
@@ -694,12 +705,8 @@ fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) {
 
     fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) {
         debug!("visit_impl_item: {:?}", impl_item);
-        let method_sig = match impl_item.node {
-            hir::ImplItemKind::Method(ref sig, _) => Some(sig),
-            _ => None
-        };
-        CheckTypeWellFormed::new(self.tcx)
-            .check_associated_item(impl_item.id, impl_item.span, method_sig);
+        let def_id = self.tcx.hir.local_def_id(impl_item.id);
+        ty::maps::queries::check_impl_item_well_formed::ensure(self.tcx, def_id);
         intravisit::walk_impl_item(self, impl_item)
     }
 }