Skip to content

Commit 3051f6e

Browse files
committed
rustc_metadata: Rename item_children(_untracked) to module_children(_untracked)
And `each_child_of_item` to `for_each_module_child`
1 parent 96c6a50 commit 3051f6e

File tree

14 files changed

+27
-22
lines changed

14 files changed

+27
-22
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10791079
/// including both proper items and reexports.
10801080
/// Module here is understood in name resolution sense - it can be a `mod` item,
10811081
/// or a crate root, or an enum, or a trait.
1082-
fn each_child_of_item(&self, id: DefIndex, mut callback: impl FnMut(Export), sess: &Session) {
1082+
fn for_each_module_child(
1083+
&self,
1084+
id: DefIndex,
1085+
mut callback: impl FnMut(Export),
1086+
sess: &Session,
1087+
) {
10831088
if let Some(data) = &self.root.proc_macro_data {
10841089
// If we are loading as a proc macro, we want to return
10851090
// the view of this crate as a proc macro crate.
@@ -1164,7 +1169,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11641169
}
11651170
}
11661171
EntryKind::Enum(..) | EntryKind::Trait(..) => {}
1167-
_ => bug!("`each_child_of_item` is called on a non-module: {:?}", self.def_kind(id)),
1172+
_ => bug!("`for_each_module_child` is called on a non-module: {:?}", self.def_kind(id)),
11681173
}
11691174
}
11701175

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
196196
let r = *cdata.dep_kind.lock();
197197
r
198198
}
199-
item_children => {
199+
module_children => {
200200
let mut result = SmallVec::<[_; 8]>::new();
201-
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
201+
cdata.for_each_module_child(def_id.index, |child| result.push(child), tcx.sess);
202202
tcx.arena.alloc_slice(&result)
203203
}
204204
defined_lib_features => { cdata.get_lib_features(tcx) }
@@ -342,7 +342,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
342342
};
343343

344344
while let Some(def) = bfs_queue.pop_front() {
345-
for child in tcx.item_children(def).iter() {
345+
for child in tcx.module_children(def).iter() {
346346
add_child(bfs_queue, child, def);
347347
}
348348
}
@@ -388,9 +388,9 @@ impl CStore {
388388
self.get_crate_data(def.krate).get_visibility(def.index)
389389
}
390390

391-
pub fn item_children_untracked(&self, def_id: DefId, sess: &Session) -> Vec<Export> {
391+
pub fn module_children_untracked(&self, def_id: DefId, sess: &Session) -> Vec<Export> {
392392
let mut result = vec![];
393-
self.get_crate_data(def_id.krate).each_child_of_item(
393+
self.get_crate_data(def_id.krate).for_each_module_child(
394394
def_id.index,
395395
|child| result.push(child),
396396
sess,

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ rustc_queries! {
15281528
desc { "fetching what a crate is named" }
15291529
separate_provide_extern
15301530
}
1531-
query item_children(def_id: DefId) -> &'tcx [Export] {
1531+
query module_children(def_id: DefId) -> &'tcx [Export] {
15321532
desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
15331533
separate_provide_extern
15341534
}

compiler/rustc_middle/src/ty/print/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ pub trait PrettyPrinter<'tcx>:
458458
// that's public and whose identifier isn't `_`.
459459
let reexport = self
460460
.tcx()
461-
.item_children(visible_parent)
461+
.module_children(visible_parent)
462462
.iter()
463463
.filter(|child| child.res.opt_def_id() == Some(def_id))
464464
.find(|child| child.vis.is_public() && child.ident.name != kw::Underscore)
@@ -2602,7 +2602,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
26022602

26032603
// Iterate external crate defs but be mindful about visibility
26042604
while let Some(def) = queue.pop() {
2605-
for child in tcx.item_children(def).iter() {
2605+
for child in tcx.module_children(def).iter() {
26062606
if !child.vis.is_public() {
26072607
continue;
26082608
}

compiler/rustc_resolve/src/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl<'a> Resolver<'a> {
214214
}
215215

216216
crate fn build_reduced_graph_external(&mut self, module: Module<'a>) {
217-
for child in self.cstore().item_children_untracked(module.def_id(), self.session) {
217+
for child in self.cstore().module_children_untracked(module.def_id(), self.session) {
218218
let parent_scope = ParentScope::module(module, self);
219219
BuildReducedGraphVisitor { r: self, parent_scope }
220220
.build_reduced_graph_for_external_crate_res(child);

compiler/rustc_typeck/src/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13211321
if Some(*parent_did) != self.tcx.parent(*trait_did)
13221322
&& self
13231323
.tcx
1324-
.item_children(*parent_did)
1324+
.module_children(*parent_did)
13251325
.iter()
13261326
.filter(|child| child.res.opt_def_id() == Some(*trait_did))
13271327
.all(|child| child.ident.name == kw::Underscore)

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ fn build_module(
516516
// If we're re-exporting a re-export it may actually re-export something in
517517
// two namespaces, so the target may be listed twice. Make sure we only
518518
// visit each node at most once.
519-
for &item in cx.tcx.item_children(did).iter() {
519+
for &item in cx.tcx.module_children(did).iter() {
520520
if item.vis.is_public() {
521521
let res = item.res.expect_non_local();
522522
if let Some(def_id) = res.mod_def_id() {

src/librustdoc/clean/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl ExternalCrate {
265265
})
266266
.collect()
267267
} else {
268-
tcx.item_children(root).iter().map(|item| item.res).filter_map(as_keyword).collect()
268+
tcx.module_children(root).iter().map(|item| item.res).filter_map(as_keyword).collect()
269269
}
270270
}
271271

@@ -333,7 +333,7 @@ impl ExternalCrate {
333333
})
334334
.collect()
335335
} else {
336-
tcx.item_children(root).iter().map(|item| item.res).filter_map(as_primitive).collect()
336+
tcx.module_children(root).iter().map(|item| item.res).filter_map(as_primitive).collect()
337337
}
338338
}
339339
}

src/librustdoc/visit_lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
5353
return;
5454
}
5555

56-
for item in self.tcx.item_children(def_id).iter() {
56+
for item in self.tcx.module_children(def_id).iter() {
5757
if let Some(def_id) = item.res.opt_def_id() {
5858
if self.tcx.def_key(def_id).parent.map_or(false, |d| d == def_id.index)
5959
|| item.vis.is_public()

src/tools/clippy/clippy_lints/src/macro_use.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
9696
if let Res::Def(DefKind::Mod, id) = path.res;
9797
if !id.is_local();
9898
then {
99-
for kid in cx.tcx.item_children(id).iter() {
99+
for kid in cx.tcx.module_children(id).iter() {
100100
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
101101
let span = mac_attr.span;
102102
let def_path = cx.tcx.def_path_str(mac_id);

src/tools/clippy/clippy_lints/src/utils/internal_lints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
924924
let lang_item_path = cx.get_def_path(*item_def_id);
925925
if path_syms.starts_with(&lang_item_path) {
926926
if let [item] = &path_syms[lang_item_path.len()..] {
927-
for child in cx.tcx.item_children(*item_def_id) {
927+
for child in cx.tcx.module_children(*item_def_id) {
928928
if child.ident.name == *item {
929929
return true;
930930
}
@@ -984,7 +984,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
984984

985985
for &module in &[&paths::KW_MODULE, &paths::SYM_MODULE] {
986986
if let Some(def_id) = path_to_res(cx, module).opt_def_id() {
987-
for item in cx.tcx.item_children(def_id).iter() {
987+
for item in cx.tcx.module_children(def_id).iter() {
988988
if_chain! {
989989
if let Res::Def(DefKind::Const, item_def_id) = item.res;
990990
let ty = cx.tcx.type_of(item_def_id);

src/tools/clippy/clippy_utils/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
525525
fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<Res> {
526526
match tcx.def_kind(def_id) {
527527
DefKind::Mod | DefKind::Enum | DefKind::Trait => tcx
528-
.item_children(def_id)
528+
.module_children(def_id)
529529
.iter()
530530
.find(|item| item.ident.name.as_str() == name)
531531
.map(|child| child.res.expect_non_local()),

src/tools/clippy/tests/ui/macro_use_imports.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mod a {
4040
}
4141
}
4242

43-
// issue #7015, ICE due to calling `item_children` with local `DefId`
43+
// issue #7015, ICE due to calling `module_children` with local `DefId`
4444
#[macro_use]
4545
use a as b;
4646

src/tools/clippy/tests/ui/macro_use_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mod a {
4040
}
4141
}
4242

43-
// issue #7015, ICE due to calling `item_children` with local `DefId`
43+
// issue #7015, ICE due to calling `module_children` with local `DefId`
4444
#[macro_use]
4545
use a as b;
4646

0 commit comments

Comments
 (0)