Skip to content

Commit aa76e13

Browse files
committed
extend attrs if local_def_id exists
1 parent 9845f4c commit aa76e13

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/librustdoc/passes/propagate_doc_cfg.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ impl<'a, 'tcx> DocFolder for CfgPropagator<'a, 'tcx> {
4141
if self.parent != Some(expected_parent) {
4242
let mut attrs = Vec::new();
4343
for (parent_hir_id, _) in hir.parent_iter(hir_id) {
44-
let def_id = hir.local_def_id(parent_hir_id).to_def_id();
45-
attrs.extend_from_slice(load_attrs(self.cx, def_id));
44+
if let Some(def_id) = hir.opt_local_def_id(parent_hir_id) {
45+
attrs.extend_from_slice(load_attrs(self.cx, def_id.to_def_id()));
46+
}
4647
}
4748
let (_, cfg) =
4849
merge_attrs(self.cx, None, item.attrs.other_attrs.as_slice(), Some(&attrs));

src/test/rustdoc-ui/issue-101076.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
3+
const _: () = {
4+
#[macro_export]
5+
macro_rules! first_macro {
6+
() => {}
7+
}
8+
mod foo {
9+
#[macro_export]
10+
macro_rules! second_macro {
11+
() => {}
12+
}
13+
}
14+
};

0 commit comments

Comments
 (0)