diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-10-16 00:01:47 +0300 | 
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-10-19 00:23:57 +0300 | 
| commit | 25cc99fca0650f54828e8ba7ad2bab341b231fcc (patch) | |
| tree | 88a6bc6f80ee792522a06d20e0928ca573458b7a | |
| parent | 7ce85f2dca545c9012fdc13c90cb2b058e58d3dd (diff) | |
| download | rust-25cc99fca0650f54828e8ba7ad2bab341b231fcc.tar.gz rust-25cc99fca0650f54828e8ba7ad2bab341b231fcc.zip | |
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
| -rw-r--r-- | src/librustc_privacy/lib.rs | 10 | ||||
| -rw-r--r-- | src/test/rustdoc/macro-in-closure.rs | 9 | 
2 files changed, 14 insertions, 5 deletions
| diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index f44692b7aea..a3a4ccf5d65 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -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() { diff --git a/src/test/rustdoc/macro-in-closure.rs b/src/test/rustdoc/macro-in-closure.rs new file mode 100644 index 00000000000..298ff601de8 --- /dev/null +++ b/src/test/rustdoc/macro-in-closure.rs @@ -0,0 +1,9 @@ +// Regression issue for rustdoc ICE encountered in PR #65252. + +#![feature(decl_macro)] + +fn main() { + || { + macro m() {} + }; +} | 
