diff options
author | Aleksey Kladov <[email protected]> | 2019-11-20 13:03:59 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-20 13:22:58 +0000 |
commit | cebeedc66fc40097eae20bf1767a285d00269966 (patch) | |
tree | e54c306ac0512e3610430574dc8bea39e4b50218 /crates/ra_hir/src/code_model | |
parent | 06fa3d8389c833b01f482bf35b0f850e627612b9 (diff) |
Next gen IDs for functions
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
Diffstat (limited to 'crates/ra_hir/src/code_model')
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 556417b0f..91cab7414 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -1,5 +1,6 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use hir_def::{HasSource as _, Lookup}; | ||
3 | use ra_syntax::ast::{self, AstNode}; | 4 | use ra_syntax::ast::{self, AstNode}; |
4 | 5 | ||
5 | use crate::{ | 6 | use crate::{ |
@@ -113,7 +114,7 @@ impl HasSource for EnumVariant { | |||
113 | impl HasSource for Function { | 114 | impl HasSource for Function { |
114 | type Ast = ast::FnDef; | 115 | type Ast = ast::FnDef; |
115 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::FnDef> { | 116 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::FnDef> { |
116 | self.id.source(db) | 117 | self.id.lookup(db).source(db) |
117 | } | 118 | } |
118 | } | 119 | } |
119 | impl HasSource for Const { | 120 | impl HasSource for Const { |