]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_typeck/coherence/mod.rs
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / librustc_typeck / coherence / mod.rs
index b3ec10a8941dc753e69b3f72344cecfbdb2ba5bd..cdbfda40813b4648a4b356de34358ee80b5acdc1 100644 (file)
@@ -33,7 +33,7 @@ use middle::ty::TyProjection;
 use middle::ty::util::CopyImplementationError;
 use middle::free_region::FreeRegionMap;
 use CrateCtxt;
-use middle::infer::{self, InferCtxt, new_infer_ctxt};
+use middle::infer::{self, InferCtxt, TypeOrigin, new_infer_ctxt};
 use std::cell::RefCell;
 use std::rc::Rc;
 use syntax::codemap::Span;
@@ -41,7 +41,7 @@ use syntax::parse::token;
 use util::nodemap::{DefIdMap, FnvHashMap};
 use rustc::front::map as hir_map;
 use rustc::front::map::NodeItem;
-use rustc_front::visit;
+use rustc_front::intravisit;
 use rustc_front::hir::{Item, ItemImpl,Crate};
 use rustc_front::hir;
 
@@ -69,7 +69,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
         }
 
         TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
-        TyStr(..) | TyArray(..) | TySlice(..) | TyBareFn(..) | TyTuple(..) |
+        TyStr | TyArray(..) | TySlice(..) | TyBareFn(..) | TyTuple(..) |
         TyParam(..) | TyError |
         TyRawPtr(_) | TyRef(_, _) | TyProjection(..) => {
             None
@@ -96,13 +96,11 @@ struct CoherenceCheckVisitor<'a, 'tcx: 'a> {
     cc: &'a CoherenceChecker<'a, 'tcx>
 }
 
-impl<'a, 'tcx, 'v> visit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
+impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
     fn visit_item(&mut self, item: &Item) {
         if let ItemImpl(..) = item.node {
             self.cc.check_implementation(item)
         }
-
-        visit::walk_item(self, item);
     }
 }
 
@@ -111,8 +109,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
         // Check implementations and traits. This populates the tables
         // containing the inherent methods and extension methods. It also
         // builds up the trait inheritance table.
-        let mut visitor = CoherenceCheckVisitor { cc: self };
-        visit::walk_crate(&mut visitor, krate);
+        krate.visit_all_items(&mut CoherenceCheckVisitor { cc: self });
 
         // Copy over the inherent impls we gathered up during the walk into
         // the tcx.
@@ -196,13 +193,13 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
                 impl_items.iter().map(|impl_item| {
                     let impl_def_id = self.crate_context.tcx.map.local_def_id(impl_item.id);
                     match impl_item.node {
-                        hir::ConstImplItem(..) => {
+                        hir::ImplItemKind::Const(..) => {
                             ConstTraitItemId(impl_def_id)
                         }
-                        hir::MethodImplItem(..) => {
+                        hir::ImplItemKind::Method(..) => {
                             MethodTraitItemId(impl_def_id)
                         }
-                        hir::TypeImplItem(_) => {
+                        hir::ImplItemKind::Type(_) => {
                             TypeTraitItemId(impl_def_id)
                         }
                     }
@@ -409,7 +406,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
                         return;
                     }
 
-                    let origin = infer::Misc(span);
+                    let origin = TypeOrigin::Misc(span);
                     let fields = &def_a.struct_variant().fields;
                     let diff_fields = fields.iter().enumerate().filter_map(|(i, f)| {
                         let (a, b) = (f.ty(tcx, substs_a), f.ty(tcx, substs_b));