about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-01-07 21:31:08 +0100
committerLukas Wirth <lukastw97@gmail.com>2022-01-07 21:31:08 +0100
commit0c9268c1ee315adf038573890b58ee93c1083501 (patch)
treeb7bdff4d636fc21fde64ab05f566ad1f4de3f063
parent41a0e95d6125c7d15aad4daa48123afd5d410af7 (diff)
downloadrust-0c9268c1ee315adf038573890b58ee93c1083501.tar.gz
rust-0c9268c1ee315adf038573890b58ee93c1083501.zip
Filter out macro calls by file id in when building DynMap
-rw-r--r--crates/hir_def/src/child_by_source.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/hir_def/src/child_by_source.rs b/crates/hir_def/src/child_by_source.rs
index d314b7fc015..c5d01347790 100644
--- a/crates/hir_def/src/child_by_source.rs
+++ b/crates/hir_def/src/child_by_source.rs
@@ -114,15 +114,23 @@ impl ChildBySource for ItemScope {
             }
         });
         self.unnamed_consts().for_each(|konst| {
-            let src = konst.lookup(db).source(db);
-            res[keys::CONST].insert(src, konst);
+            let loc = konst.lookup(db);
+            if loc.id.file_id() == file_id {
+                let src = loc.source(db);
+                res[keys::CONST].insert(src, konst);
+            }
         });
         self.impls().for_each(|imp| add_impl(db, file_id, res, imp));
         self.attr_macro_invocs().for_each(|(ast_id, call_id)| {
-            let item = ast_id.with_value(ast_id.to_node(db.upcast()));
-            res[keys::ATTR_MACRO_CALL].insert(item, call_id);
+            if ast_id.file_id == file_id {
+                let item = ast_id.with_value(ast_id.to_node(db.upcast()));
+                res[keys::ATTR_MACRO_CALL].insert(item, call_id);
+            }
         });
         self.derive_macro_invocs().for_each(|(ast_id, calls)| {
+            if ast_id.file_id != file_id {
+                return;
+            }
             let adt = ast_id.to_node(db.upcast());
             for (attr_id, calls) in calls {
                 if let Some(Either::Right(attr)) =