1
Fork 0

parent_module_from_def_id does not need to be a query.

This commit is contained in:
Camille GILLOT 2023-08-05 12:18:12 +00:00
parent fbc11e9690
commit 7a51b30ebd
3 changed files with 15 additions and 21 deletions

View file

@ -102,7 +102,21 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn parent_module(self, id: HirId) -> LocalDefId {
self.parent_module_from_def_id(id.owner.def_id)
if !id.is_owner() && self.def_kind(id.owner) == DefKind::Mod {
id.owner.def_id
} else {
self.parent_module_from_def_id(id.owner.def_id)
}
}
pub fn parent_module_from_def_id(self, mut id: LocalDefId) -> LocalDefId {
while let Some(parent) = self.opt_local_parent(id) {
id = parent;
if self.def_kind(id) == DefKind::Mod {
break;
}
}
id
}
pub fn impl_subject(self, def_id: DefId) -> EarlyBinder<ImplSubject<'tcx>> {
@ -120,10 +134,6 @@ impl<'tcx> TyCtxt<'tcx> {
}
pub fn provide(providers: &mut Providers) {
providers.parent_module_from_def_id = |tcx, id| {
let hir = tcx.hir();
hir.get_module_parent_node(hir.local_def_id_to_hir_id(id)).def_id
};
providers.hir_crate_items = map::hir_crate_items;
providers.crate_hash = map::crate_hash;
providers.hir_module_items = map::hir_module_items;