about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2016-12-04 01:32:49 +0200
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-01-03 21:50:18 +0200
commitd938ba47699a1539b00cbc59e6fc647010df340a (patch)
tree685ef744810ac9926d35756cc94bf47b936de2a1
parent7309babf1773cde3ee6d9e5ef2b177b44278a809 (diff)
coherence: check builtin impls after the specialization graph is ready
Fixes #33187.
-rw-r--r--src/librustc_typeck/coherence/mod.rs16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs
index 316e6555b41..6cf752dd69f 100644
--- a/src/librustc_typeck/coherence/mod.rs
+++ b/src/librustc_typeck/coherence/mod.rs
@@ -39,14 +39,10 @@ struct CoherenceChecker<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
-struct CoherenceCheckVisitor<'a, 'tcx: 'a> {
-    cc: &'a CoherenceChecker<'a, 'tcx>,
-}
-
-impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
+impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CoherenceChecker<'a, 'tcx> {
     fn visit_item(&mut self, item: &Item) {
         if let ItemImpl(..) = item.node {
-            self.cc.check_implementation(item)
+            self.check_implementation(item)
         }
     }
 
@@ -81,14 +77,11 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
         }
     }
 
-    fn check(&self) {
+    fn check(&mut self) {
         // Check implementations and traits. This populates the tables
         // containing the inherent methods and extension methods. It also
         // builds up the trait inheritance table.
-        self.tcx.visit_all_item_likes_in_krate(
-            DepNode::CoherenceCheckImpl,
-            &mut CoherenceCheckVisitor { cc: self });
-        builtin::check(self.tcx);
+        self.tcx.visit_all_item_likes_in_krate(DepNode::CoherenceCheckImpl, self);
     }
 
     fn check_implementation(&self, item: &Item) {
@@ -174,4 +167,5 @@ pub fn check_coherence(ccx: &CrateCtxt) {
     unsafety::check(ccx.tcx);
     orphan::check(ccx.tcx);
     overlap::check(ccx.tcx);
+    builtin::check(ccx.tcx);
 }