diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 27 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 3 |
2 files changed, 6 insertions, 24 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index faeb2fc8a..d11b573e5 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -160,27 +160,8 @@ impl_intern!(TypeAliasId, TypeAliasLoc, intern_type_alias, lookup_intern_type_al | |||
160 | 160 | ||
161 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 161 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
162 | pub struct ImplId(salsa::InternId); | 162 | pub struct ImplId(salsa::InternId); |
163 | impl_intern_key!(ImplId); | 163 | type ImplLoc = ItemLoc<ast::ImplBlock>; |
164 | 164 | impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl); | |
165 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
166 | pub struct ImplLoc { | ||
167 | pub container: ModuleId, | ||
168 | pub ast_id: AstId<ast::ImplBlock>, | ||
169 | } | ||
170 | |||
171 | impl Intern for ImplLoc { | ||
172 | type ID = ImplId; | ||
173 | fn intern(self, db: &impl db::DefDatabase) -> ImplId { | ||
174 | db.intern_impl(self) | ||
175 | } | ||
176 | } | ||
177 | |||
178 | impl Lookup for ImplId { | ||
179 | type Data = ImplLoc; | ||
180 | fn lookup(&self, db: &impl db::DefDatabase) -> ImplLoc { | ||
181 | db.lookup_intern_impl(*self) | ||
182 | } | ||
183 | } | ||
184 | 165 | ||
185 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 166 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
186 | pub struct TypeParamId { | 167 | pub struct TypeParamId { |
@@ -379,7 +360,7 @@ impl HasModule for AssocContainerId { | |||
379 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { | 360 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
380 | match *self { | 361 | match *self { |
381 | AssocContainerId::ContainerId(it) => it.module(db), | 362 | AssocContainerId::ContainerId(it) => it.module(db), |
382 | AssocContainerId::ImplId(it) => it.lookup(db).container, | 363 | AssocContainerId::ImplId(it) => it.lookup(db).container.module(db), |
383 | AssocContainerId::TraitId(it) => it.lookup(db).container.module(db), | 364 | AssocContainerId::TraitId(it) => it.lookup(db).container.module(db), |
384 | } | 365 | } |
385 | } | 366 | } |
@@ -431,7 +412,7 @@ impl HasModule for GenericDefId { | |||
431 | GenericDefId::AdtId(it) => it.module(db), | 412 | GenericDefId::AdtId(it) => it.module(db), |
432 | GenericDefId::TraitId(it) => it.lookup(db).container.module(db), | 413 | GenericDefId::TraitId(it) => it.lookup(db).container.module(db), |
433 | GenericDefId::TypeAliasId(it) => it.lookup(db).module(db), | 414 | GenericDefId::TypeAliasId(it) => it.lookup(db).module(db), |
434 | GenericDefId::ImplId(it) => it.lookup(db).container, | 415 | GenericDefId::ImplId(it) => it.lookup(db).container.module(db), |
435 | GenericDefId::EnumVariantId(it) => it.parent.lookup(db).container.module(db), | 416 | GenericDefId::EnumVariantId(it) => it.parent.lookup(db).container.module(db), |
436 | GenericDefId::ConstId(it) => it.lookup(db).module(db), | 417 | GenericDefId::ConstId(it) => it.lookup(db).module(db), |
437 | } | 418 | } |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index a1ea130e0..e68bf4868 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -661,9 +661,10 @@ where | |||
661 | krate: self.def_collector.def_map.krate, | 661 | krate: self.def_collector.def_map.krate, |
662 | local_id: self.module_id, | 662 | local_id: self.module_id, |
663 | }; | 663 | }; |
664 | let container = ContainerId::ModuleId(module); | ||
664 | let ast_id = self.raw_items[imp].ast_id; | 665 | let ast_id = self.raw_items[imp].ast_id; |
665 | let impl_id = | 666 | let impl_id = |
666 | ImplLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 667 | ImplLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
667 | .intern(self.def_collector.db); | 668 | .intern(self.def_collector.db); |
668 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) | 669 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) |
669 | } | 670 | } |