Skip to content

Commit 25cc99f

Browse files
committed
privacy: Avoid one more unwrap causing an ICE in rustdoc
The issue is rustdoc-specific because its root cause if the `everybody_loops` pass makes some def-ids to not have local hir-ids
1 parent 7ce85f2 commit 25cc99f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/librustc_privacy/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -880,11 +880,11 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
880880
self.tcx,
881881
self.tcx.hir().local_def_id(md.hir_id)
882882
).unwrap();
883-
let mut module_id = self.tcx.hir().as_local_hir_id(macro_module_def_id).unwrap();
884-
if !self.tcx.hir().is_hir_id_module(module_id) {
885-
// `module_id` doesn't correspond to a `mod`, return early (#63164).
886-
return;
887-
}
883+
let mut module_id = match self.tcx.hir().as_local_hir_id(macro_module_def_id) {
884+
Some(module_id) if self.tcx.hir().is_hir_id_module(module_id) => module_id,
885+
// `module_id` doesn't correspond to a `mod`, return early (#63164, #65252).
886+
_ => return,
887+
};
888888
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
889889
let new_level = self.update(md.hir_id, level);
890890
if new_level.is_none() {

src/test/rustdoc/macro-in-closure.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Regression issue for rustdoc ICE encountered in PR #65252.
2+
3+
#![feature(decl_macro)]
4+
5+
fn main() {
6+
|| {
7+
macro m() {}
8+
};
9+
}

0 commit comments

Comments
 (0)