Skip to content

Commit

Permalink
Rollup merge of #101091 - TaKO8Ki:fix-101076, r=notriddle
Browse files Browse the repository at this point in the history
Extend attrs if local_def_id exists

Fixes #101076
  • Loading branch information
matthiaskrgr authored Aug 28, 2022
2 parents 3142996 + aa76e13 commit c2f294a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustdoc/passes/propagate_doc_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ impl<'a, 'tcx> DocFolder for CfgPropagator<'a, 'tcx> {
if self.parent != Some(expected_parent) {
let mut attrs = Vec::new();
for (parent_hir_id, _) in hir.parent_iter(hir_id) {
let def_id = hir.local_def_id(parent_hir_id).to_def_id();
attrs.extend_from_slice(load_attrs(self.cx, def_id));
if let Some(def_id) = hir.opt_local_def_id(parent_hir_id) {
attrs.extend_from_slice(load_attrs(self.cx, def_id.to_def_id()));
}
}
let (_, cfg) =
merge_attrs(self.cx, None, item.attrs.other_attrs.as_slice(), Some(&attrs));
Expand Down
14 changes: 14 additions & 0 deletions src/test/rustdoc-ui/issue-101076.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass

const _: () = {
#[macro_export]
macro_rules! first_macro {
() => {}
}
mod foo {
#[macro_export]
macro_rules! second_macro {
() => {}
}
}
};

0 comments on commit c2f294a

Please sign in to comment.