diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2022-01-07 21:31:08 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2022-01-07 21:31:08 +0100 |
| commit | 0c9268c1ee315adf038573890b58ee93c1083501 (patch) | |
| tree | b7bdff4d636fc21fde64ab05f566ad1f4de3f063 | |
| parent | 41a0e95d6125c7d15aad4daa48123afd5d410af7 (diff) | |
| download | rust-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.rs | 16 |
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)) = |
