rename items -> free_items
This commit is contained in:
parent
1e926b50d7
commit
0dd8a83e5e
@ -148,7 +148,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
|
||||
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
for id in crate_items.free_items() {
|
||||
dirty_clean_visitor.check_item(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
|
@ -166,12 +166,12 @@ pub fn root_module(self) -> &'hir Mod<'hir> {
|
||||
|
||||
#[inline]
|
||||
pub fn items(self) -> impl Iterator<Item = ItemId> + 'hir {
|
||||
self.tcx.hir_crate_items(()).items.iter().copied()
|
||||
self.tcx.hir_crate_items(()).free_items.iter().copied()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn module_items(self, module: LocalModDefId) -> impl Iterator<Item = ItemId> + 'hir {
|
||||
self.tcx.hir_module_items(module).items()
|
||||
self.tcx.hir_module_items(module).free_items()
|
||||
}
|
||||
|
||||
pub fn def_key(self, def_id: LocalDefId) -> DefKey {
|
||||
@ -418,7 +418,7 @@ pub fn visit_all_item_likes_in_crate<V>(self, visitor: &mut V) -> V::Result
|
||||
V: Visitor<'hir>,
|
||||
{
|
||||
let krate = self.tcx.hir_crate_items(());
|
||||
walk_list!(visitor, visit_item, krate.items().map(|id| self.item(id)));
|
||||
walk_list!(visitor, visit_item, krate.free_items().map(|id| self.item(id)));
|
||||
walk_list!(visitor, visit_trait_item, krate.trait_items().map(|id| self.trait_item(id)));
|
||||
walk_list!(visitor, visit_impl_item, krate.impl_items().map(|id| self.impl_item(id)));
|
||||
walk_list!(
|
||||
@ -436,7 +436,7 @@ pub fn visit_item_likes_in_module<V>(self, module: LocalModDefId, visitor: &mut
|
||||
V: Visitor<'hir>,
|
||||
{
|
||||
let module = self.tcx.hir_module_items(module);
|
||||
walk_list!(visitor, visit_item, module.items().map(|id| self.item(id)));
|
||||
walk_list!(visitor, visit_item, module.free_items().map(|id| self.item(id)));
|
||||
walk_list!(visitor, visit_trait_item, module.trait_items().map(|id| self.trait_item(id)));
|
||||
walk_list!(visitor, visit_impl_item, module.impl_items().map(|id| self.impl_item(id)));
|
||||
walk_list!(
|
||||
@ -1197,7 +1197,7 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
|
||||
} = collector;
|
||||
return ModuleItems {
|
||||
submodules: submodules.into_boxed_slice(),
|
||||
items: items.into_boxed_slice(),
|
||||
free_items: items.into_boxed_slice(),
|
||||
trait_items: trait_items.into_boxed_slice(),
|
||||
impl_items: impl_items.into_boxed_slice(),
|
||||
foreign_items: foreign_items.into_boxed_slice(),
|
||||
@ -1226,7 +1226,7 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
|
||||
|
||||
return ModuleItems {
|
||||
submodules: submodules.into_boxed_slice(),
|
||||
items: items.into_boxed_slice(),
|
||||
free_items: items.into_boxed_slice(),
|
||||
trait_items: trait_items.into_boxed_slice(),
|
||||
impl_items: impl_items.into_boxed_slice(),
|
||||
foreign_items: foreign_items.into_boxed_slice(),
|
||||
|
@ -22,7 +22,7 @@
|
||||
#[derive(Debug, HashStable, Encodable, Decodable)]
|
||||
pub struct ModuleItems {
|
||||
submodules: Box<[OwnerId]>,
|
||||
items: Box<[ItemId]>,
|
||||
free_items: Box<[ItemId]>,
|
||||
trait_items: Box<[TraitItemId]>,
|
||||
impl_items: Box<[ImplItemId]>,
|
||||
foreign_items: Box<[ForeignItemId]>,
|
||||
@ -34,8 +34,10 @@ impl ModuleItems {
|
||||
///
|
||||
/// Note that this does *not* include associated items of `impl` blocks! It also does not
|
||||
/// include foreign items. If you want to e.g. get all functions, use `definitions()` below.
|
||||
pub fn items(&self) -> impl Iterator<Item = ItemId> + '_ {
|
||||
self.items.iter().copied()
|
||||
///
|
||||
/// However, this does include the `impl` blocks themselves.
|
||||
pub fn free_items(&self) -> impl Iterator<Item = ItemId> + '_ {
|
||||
self.free_items.iter().copied()
|
||||
}
|
||||
|
||||
pub fn trait_items(&self) -> impl Iterator<Item = TraitItemId> + '_ {
|
||||
@ -53,7 +55,7 @@ pub fn foreign_items(&self) -> impl Iterator<Item = ForeignItemId> + '_ {
|
||||
}
|
||||
|
||||
pub fn owners(&self) -> impl Iterator<Item = OwnerId> + '_ {
|
||||
self.items
|
||||
self.free_items
|
||||
.iter()
|
||||
.map(|id| id.owner_id)
|
||||
.chain(self.trait_items.iter().map(|id| id.owner_id))
|
||||
@ -69,7 +71,7 @@ pub fn par_items(
|
||||
&self,
|
||||
f: impl Fn(ItemId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
try_par_for_each_in(&self.items[..], |&id| f(id))
|
||||
try_par_for_each_in(&self.free_items[..], |&id| f(id))
|
||||
}
|
||||
|
||||
pub fn par_trait_items(
|
||||
|
@ -1526,7 +1526,7 @@ fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionStrategy) -> Vec<MonoI
|
||||
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
for id in crate_items.free_items() {
|
||||
collector.process_item(id);
|
||||
}
|
||||
|
||||
|
@ -831,7 +831,7 @@ fn create_and_seed_worklist(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
for id in crate_items.items() {
|
||||
for id in crate_items.free_items() {
|
||||
check_item(tcx, &mut worklist, &mut struct_constructors, &mut unsolved_impl_item, id);
|
||||
}
|
||||
|
||||
@ -1084,7 +1084,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
|
||||
let module_items = tcx.hir_module_items(module);
|
||||
|
||||
for item in module_items.items() {
|
||||
for item in module_items.free_items() {
|
||||
let def_kind = tcx.def_kind(item.owner_id);
|
||||
|
||||
let mut dead_codes = Vec::new();
|
||||
|
@ -437,7 +437,7 @@ fn reachable_set(tcx: TyCtxt<'_>, (): ()) -> LocalDefIdSet {
|
||||
// trait is a lang item.
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
for id in crate_items.free_items() {
|
||||
check_item(tcx, id, &mut reachable_context.worklist, effective_visibilities);
|
||||
}
|
||||
|
||||
|
@ -1696,7 +1696,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
|
||||
}
|
||||
}
|
||||
|
||||
for id in module.items() {
|
||||
for id in module.free_items() {
|
||||
if let ItemKind::Impl(i) = tcx.hir().item(id).kind {
|
||||
if let Some(item) = i.of_trait {
|
||||
let trait_ref = tcx.impl_trait_ref(id.owner_id.def_id).unwrap();
|
||||
|
@ -25,7 +25,7 @@ pub fn report_symbol_names(tcx: TyCtxt<'_>) {
|
||||
let mut symbol_names = SymbolNamesTest { tcx };
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
|
||||
for id in crate_items.items() {
|
||||
for id in crate_items.free_items() {
|
||||
symbol_names.process_attrs(id.owner_id.def_id);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ fn after_analysis<'tcx>(
|
||||
let mut bodies = Vec::new();
|
||||
|
||||
let crate_items = tcx.hir_crate_items(());
|
||||
for id in crate_items.items() {
|
||||
for id in crate_items.free_items() {
|
||||
if matches!(tcx.def_kind(id.owner_id), DefKind::Fn) {
|
||||
bodies.push(id.owner_id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user