diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-04 01:38:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-04 01:38:50 +0200 |
| commit | d7e42cc61c122c24a2503d7deebdaf00cb2aea23 (patch) | |
| tree | 2aaa155dc6d78fc25e5028801673132c9c3ac858 | |
| parent | 8867ba19de71f437956440eeda9cd45ca8f1dc8f (diff) | |
| parent | 8d6b1d10d48c3d189718c46c3b6441c2b7a0598b (diff) | |
| download | rust-d7e42cc61c122c24a2503d7deebdaf00cb2aea23.tar.gz rust-d7e42cc61c122c24a2503d7deebdaf00cb2aea23.zip | |
Rollup merge of #62268 - Zoxc:inherent_impls, r=eddyb
Clean up inherent_impls Split out from https://github.com/rust-lang/rust/pull/61923. r? @eddyb
| -rw-r--r-- | src/librustc_typeck/coherence/inherent_impls.rs | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index f208c6a138d..9efe1273ac0 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -7,7 +7,6 @@ //! `tcx.inherent_impls(def_id)`). That value, however, //! is computed by selecting an idea from this table. -use rustc::dep_graph::DepKind; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; @@ -36,35 +35,11 @@ pub fn crate_inherent_impls( pub fn inherent_impls(tcx: TyCtxt<'_>, ty_def_id: DefId) -> &[DefId] { assert!(ty_def_id.is_local()); - // NB. Until we adopt the red-green dep-tracking algorithm (see - // [the plan] for details on that), we do some hackery here to get - // the dependencies correct. Basically, we use a `with_ignore` to - // read the result we want. If we didn't have the `with_ignore`, - // we would wind up with a dependency on the entire crate, which - // we don't want. Then we go and add dependencies on all the impls - // in the result (which is what we wanted). - // - // The result is a graph with an edge from `Hir(I)` for every impl - // `I` defined on some type `T` to `CoherentInherentImpls(T)`, - // thus ensuring that if any of those impls change, the set of - // inherent impls is considered dirty. - // - // [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4 - - let result = tcx.dep_graph.with_ignore(|| { - let crate_map = tcx.crate_inherent_impls(ty_def_id.krate); - match crate_map.inherent_impls.get(&ty_def_id) { - Some(v) => &v[..], - None => &[], - } - }); - - for &impl_def_id in &result[..] { - let def_path_hash = tcx.def_path_hash(impl_def_id); - tcx.dep_graph.read(def_path_hash.to_dep_node(DepKind::Hir)); + let crate_map = tcx.crate_inherent_impls(ty_def_id.krate); + match crate_map.inherent_impls.get(&ty_def_id) { + Some(v) => &v[..], + None => &[], } - - result } struct InherentCollect<'tcx> { |
