Skip to content

Commit fb968d2

Browse files
committed
rustc_typeck: Make CollectItemTypesVisitor descend into bodies as well
1 parent c91037b commit fb968d2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/librustc_typeck/collect.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use syntax::symbol::{Symbol, keywords};
8383
use syntax_pos::Span;
8484

8585
use rustc::hir::{self, map as hir_map, print as pprust};
86-
use rustc::hir::intravisit::{self, Visitor};
86+
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
8787
use rustc::hir::def::{Def, CtorKind};
8888
use rustc::hir::def_id::DefId;
8989

@@ -128,13 +128,17 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
128128
ccx: &'a CrateCtxt<'a, 'tcx>
129129
}
130130

131-
impl<'a, 'tcx, 'v> Visitor<'v> for CollectItemTypesVisitor<'a, 'tcx> {
132-
fn visit_item(&mut self, item: &hir::Item) {
131+
impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
132+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
133+
Some((&self.ccx.tcx.map, NestedVisitMode::OnlyBodies))
134+
}
135+
136+
fn visit_item(&mut self, item: &'tcx hir::Item) {
133137
convert_item(self.ccx, item);
134138
intravisit::walk_item(self, item);
135139
}
136140

137-
fn visit_expr(&mut self, expr: &hir::Expr) {
141+
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
138142
if let hir::ExprClosure(..) = expr.node {
139143
let def_id = self.ccx.tcx.map.local_def_id(expr.id);
140144
generics_of_def_id(self.ccx, def_id);
@@ -143,15 +147,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CollectItemTypesVisitor<'a, 'tcx> {
143147
intravisit::walk_expr(self, expr);
144148
}
145149

146-
fn visit_ty(&mut self, ty: &hir::Ty) {
150+
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
147151
if let hir::TyImplTrait(..) = ty.node {
148152
let def_id = self.ccx.tcx.map.local_def_id(ty.id);
149153
generics_of_def_id(self.ccx, def_id);
150154
}
151155
intravisit::walk_ty(self, ty);
152156
}
153157

154-
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
158+
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
155159
convert_impl_item(self.ccx, impl_item);
156160
intravisit::walk_impl_item(self, impl_item);
157161
}

0 commit comments

Comments
 (0)