]> git.lizzy.rs Git - rust.git/commitdiff
Queryify check_trait_item_well_formed
authorWesley Wiser <wwiser@gmail.com>
Sat, 10 Mar 2018 16:25:03 +0000 (11:25 -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 20c3fb501572c84d7c05908133254a3ec6af6b2f..9cb59da47bd9f96549b77dd60f7b1ec770867ea6 100644 (file)
@@ -580,6 +580,7 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
     [] IsNoBuiltins(CrateNum),
     [] ImplDefaultness(DefId),
     [] CheckItemWellFormed(DefId),
+    [] CheckTraitItemWellFormed(DefId),
     [] ReachableNonGenerics(CrateNum),
     [] NativeLibraries(CrateNum),
     [] PluginRegistrarFn(CrateNum),
index 8f4100ad5f703e327f171c70308f102c4bdb5654..3e201560474472c3b25ed586141a2ac0a9568aaa 100644 (file)
     [] fn impl_defaultness: ImplDefaultness(DefId) -> hir::Defaultness,
 
     [] fn check_item_well_formed: CheckItemWellFormed(DefId) -> (),
+    [] fn check_trait_item_well_formed: CheckTraitItemWellFormed(DefId) -> (),
 
     // The DefIds of all non-generic functions and statics in the given crate
     // that can be reached from outside the crate.
index 732c91ea98aa6e45b28234e61b141f9c0e3e3e62..2eba72a590e3acaaff6684c48e3041a77f0a766f 100644 (file)
@@ -872,6 +872,7 @@ macro_rules! force {
         DepKind::IsNoBuiltins => { force!(is_no_builtins, krate!()); }
         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::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); }
         DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
         DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }
index a6b307b841490d2cece5ea9d7af509ee8f525c3f..9ffe029468d3ea79b700ea159ef472c93a7f9d01 100644 (file)
@@ -722,6 +722,10 @@ fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
     wfcheck::CheckTypeWellFormed::new(tcx).check_item_well_formed(def_id);
 }
 
+fn check_trait_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
+    wfcheck::CheckTypeWellFormed::new(tcx).check_trait_item(def_id);
+}
+
 pub fn provide(providers: &mut Providers) {
     *providers = Providers {
         typeck_item_bodies,
@@ -730,6 +734,7 @@ pub fn provide(providers: &mut Providers) {
         adt_destructor,
         used_trait_imports,
         check_item_well_formed,
+        check_trait_item_well_formed,
         ..*providers
     };
 }
index d665e55898d4a6eda658851b15517a1cdf04506d..c80e0b8bba0666dd256c2510f8e142927d53c65e 100644 (file)
@@ -159,6 +159,18 @@ pub fn check_item_well_formed(&mut self, def_id: DefId) {
         }
     }
 
+    pub fn check_trait_item(&mut self, def_id: DefId) {
+        let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
+        let trait_item = self.tcx.hir.expect_trait_item(node_id);
+
+        let method_sig = match trait_item.node {
+            hir::TraitItemKind::Method(ref sig, _) => Some(sig),
+            _ => None
+        };
+        CheckTypeWellFormed::new(self.tcx)
+            .check_associated_item(trait_item.id, trait_item.span, method_sig);
+    }
+
     fn check_associated_item(&mut self,
                              item_id: ast::NodeId,
                              span: Span,
@@ -675,12 +687,8 @@ fn visit_item(&mut self, i: &hir::Item) {
 
     fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) {
         debug!("visit_trait_item: {:?}", trait_item);
-        let method_sig = match trait_item.node {
-            hir::TraitItemKind::Method(ref sig, _) => Some(sig),
-            _ => None
-        };
-        CheckTypeWellFormed::new(self.tcx)
-            .check_associated_item(trait_item.id, trait_item.span, method_sig);
+        let def_id = self.tcx.hir.local_def_id(trait_item.id);
+        ty::maps::queries::check_trait_item_well_formed::ensure(self.tcx, def_id);
         intravisit::walk_trait_item(self, trait_item)
     }