about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-01 20:06:34 +0000
committerbors <bors@rust-lang.org>2021-10-01 20:06:34 +0000
commitc02371c442f811878ab3a0f5a813402b6dfd45d2 (patch)
treee293105dba102078f3039dba3ddc4f82f7c6c6bb /compiler/rustc_middle/src/ty/mod.rs
parentb6057bf7b7ee7c58e6a39ead02eaa13b75f908c2 (diff)
parent77c300285c0528241b2b08823167598739fc0f82 (diff)
downloadrust-c02371c442f811878ab3a0f5a813402b6dfd45d2.tar.gz
rust-c02371c442f811878ab3a0f5a813402b6dfd45d2.zip
Auto merge of #88880 - cjgillot:no-krate, r=oli-obk
Rework HIR API to make invocations of the hir_crate query harder.

`hir_crate` forces the recomputation of queries that depend on it.

This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
Diffstat (limited to 'compiler/rustc_middle/src/ty/mod.rs')
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs14
1 files changed, 0 insertions, 14 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index d04d1565fea..7a6012409db 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -29,10 +29,8 @@ use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
 use crate::ty::util::Discr;
 use rustc_ast as ast;
 use rustc_attr as attr;
-use rustc_data_structures::captures::Captures;
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
-use rustc_data_structures::sync::{self, par_iter, ParallelIterator};
 use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
 use rustc_hir as hir;
 use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
@@ -1696,18 +1694,6 @@ impl<'tcx> TyCtxt<'tcx> {
         self.typeck(self.hir().body_owner_def_id(body))
     }
 
-    /// Returns an iterator of the `DefId`s for all body-owners in this
-    /// crate. If you would prefer to iterate over the bodies
-    /// themselves, you can do `self.hir().krate().body_ids.iter()`.
-    pub fn body_owners(self) -> impl Iterator<Item = LocalDefId> + Captures<'tcx> + 'tcx {
-        self.hir().krate().bodies.keys().map(move |&body_id| self.hir().body_owner_def_id(body_id))
-    }
-
-    pub fn par_body_owners<F: Fn(LocalDefId) + sync::Sync + sync::Send>(self, f: F) {
-        par_iter(&self.hir().krate().bodies)
-            .for_each(|(&body_id, _)| f(self.hir().body_owner_def_id(body_id)));
-    }
-
     pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
         self.associated_items(id)
             .in_definition_order()