Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend attrs if local_def_id exists #101091

Merged
merged 1 commit into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
() => {}
}
}
};