Reduce visibility of get_module_parent_node and remove get_module_parent

This commit is contained in:
John Kåre Alsaker
2020-02-22 19:53:10 +01:00
parent 542d813475
commit 98251d8fb2
2 changed files with 2 additions and 8 deletions
+1 -7
View File
@@ -746,15 +746,9 @@ pub fn get_parent_item(&self, hir_id: HirId) -> HirId {
hir_id
}
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
/// module parent is in this map.
pub fn get_module_parent(&self, id: HirId) -> DefId {
self.local_def_id(self.get_module_parent_node(id))
}
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
/// module parent is in this map.
pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
pub(super) fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
for (hir_id, node) in self.parent_iter(hir_id) {
if let Node::Item(&Item { kind: ItemKind::Mod(_), .. }) = node {
return hir_id;
+1 -1
View File
@@ -55,7 +55,7 @@ pub fn parent_module(self, id: HirId) -> DefId {
pub fn provide(providers: &mut Providers<'_>) {
providers.parent_module_from_def_id = |tcx, id| {
let hir = tcx.hir();
hir.get_module_parent(hir.as_local_hir_id(id).unwrap())
hir.local_def_id(hir.get_module_parent_node(hir.as_local_hir_id(id).unwrap()))
};
providers.hir_crate = |tcx, _| tcx.hir_map.untracked_krate();
map::provide(providers);