diff options
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 27 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/method_resolution.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 2 |
5 files changed, 10 insertions, 28 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 35e1f752b..ecf883272 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -754,7 +754,7 @@ impl ImplBlock { | |||
754 | let environment = TraitEnvironment::lower(db, &resolver); | 754 | let environment = TraitEnvironment::lower(db, &resolver); |
755 | let ty = Ty::from_hir(db, &resolver, &impl_data.target_type); | 755 | let ty = Ty::from_hir(db, &resolver, &impl_data.target_type); |
756 | Type { | 756 | Type { |
757 | krate: self.id.lookup(db).container.krate, | 757 | krate: self.id.lookup(db).container.module(db).krate, |
758 | ty: InEnvironment { value: ty, environment }, | 758 | ty: InEnvironment { value: ty, environment }, |
759 | } | 759 | } |
760 | } | 760 | } |
@@ -768,7 +768,7 @@ impl ImplBlock { | |||
768 | } | 768 | } |
769 | 769 | ||
770 | pub fn module(&self, db: &impl DefDatabase) -> Module { | 770 | pub fn module(&self, db: &impl DefDatabase) -> Module { |
771 | self.id.lookup(db).container.into() | 771 | self.id.lookup(db).container.module(db).into() |
772 | } | 772 | } |
773 | 773 | ||
774 | pub fn krate(&self, db: &impl DefDatabase) -> Crate { | 774 | pub fn krate(&self, db: &impl DefDatabase) -> Crate { |
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 | } |
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 1b2f4014c..92fb4c081 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs | |||
@@ -134,7 +134,7 @@ impl Ty { | |||
134 | LangItemTarget::ImplBlockId(it) => Some(it), | 134 | LangItemTarget::ImplBlockId(it) => Some(it), |
135 | _ => None, | 135 | _ => None, |
136 | }) | 136 | }) |
137 | .map(|it| it.lookup(db).container.krate) | 137 | .map(|it| it.lookup(db).container.module(db).krate) |
138 | .collect(); | 138 | .collect(); |
139 | Some(res) | 139 | Some(res) |
140 | } | 140 | } |
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index dd4fa9664..5eb032d86 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -673,7 +673,7 @@ fn impl_block_datum( | |||
673 | let bound_vars = Substs::bound_vars(&generic_params); | 673 | let bound_vars = Substs::bound_vars(&generic_params); |
674 | let trait_ref = trait_ref.subst(&bound_vars); | 674 | let trait_ref = trait_ref.subst(&bound_vars); |
675 | let trait_ = trait_ref.trait_; | 675 | let trait_ = trait_ref.trait_; |
676 | let impl_type = if impl_id.lookup(db).container.krate == krate { | 676 | let impl_type = if impl_id.lookup(db).container.module(db).krate == krate { |
677 | chalk_rust_ir::ImplType::Local | 677 | chalk_rust_ir::ImplType::Local |
678 | } else { | 678 | } else { |
679 | chalk_rust_ir::ImplType::External | 679 | chalk_rust_ir::ImplType::External |