Skip to content

Commit 0783a2d

Browse files
authored
Rollup merge of #62268 - Zoxc:inherent_impls, r=eddyb
Clean up inherent_impls Split out from #61923. r? @eddyb
2 parents a46f705 + 8d6b1d1 commit 0783a2d

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

src/librustc_typeck/coherence/inherent_impls.rs

+4-29
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//! `tcx.inherent_impls(def_id)`). That value, however,
88
//! is computed by selecting an idea from this table.
99
10-
use rustc::dep_graph::DepKind;
1110
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
1211
use rustc::hir;
1312
use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -36,35 +35,11 @@ pub fn crate_inherent_impls<'tcx>(
3635
pub fn inherent_impls<'tcx>(tcx: TyCtxt<'tcx>, ty_def_id: DefId) -> &'tcx [DefId] {
3736
assert!(ty_def_id.is_local());
3837

39-
// NB. Until we adopt the red-green dep-tracking algorithm (see
40-
// [the plan] for details on that), we do some hackery here to get
41-
// the dependencies correct. Basically, we use a `with_ignore` to
42-
// read the result we want. If we didn't have the `with_ignore`,
43-
// we would wind up with a dependency on the entire crate, which
44-
// we don't want. Then we go and add dependencies on all the impls
45-
// in the result (which is what we wanted).
46-
//
47-
// The result is a graph with an edge from `Hir(I)` for every impl
48-
// `I` defined on some type `T` to `CoherentInherentImpls(T)`,
49-
// thus ensuring that if any of those impls change, the set of
50-
// inherent impls is considered dirty.
51-
//
52-
// [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4
53-
54-
let result = tcx.dep_graph.with_ignore(|| {
55-
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
56-
match crate_map.inherent_impls.get(&ty_def_id) {
57-
Some(v) => &v[..],
58-
None => &[],
59-
}
60-
});
61-
62-
for &impl_def_id in &result[..] {
63-
let def_path_hash = tcx.def_path_hash(impl_def_id);
64-
tcx.dep_graph.read(def_path_hash.to_dep_node(DepKind::Hir));
38+
let crate_map = tcx.crate_inherent_impls(ty_def_id.krate);
39+
match crate_map.inherent_impls.get(&ty_def_id) {
40+
Some(v) => &v[..],
41+
None => &[],
6542
}
66-
67-
result
6843
}
6944

7045
struct InherentCollect<'tcx> {

0 commit comments

Comments
 (0)