]> git.lizzy.rs Git - rust.git/commitdiff
coherence: check builtin impls after the specialization graph is ready
authorAriel Ben-Yehuda <ariel.byd@gmail.com>
Sat, 3 Dec 2016 23:32:49 +0000 (01:32 +0200)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Tue, 3 Jan 2017 19:50:18 +0000 (21:50 +0200)
Fixes #33187.

src/librustc_typeck/coherence/mod.rs

index 316e6555b41ecc8590067a4adcc84e87be7f1059..6cf752dd69fcadea7d82f05ab89999e0c817c87a 100644 (file)
@@ -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 @@ fn get_base_type_def_id(&self, span: Span, ty: Ty<'tcx>) -> Option<DefId> {
         }
     }
 
-    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);
 }