diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-20 13:23:38 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-20 13:23:38 +0000 |
commit | b568bcfe6d94d5f4c6cdc012b766473e5b771a26 (patch) | |
tree | e54c306ac0512e3610430574dc8bea39e4b50218 /crates/ra_hir_def/src/db.rs | |
parent | 2d47f380baad4eacd87331c4b86c0ecb28239499 (diff) | |
parent | cebeedc66fc40097eae20bf1767a285d00269966 (diff) |
Merge #2325
2325: Next gen IDs for functions r=matklad a=matklad
The current system with AstIds has two primaraly drawbacks:
* It is possible to manufacture IDs out of thin air.
For example, it's possible to create IDs for items which are not
considered in CrateDefMap due to cfg. Or it is possible to mixup
structs and unions, because they share ID space.
* Getting the ID of a parent requires a secondary index.
Instead, the plan is to pursue the more traditional approach, where
each items stores the id of the parent declaration. This makes
`FromSource` more awkward, but also more correct: now, to get from an
AST to HIR, we first do this recursively for the parent item, and the
just search the children of the parent for the matching def
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/db.rs')
-rw-r--r-- | crates/ra_hir_def/src/db.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index fb4402463..e4ffdebe9 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -14,13 +14,13 @@ use crate::{ | |||
14 | CrateDefMap, | 14 | CrateDefMap, |
15 | }, | 15 | }, |
16 | traits::{TraitData, TraitItemsIndex}, | 16 | traits::{TraitData, TraitItemsIndex}, |
17 | DefWithBodyId, EnumId, ImplId, ItemLoc, ModuleId, StructOrUnionId, TraitId, | 17 | DefWithBodyId, EnumId, FunctionLoc, ImplId, ItemLoc, ModuleId, StructOrUnionId, TraitId, |
18 | }; | 18 | }; |
19 | 19 | ||
20 | #[salsa::query_group(InternDatabaseStorage)] | 20 | #[salsa::query_group(InternDatabaseStorage)] |
21 | pub trait InternDatabase: SourceDatabase { | 21 | pub trait InternDatabase: SourceDatabase { |
22 | #[salsa::interned] | 22 | #[salsa::interned] |
23 | fn intern_function(&self, loc: ItemLoc<ast::FnDef>) -> crate::FunctionId; | 23 | fn intern_function(&self, loc: FunctionLoc) -> crate::FunctionId; |
24 | #[salsa::interned] | 24 | #[salsa::interned] |
25 | fn intern_struct_or_union(&self, loc: ItemLoc<ast::StructDef>) -> crate::StructOrUnionId; | 25 | fn intern_struct_or_union(&self, loc: ItemLoc<ast::StructDef>) -> crate::StructOrUnionId; |
26 | #[salsa::interned] | 26 | #[salsa::interned] |