Skip to content

Commit eeb45c7

Browse files
committed
make distinct Hir() nodes in the graph for impl items
1 parent 3fd67eb commit eeb45c7

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/librustc/dep_graph/visit.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>
4747
}
4848

4949
fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) {
50-
// TODO -- use the def-id of the impl for now
51-
let impl_def_id = self.tcx.map.get_parent_did(i.id);
52-
let task_id = (self.dep_node_fn)(impl_def_id);
50+
let impl_item_def_id = self.tcx.map.local_def_id(i.id);
51+
let task_id = (self.dep_node_fn)(impl_item_def_id);
5352
let _task = self.tcx.dep_graph.in_task(task_id.clone());
5453
debug!("Started task {:?}", task_id);
55-
assert!(!self.tcx.map.is_inlined_def_id(impl_def_id));
56-
self.tcx.dep_graph.read(DepNode::Hir(impl_def_id));
54+
assert!(!self.tcx.map.is_inlined_def_id(impl_item_def_id));
55+
self.tcx.dep_graph.read(DepNode::Hir(impl_item_def_id));
5756
self.visitor.visit_impl_item(i);
5857
debug!("Ended task {:?}", task_id);
5958
}

src/librustc/hir/map/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,14 @@ impl<'ast> Map<'ast> {
254254
return DepNode::Hir(def_id);
255255
}
256256

257+
EntryImplItem(..) => {
258+
let def_id = self.local_def_id(id);
259+
assert!(!self.is_inlined_def_id(def_id));
260+
return DepNode::Hir(def_id);
261+
}
262+
257263
EntryForeignItem(p, _) |
258264
EntryTraitItem(p, _) |
259-
EntryImplItem(p, _) |
260265
EntryVariant(p, _) |
261266
EntryExpr(p, _) |
262267
EntryStmt(p, _) |
@@ -379,7 +384,6 @@ impl<'ast> Map<'ast> {
379384
}
380385

381386
pub fn impl_item(&self, id: ImplItemId) -> &'ast ImplItem {
382-
// TODO right now this triggers a read of the whole impl
383387
self.read(id.id);
384388

385389
// NB: intentionally bypass `self.forest.krate()` so that we

src/librustc_incremental/calculate_svh/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ impl<'a, 'tcx> Visitor<'tcx> for HashItemsVisitor<'a, 'tcx> {
207207
visit::walk_item(self, item);
208208
}
209209

210+
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
211+
self.calculate_node_id(impl_item.id, |v| v.visit_impl_item(impl_item));
212+
visit::walk_impl_item(self, impl_item);
213+
}
214+
210215
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
211216
self.calculate_node_id(item.id, |v| v.visit_foreign_item(item));
212217
visit::walk_foreign_item(self, item);

src/librustc_incremental/calculate_svh/svh_visitor.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,8 @@ impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'has
503503
// Each item is hashed independently; ignore nested items.
504504
}
505505

506-
fn visit_nested_impl_item(&mut self, impl_item_id: ImplItemId) {
507-
// For now, we hash impl items as part of the containing impl.
508-
let impl_item = self.tcx.map.impl_item(impl_item_id);
509-
self.visit_impl_item(impl_item);
506+
fn visit_nested_impl_item(&mut self, _: ImplItemId) {
507+
// Impl items are hashed independently; ignore nested impl items.
510508
}
511509

512510
fn visit_variant_data(&mut self,

0 commit comments

Comments
 (0)