about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2018-03-10 11:25:03 -0500
committerWesley Wiser <wwiser@gmail.com>2018-03-15 23:11:09 -0400
commitedbd02fd35ffd3724a415c05c21e4e4fc5575e1e (patch)
treef707872bf972adcf3f7bdc6ef1a3e40daf652067 /src
parent86a123c2fd018905fca7af94a352227fe97e1623 (diff)
downloadrust-edbd02fd35ffd3724a415c05c21e4e4fc5575e1e.tar.gz
rust-edbd02fd35ffd3724a415c05c21e4e4fc5575e1e.zip
Queryify check_trait_item_well_formed
Fixes #46753
Diffstat (limited to 'src')
-rw-r--r--src/librustc/dep_graph/dep_node.rs1
-rw-r--r--src/librustc/ty/maps/mod.rs1
-rw-r--r--src/librustc/ty/maps/plumbing.rs1
-rw-r--r--src/librustc_typeck/check/mod.rs5
-rw-r--r--src/librustc_typeck/check/wfcheck.rs20
5 files changed, 22 insertions, 6 deletions
diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs
index 20c3fb50157..9cb59da47bd 100644
--- a/src/librustc/dep_graph/dep_node.rs
+++ b/src/librustc/dep_graph/dep_node.rs
@@ -580,6 +580,7 @@ define_dep_nodes!( <'tcx>
     [] IsNoBuiltins(CrateNum),
     [] ImplDefaultness(DefId),
     [] CheckItemWellFormed(DefId),
+    [] CheckTraitItemWellFormed(DefId),
     [] ReachableNonGenerics(CrateNum),
     [] NativeLibraries(CrateNum),
     [] PluginRegistrarFn(CrateNum),
diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs
index 8f4100ad5f7..3e201560474 100644
--- a/src/librustc/ty/maps/mod.rs
+++ b/src/librustc/ty/maps/mod.rs
@@ -299,6 +299,7 @@ define_maps! { <'tcx>
     [] 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.
diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs
index 732c91ea98a..2eba72a590e 100644
--- a/src/librustc/ty/maps/plumbing.rs
+++ b/src/librustc/ty/maps/plumbing.rs
@@ -872,6 +872,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
         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!()); }
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index a6b307b8414..9ffe029468d 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -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
     };
 }
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index d665e55898d..c80e0b8bba0 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -159,6 +159,18 @@ impl<'a, 'gcx> CheckTypeWellFormed<'a, 'gcx> {
         }
     }
 
+    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 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'a, 'tcx> {
 
     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)
     }