Move body_owners to tcx.hir().
This commit is contained in:
parent
db9fea508a
commit
abc57f63ad
7 changed files with 18 additions and 25 deletions
|
@ -491,6 +491,17 @@ impl<'hir> Map<'hir> {
|
|||
Some(ccx)
|
||||
}
|
||||
|
||||
/// 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> + 'hir {
|
||||
self.krate().bodies.keys().map(move |&body_id| self.body_owner_def_id(body_id))
|
||||
}
|
||||
|
||||
pub fn par_body_owners<F: Fn(LocalDefId) + Sync + Send>(self, f: F) {
|
||||
par_for_each_in(&self.krate().bodies, |(&body_id, _)| f(self.body_owner_def_id(body_id)));
|
||||
}
|
||||
|
||||
pub fn ty_param_owner(&self, id: HirId) -> HirId {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..) | ItemKind::TraitAlias(..), .. }) => id,
|
||||
|
|
|
@ -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};
|
||||
|
@ -1660,18 +1658,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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue