Skip to content

Commit f704ef5

Browse files
committed
simplify check-item-types too
1 parent 384f044 commit f704ef5

File tree

1 file changed

+5
-30
lines changed
  • src/librustc_typeck/check

1 file changed

+5
-30
lines changed

src/librustc_typeck/check/mod.rs

+5-30
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ use syntax::util::lev_distance::find_best_match_for_name;
118118
use syntax_pos::{self, BytePos, Span, DUMMY_SP};
119119

120120
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
121+
use rustc::hir::itemlikevisit::ItemLikeVisitor;
121122
use rustc::hir::{self, PatKind};
122123
use rustc::middle::lang_items;
123124
use rustc_back::slice;
@@ -515,37 +516,12 @@ impl<'a, 'gcx, 'tcx> Inherited<'a, 'gcx, 'tcx> {
515516

516517
struct CheckItemTypesVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> }
517518

518-
impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
519-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
520-
NestedVisitorMap::OnlyBodies(&self.tcx.hir)
521-
}
522-
519+
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
523520
fn visit_item(&mut self, i: &'tcx hir::Item) {
524521
check_item_type(self.tcx, i);
525-
intravisit::walk_item(self, i);
526-
}
527-
528-
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
529-
match t.node {
530-
hir::TyArray(_, length) => {
531-
self.tcx.item_tables(self.tcx.hir.local_def_id(length.node_id));
532-
}
533-
_ => {}
534-
}
535-
536-
intravisit::walk_ty(self, t);
537-
}
538-
539-
fn visit_expr(&mut self, e: &'tcx hir::Expr) {
540-
match e.node {
541-
hir::ExprRepeat(_, count) => {
542-
self.tcx.item_tables(self.tcx.hir.local_def_id(count.node_id));
543-
}
544-
_ => {}
545-
}
546-
547-
intravisit::walk_expr(self, e);
548522
}
523+
fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) { }
524+
fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) { }
549525
}
550526

551527
pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
@@ -557,9 +533,8 @@ pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
557533

558534
pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult {
559535
tcx.sess.track_errors(|| {
560-
let mut visit = CheckItemTypesVisitor { tcx: tcx };
561536
tcx.visit_all_item_likes_in_krate(DepNode::TypeckItemType,
562-
&mut visit.as_deep_visitor());
537+
&mut CheckItemTypesVisitor { tcx });
563538
})
564539
}
565540

0 commit comments

Comments
 (0)