Skip to content

Commit 29a39ab

Browse files
committed
move convert_impl_item into the main loop
This is better because the edges will be accounted to the impl item itself
1 parent 4a4c61b commit 29a39ab

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/librustc_typeck/collect.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CollectItemTypesVisitor<'a, 'tcx> {
151151
}
152152

153153
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
154-
// handled in `visit_item` above; we may want to break this out later
154+
convert_impl_item(self.ccx, impl_item);
155155
intravisit::walk_impl_item(self, impl_item);
156156
}
157157
}
@@ -792,10 +792,6 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
792792
}
793793
}
794794
}
795-
796-
for &impl_item_id in impl_item_ids {
797-
convert_impl_item(ccx, impl_item_id);
798-
}
799795
},
800796
hir::ItemTrait(.., ref trait_items) => {
801797
let trait_def = trait_def_of_item(ccx, it);
@@ -881,10 +877,12 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
881877
}
882878
}
883879

884-
fn convert_impl_item(ccx: &CrateCtxt, impl_item_id: hir::ImplItemId) {
880+
fn convert_impl_item(ccx: &CrateCtxt, impl_item: &hir::ImplItem) {
885881
let tcx = ccx.tcx;
886-
let impl_item = tcx.map.impl_item(impl_item_id);
887-
let impl_def_id = tcx.map.get_parent_did(impl_item_id.id);
882+
883+
// we can lookup details about the impl because items are visited
884+
// before impl-items
885+
let impl_def_id = tcx.map.get_parent_did(impl_item.id);
888886
let impl_predicates = tcx.item_predicates(impl_def_id);
889887
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
890888
let impl_self_ty = tcx.item_type(impl_def_id);

0 commit comments

Comments
 (0)