extend attrs if local_def_id exists

This commit is contained in:
Takayuki Maeda 2022-08-28 01:20:26 +09:00
parent 9845f4c47e
commit aa76e135ff
2 changed files with 17 additions and 2 deletions

View File

@ -41,8 +41,9 @@ fn fold_item(&mut self, mut item: Item) -> Option<Item> {
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));

View File

@ -0,0 +1,14 @@
// check-pass
const _: () = {
#[macro_export]
macro_rules! first_macro {
() => {}
}
mod foo {
#[macro_export]
macro_rules! second_macro {
() => {}
}
}
};