diff options
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 27 |
1 files changed, 4 insertions, 23 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 | } |