From 0c9268c1ee315adf038573890b58ee93c1083501 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 7 Jan 2022 21:31:08 +0100 Subject: [PATCH] Filter out macro calls by file id in when building DynMap --- crates/hir_def/src/child_by_source.rs | 16 ++++++++++++---- 1 file 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 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: Hi } }); 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)) =