Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get_parent_did to access parent hir_id instead of DefIdTree::parent #72039

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,27 +941,21 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
return;
}

let macro_module_def_id =
ty::DefIdTree::parent(self.tcx, self.tcx.hir().local_def_id(md.hir_id).to_def_id())
.unwrap();
// FIXME(#71104) Should really be using just `as_local_hir_id` but
// some `DefId` do not seem to have a corresponding HirId.
let hir_id = macro_module_def_id
.as_local()
.and_then(|def_id| self.tcx.hir().opt_local_def_id_to_hir_id(def_id));
let mut module_id = match hir_id {
Some(module_id) if self.tcx.hir().is_hir_id_module(module_id) => module_id,
let macro_module_def_id = self.tcx.hir().get_parent_did(md.hir_id);
let mut module_id = self.tcx.hir().as_local_hir_id(macro_module_def_id);
if !self.tcx.hir().is_hir_id_module(module_id) {
// `module_id` doesn't correspond to a `mod`, return early (#63164, #65252).
_ => return,
};
return;
}
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
let new_level = self.update(md.hir_id, level);
if new_level.is_none() {
return;
}

loop {
let changed_reachability = self.update_macro_reachable(module_id, macro_module_def_id);
let changed_reachability =
self.update_macro_reachable(module_id, macro_module_def_id.to_def_id());
if changed_reachability || module_id == hir::CRATE_HIR_ID {
break;
}
Expand Down