rustc_metadata: Rename item_children(_untracked)
to module_children(_untracked)
And `each_child_of_item` to `for_each_module_child`
This commit is contained in:
parent
96c6a50e96
commit
3051f6e9c4
14 changed files with 27 additions and 22 deletions
|
@ -1079,7 +1079,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
/// including both proper items and reexports.
|
/// including both proper items and reexports.
|
||||||
/// Module here is understood in name resolution sense - it can be a `mod` item,
|
/// Module here is understood in name resolution sense - it can be a `mod` item,
|
||||||
/// or a crate root, or an enum, or a trait.
|
/// or a crate root, or an enum, or a trait.
|
||||||
fn each_child_of_item(&self, id: DefIndex, mut callback: impl FnMut(Export), sess: &Session) {
|
fn for_each_module_child(
|
||||||
|
&self,
|
||||||
|
id: DefIndex,
|
||||||
|
mut callback: impl FnMut(Export),
|
||||||
|
sess: &Session,
|
||||||
|
) {
|
||||||
if let Some(data) = &self.root.proc_macro_data {
|
if let Some(data) = &self.root.proc_macro_data {
|
||||||
// If we are loading as a proc macro, we want to return
|
// If we are loading as a proc macro, we want to return
|
||||||
// the view of this crate as a proc macro crate.
|
// the view of this crate as a proc macro crate.
|
||||||
|
@ -1164,7 +1169,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EntryKind::Enum(..) | EntryKind::Trait(..) => {}
|
EntryKind::Enum(..) | EntryKind::Trait(..) => {}
|
||||||
_ => bug!("`each_child_of_item` is called on a non-module: {:?}", self.def_kind(id)),
|
_ => bug!("`for_each_module_child` is called on a non-module: {:?}", self.def_kind(id)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,9 +196,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
let r = *cdata.dep_kind.lock();
|
let r = *cdata.dep_kind.lock();
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
item_children => {
|
module_children => {
|
||||||
let mut result = SmallVec::<[_; 8]>::new();
|
let mut result = SmallVec::<[_; 8]>::new();
|
||||||
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
|
cdata.for_each_module_child(def_id.index, |child| result.push(child), tcx.sess);
|
||||||
tcx.arena.alloc_slice(&result)
|
tcx.arena.alloc_slice(&result)
|
||||||
}
|
}
|
||||||
defined_lib_features => { cdata.get_lib_features(tcx) }
|
defined_lib_features => { cdata.get_lib_features(tcx) }
|
||||||
|
@ -342,7 +342,7 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
|
||||||
};
|
};
|
||||||
|
|
||||||
while let Some(def) = bfs_queue.pop_front() {
|
while let Some(def) = bfs_queue.pop_front() {
|
||||||
for child in tcx.item_children(def).iter() {
|
for child in tcx.module_children(def).iter() {
|
||||||
add_child(bfs_queue, child, def);
|
add_child(bfs_queue, child, def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,9 +388,9 @@ impl CStore {
|
||||||
self.get_crate_data(def.krate).get_visibility(def.index)
|
self.get_crate_data(def.krate).get_visibility(def.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item_children_untracked(&self, def_id: DefId, sess: &Session) -> Vec<Export> {
|
pub fn module_children_untracked(&self, def_id: DefId, sess: &Session) -> Vec<Export> {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
self.get_crate_data(def_id.krate).each_child_of_item(
|
self.get_crate_data(def_id.krate).for_each_module_child(
|
||||||
def_id.index,
|
def_id.index,
|
||||||
|child| result.push(child),
|
|child| result.push(child),
|
||||||
sess,
|
sess,
|
||||||
|
|
|
@ -1528,7 +1528,7 @@ rustc_queries! {
|
||||||
desc { "fetching what a crate is named" }
|
desc { "fetching what a crate is named" }
|
||||||
separate_provide_extern
|
separate_provide_extern
|
||||||
}
|
}
|
||||||
query item_children(def_id: DefId) -> &'tcx [Export] {
|
query module_children(def_id: DefId) -> &'tcx [Export] {
|
||||||
desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
|
desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
|
||||||
separate_provide_extern
|
separate_provide_extern
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,7 +458,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
// that's public and whose identifier isn't `_`.
|
// that's public and whose identifier isn't `_`.
|
||||||
let reexport = self
|
let reexport = self
|
||||||
.tcx()
|
.tcx()
|
||||||
.item_children(visible_parent)
|
.module_children(visible_parent)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|child| child.res.opt_def_id() == Some(def_id))
|
.filter(|child| child.res.opt_def_id() == Some(def_id))
|
||||||
.find(|child| child.vis.is_public() && child.ident.name != kw::Underscore)
|
.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
|
||||||
|
|
||||||
// Iterate external crate defs but be mindful about visibility
|
// Iterate external crate defs but be mindful about visibility
|
||||||
while let Some(def) = queue.pop() {
|
while let Some(def) = queue.pop() {
|
||||||
for child in tcx.item_children(def).iter() {
|
for child in tcx.module_children(def).iter() {
|
||||||
if !child.vis.is_public() {
|
if !child.vis.is_public() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn build_reduced_graph_external(&mut self, module: Module<'a>) {
|
crate fn build_reduced_graph_external(&mut self, module: Module<'a>) {
|
||||||
for child in self.cstore().item_children_untracked(module.def_id(), self.session) {
|
for child in self.cstore().module_children_untracked(module.def_id(), self.session) {
|
||||||
let parent_scope = ParentScope::module(module, self);
|
let parent_scope = ParentScope::module(module, self);
|
||||||
BuildReducedGraphVisitor { r: self, parent_scope }
|
BuildReducedGraphVisitor { r: self, parent_scope }
|
||||||
.build_reduced_graph_for_external_crate_res(child);
|
.build_reduced_graph_for_external_crate_res(child);
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if Some(*parent_did) != self.tcx.parent(*trait_did)
|
if Some(*parent_did) != self.tcx.parent(*trait_did)
|
||||||
&& self
|
&& self
|
||||||
.tcx
|
.tcx
|
||||||
.item_children(*parent_did)
|
.module_children(*parent_did)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|child| child.res.opt_def_id() == Some(*trait_did))
|
.filter(|child| child.res.opt_def_id() == Some(*trait_did))
|
||||||
.all(|child| child.ident.name == kw::Underscore)
|
.all(|child| child.ident.name == kw::Underscore)
|
||||||
|
|
|
@ -516,7 +516,7 @@ fn build_module(
|
||||||
// If we're re-exporting a re-export it may actually re-export something in
|
// If we're re-exporting a re-export it may actually re-export something in
|
||||||
// two namespaces, so the target may be listed twice. Make sure we only
|
// two namespaces, so the target may be listed twice. Make sure we only
|
||||||
// visit each node at most once.
|
// visit each node at most once.
|
||||||
for &item in cx.tcx.item_children(did).iter() {
|
for &item in cx.tcx.module_children(did).iter() {
|
||||||
if item.vis.is_public() {
|
if item.vis.is_public() {
|
||||||
let res = item.res.expect_non_local();
|
let res = item.res.expect_non_local();
|
||||||
if let Some(def_id) = res.mod_def_id() {
|
if let Some(def_id) = res.mod_def_id() {
|
||||||
|
|
|
@ -265,7 +265,7 @@ impl ExternalCrate {
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
tcx.item_children(root).iter().map(|item| item.res).filter_map(as_keyword).collect()
|
tcx.module_children(root).iter().map(|item| item.res).filter_map(as_keyword).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ impl ExternalCrate {
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
tcx.item_children(root).iter().map(|item| item.res).filter_map(as_primitive).collect()
|
tcx.module_children(root).iter().map(|item| item.res).filter_map(as_primitive).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl<'a, 'tcx> LibEmbargoVisitor<'a, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for item in self.tcx.item_children(def_id).iter() {
|
for item in self.tcx.module_children(def_id).iter() {
|
||||||
if let Some(def_id) = item.res.opt_def_id() {
|
if let Some(def_id) = item.res.opt_def_id() {
|
||||||
if self.tcx.def_key(def_id).parent.map_or(false, |d| d == def_id.index)
|
if self.tcx.def_key(def_id).parent.map_or(false, |d| d == def_id.index)
|
||||||
|| item.vis.is_public()
|
|| item.vis.is_public()
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
|
||||||
if let Res::Def(DefKind::Mod, id) = path.res;
|
if let Res::Def(DefKind::Mod, id) = path.res;
|
||||||
if !id.is_local();
|
if !id.is_local();
|
||||||
then {
|
then {
|
||||||
for kid in cx.tcx.item_children(id).iter() {
|
for kid in cx.tcx.module_children(id).iter() {
|
||||||
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
|
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
|
||||||
let span = mac_attr.span;
|
let span = mac_attr.span;
|
||||||
let def_path = cx.tcx.def_path_str(mac_id);
|
let def_path = cx.tcx.def_path_str(mac_id);
|
||||||
|
|
|
@ -924,7 +924,7 @@ pub fn check_path(cx: &LateContext<'_>, path: &[&str]) -> bool {
|
||||||
let lang_item_path = cx.get_def_path(*item_def_id);
|
let lang_item_path = cx.get_def_path(*item_def_id);
|
||||||
if path_syms.starts_with(&lang_item_path) {
|
if path_syms.starts_with(&lang_item_path) {
|
||||||
if let [item] = &path_syms[lang_item_path.len()..] {
|
if let [item] = &path_syms[lang_item_path.len()..] {
|
||||||
for child in cx.tcx.item_children(*item_def_id) {
|
for child in cx.tcx.module_children(*item_def_id) {
|
||||||
if child.ident.name == *item {
|
if child.ident.name == *item {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -984,7 +984,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol {
|
||||||
|
|
||||||
for &module in &[&paths::KW_MODULE, &paths::SYM_MODULE] {
|
for &module in &[&paths::KW_MODULE, &paths::SYM_MODULE] {
|
||||||
if let Some(def_id) = path_to_res(cx, module).opt_def_id() {
|
if let Some(def_id) = path_to_res(cx, module).opt_def_id() {
|
||||||
for item in cx.tcx.item_children(def_id).iter() {
|
for item in cx.tcx.module_children(def_id).iter() {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let Res::Def(DefKind::Const, item_def_id) = item.res;
|
if let Res::Def(DefKind::Const, item_def_id) = item.res;
|
||||||
let ty = cx.tcx.type_of(item_def_id);
|
let ty = cx.tcx.type_of(item_def_id);
|
||||||
|
|
|
@ -525,7 +525,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res {
|
||||||
fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<Res> {
|
fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<Res> {
|
||||||
match tcx.def_kind(def_id) {
|
match tcx.def_kind(def_id) {
|
||||||
DefKind::Mod | DefKind::Enum | DefKind::Trait => tcx
|
DefKind::Mod | DefKind::Enum | DefKind::Trait => tcx
|
||||||
.item_children(def_id)
|
.module_children(def_id)
|
||||||
.iter()
|
.iter()
|
||||||
.find(|item| item.ident.name.as_str() == name)
|
.find(|item| item.ident.name.as_str() == name)
|
||||||
.map(|child| child.res.expect_non_local()),
|
.map(|child| child.res.expect_non_local()),
|
||||||
|
|
|
@ -40,7 +40,7 @@ mod a {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// issue #7015, ICE due to calling `item_children` with local `DefId`
|
// issue #7015, ICE due to calling `module_children` with local `DefId`
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
use a as b;
|
use a as b;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ mod a {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// issue #7015, ICE due to calling `item_children` with local `DefId`
|
// issue #7015, ICE due to calling `module_children` with local `DefId`
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
use a as b;
|
use a as b;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue