Skip to content

Commit 0c9268c

Browse files
committed
Filter out macro calls by file id in when building DynMap
1 parent 41a0e95 commit 0c9268c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

crates/hir_def/src/child_by_source.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,23 @@ impl ChildBySource for ItemScope {
114114
}
115115
});
116116
self.unnamed_consts().for_each(|konst| {
117-
let src = konst.lookup(db).source(db);
118-
res[keys::CONST].insert(src, konst);
117+
let loc = konst.lookup(db);
118+
if loc.id.file_id() == file_id {
119+
let src = loc.source(db);
120+
res[keys::CONST].insert(src, konst);
121+
}
119122
});
120123
self.impls().for_each(|imp| add_impl(db, file_id, res, imp));
121124
self.attr_macro_invocs().for_each(|(ast_id, call_id)| {
122-
let item = ast_id.with_value(ast_id.to_node(db.upcast()));
123-
res[keys::ATTR_MACRO_CALL].insert(item, call_id);
125+
if ast_id.file_id == file_id {
126+
let item = ast_id.with_value(ast_id.to_node(db.upcast()));
127+
res[keys::ATTR_MACRO_CALL].insert(item, call_id);
128+
}
124129
});
125130
self.derive_macro_invocs().for_each(|(ast_id, calls)| {
131+
if ast_id.file_id != file_id {
132+
return;
133+
}
126134
let adt = ast_id.to_node(db.upcast());
127135
for (attr_id, calls) in calls {
128136
if let Some(Either::Right(attr)) =

0 commit comments

Comments
 (0)