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
This commit is contained in:
parent
7ce85f2dca
commit
25cc99fca0
2 changed files with 14 additions and 5 deletions
|
@ -880,11 +880,11 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
|||
self.tcx,
|
||||
self.tcx.hir().local_def_id(md.hir_id)
|
||||
).unwrap();
|
||||
let mut module_id = self.tcx.hir().as_local_hir_id(macro_module_def_id).unwrap();
|
||||
if !self.tcx.hir().is_hir_id_module(module_id) {
|
||||
// `module_id` doesn't correspond to a `mod`, return early (#63164).
|
||||
return;
|
||||
}
|
||||
let mut module_id = match self.tcx.hir().as_local_hir_id(macro_module_def_id) {
|
||||
Some(module_id) if self.tcx.hir().is_hir_id_module(module_id) => module_id,
|
||||
// `module_id` doesn't correspond to a `mod`, return early (#63164, #65252).
|
||||
_ => 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() {
|
||||
|
|
9
src/test/rustdoc/macro-in-closure.rs
Normal file
9
src/test/rustdoc/macro-in-closure.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
// Regression issue for rustdoc ICE encountered in PR #65252.
|
||||
|
||||
#![feature(decl_macro)]
|
||||
|
||||
fn main() {
|
||||
|| {
|
||||
macro m() {}
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue