diff options
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/has_source.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/attr.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/child_by_source.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir_def/src/data.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/db.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/generics.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/keys.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 30 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_def/src/src.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/method_resolution.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 2 |
16 files changed, 69 insertions, 32 deletions
diff --git a/Cargo.lock b/Cargo.lock index 13bbbb74c..af874945c 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1123,6 +1123,7 @@ dependencies = [ | |||
1123 | "rowan 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1123 | "rowan 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1124 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1124 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1125 | "rustc_lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1125 | "rustc_lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1126 | "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1126 | "smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", | 1127 | "smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", |
1127 | "test_utils 0.1.0", | 1128 | "test_utils 0.1.0", |
1128 | "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | 1129 | "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", |
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index c013ff99b..117ca2fe3 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -809,7 +809,10 @@ impl ImplBlock { | |||
809 | let resolver = self.id.resolver(db); | 809 | let resolver = self.id.resolver(db); |
810 | let environment = TraitEnvironment::lower(db, &resolver); | 810 | let environment = TraitEnvironment::lower(db, &resolver); |
811 | let ty = Ty::from_hir(db, &resolver, &impl_data.target_type); | 811 | let ty = Ty::from_hir(db, &resolver, &impl_data.target_type); |
812 | Type { krate: self.id.module(db).krate, ty: InEnvironment { value: ty, environment } } | 812 | Type { |
813 | krate: self.id.lookup(db).container.krate, | ||
814 | ty: InEnvironment { value: ty, environment }, | ||
815 | } | ||
813 | } | 816 | } |
814 | 817 | ||
815 | pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> { | 818 | pub fn items(&self, db: &impl DefDatabase) -> Vec<AssocItem> { |
@@ -821,7 +824,7 @@ impl ImplBlock { | |||
821 | } | 824 | } |
822 | 825 | ||
823 | pub fn module(&self, db: &impl DefDatabase) -> Module { | 826 | pub fn module(&self, db: &impl DefDatabase) -> Module { |
824 | self.id.module(db).into() | 827 | self.id.lookup(db).container.into() |
825 | } | 828 | } |
826 | 829 | ||
827 | pub fn krate(&self, db: &impl DefDatabase) -> Crate { | 830 | pub fn krate(&self, db: &impl DefDatabase) -> Crate { |
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 307f3d5bf..b35188a21 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -107,8 +107,10 @@ impl FromSource for MacroDef { | |||
107 | impl FromSource for ImplBlock { | 107 | impl FromSource for ImplBlock { |
108 | type Ast = ast::ImplBlock; | 108 | type Ast = ast::ImplBlock; |
109 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> { | 109 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> { |
110 | let id = from_source(db, src)?; | 110 | // XXX: use `.parent()` to avoid finding ourselves |
111 | Some(ImplBlock { id }) | 111 | let parent = src.value.syntax().parent()?; |
112 | let container = Container::find(db, src.with_value(parent).as_ref())?; | ||
113 | container.child_by_source(db)[keys::IMPL].get(&src).copied().map(ImplBlock::from) | ||
112 | } | 114 | } |
113 | } | 115 | } |
114 | 116 | ||
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index b09582f93..a888fe995 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs | |||
@@ -114,7 +114,7 @@ impl HasSource for MacroDef { | |||
114 | impl HasSource for ImplBlock { | 114 | impl HasSource for ImplBlock { |
115 | type Ast = ast::ImplBlock; | 115 | type Ast = ast::ImplBlock; |
116 | fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> { | 116 | fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> { |
117 | self.id.source(db) | 117 | self.id.lookup(db).source(db) |
118 | } | 118 | } |
119 | } | 119 | } |
120 | impl HasSource for Import { | 120 | impl HasSource for Import { |
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 2f8f02d82..12d4e777a 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -64,7 +64,7 @@ impl Attrs { | |||
64 | AttrDefId::MacroDefId(it) => { | 64 | AttrDefId::MacroDefId(it) => { |
65 | it.ast_id.map_or_else(Default::default, |ast_id| attrs_from_ast(ast_id, db)) | 65 | it.ast_id.map_or_else(Default::default, |ast_id| attrs_from_ast(ast_id, db)) |
66 | } | 66 | } |
67 | AttrDefId::ImplId(it) => attrs_from_ast(it.lookup_intern(db).ast_id, db), | 67 | AttrDefId::ImplId(it) => attrs_from_loc(it.lookup(db), db), |
68 | AttrDefId::ConstId(it) => attrs_from_loc(it.lookup(db), db), | 68 | AttrDefId::ConstId(it) => attrs_from_loc(it.lookup(db), db), |
69 | AttrDefId::StaticId(it) => attrs_from_loc(it.lookup(db), db), | 69 | AttrDefId::StaticId(it) => attrs_from_loc(it.lookup(db), db), |
70 | AttrDefId::FunctionId(it) => attrs_from_loc(it.lookup(db), db), | 70 | AttrDefId::FunctionId(it) => attrs_from_loc(it.lookup(db), db), |
diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs index a3574a9db..821549bd5 100644 --- a/crates/ra_hir_def/src/child_by_source.rs +++ b/crates/ra_hir_def/src/child_by_source.rs | |||
@@ -98,6 +98,11 @@ impl ChildBySource for ModuleId { | |||
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | for &impl_ in crate_def_map[self.local_id].impls.iter() { | ||
102 | let src = impl_.lookup(db).source(db); | ||
103 | res[keys::IMPL].insert(src, impl_) | ||
104 | } | ||
105 | |||
101 | res | 106 | res |
102 | } | 107 | } |
103 | } | 108 | } |
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 095d7064a..42821b9b1 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -167,7 +167,7 @@ pub struct ImplData { | |||
167 | 167 | ||
168 | impl ImplData { | 168 | impl ImplData { |
169 | pub(crate) fn impl_data_query(db: &impl DefDatabase, id: ImplId) -> Arc<ImplData> { | 169 | pub(crate) fn impl_data_query(db: &impl DefDatabase, id: ImplId) -> Arc<ImplData> { |
170 | let src = id.source(db); | 170 | let src = id.lookup(db).source(db); |
171 | let items = db.ast_id_map(src.file_id); | 171 | let items = db.ast_id_map(src.file_id); |
172 | 172 | ||
173 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); | 173 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); |
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index ef5611ffc..8907aacca 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs | |||
@@ -18,8 +18,8 @@ use crate::{ | |||
18 | CrateDefMap, | 18 | CrateDefMap, |
19 | }, | 19 | }, |
20 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, FunctionId, FunctionLoc, GenericDefId, | 20 | AttrDefId, ConstId, ConstLoc, DefWithBodyId, EnumId, FunctionId, FunctionLoc, GenericDefId, |
21 | ImplId, ItemLoc, ModuleId, StaticId, StaticLoc, StructId, TraitId, TypeAliasId, TypeAliasLoc, | 21 | ImplId, ImplLoc, ItemLoc, ModuleId, StaticId, StaticLoc, StructId, TraitId, TypeAliasId, |
22 | UnionId, | 22 | TypeAliasLoc, UnionId, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | #[salsa::query_group(InternDatabaseStorage)] | 25 | #[salsa::query_group(InternDatabaseStorage)] |
@@ -41,7 +41,7 @@ pub trait InternDatabase: SourceDatabase { | |||
41 | #[salsa::interned] | 41 | #[salsa::interned] |
42 | fn intern_type_alias(&self, loc: TypeAliasLoc) -> TypeAliasId; | 42 | fn intern_type_alias(&self, loc: TypeAliasLoc) -> TypeAliasId; |
43 | #[salsa::interned] | 43 | #[salsa::interned] |
44 | fn intern_impl(&self, loc: ItemLoc<ast::ImplBlock>) -> ImplId; | 44 | fn intern_impl(&self, loc: ImplLoc) -> ImplId; |
45 | } | 45 | } |
46 | 46 | ||
47 | #[salsa::query_group(DefDatabaseStorage)] | 47 | #[salsa::query_group(DefDatabaseStorage)] |
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 976cf72d0..5d1100945 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs | |||
@@ -109,7 +109,7 @@ impl GenericParams { | |||
109 | // type-parameter, but rather is a type-alias for impl's target | 109 | // type-parameter, but rather is a type-alias for impl's target |
110 | // type, so this is handled by the resolver. | 110 | // type, so this is handled by the resolver. |
111 | GenericDefId::ImplId(it) => { | 111 | GenericDefId::ImplId(it) => { |
112 | let src = it.source(db); | 112 | let src = it.lookup(db).source(db); |
113 | generics.fill(&mut sm, &src.value); | 113 | generics.fill(&mut sm, &src.value); |
114 | src.file_id | 114 | src.file_id |
115 | } | 115 | } |
diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index be702a4f8..d318b2451 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs | |||
@@ -8,7 +8,7 @@ use rustc_hash::FxHashMap; | |||
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | dyn_map::{DynMap, Policy}, | 10 | dyn_map::{DynMap, Policy}, |
11 | ConstId, EnumVariantId, FunctionId, StaticId, StructFieldId, TypeAliasId, TypeParamId, | 11 | ConstId, EnumVariantId, FunctionId, ImplId, StaticId, StructFieldId, TypeAliasId, TypeParamId, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>; | 14 | type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>; |
@@ -16,8 +16,10 @@ type Key<K, V> = crate::dyn_map::Key<InFile<K>, V, AstPtrPolicy<K, V>>; | |||
16 | pub const FUNCTION: Key<ast::FnDef, FunctionId> = Key::new(); | 16 | pub const FUNCTION: Key<ast::FnDef, FunctionId> = Key::new(); |
17 | pub const CONST: Key<ast::ConstDef, ConstId> = Key::new(); | 17 | pub const CONST: Key<ast::ConstDef, ConstId> = Key::new(); |
18 | pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new(); | 18 | pub const STATIC: Key<ast::StaticDef, StaticId> = Key::new(); |
19 | pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new(); | ||
20 | pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new(); | 19 | pub const TYPE_ALIAS: Key<ast::TypeAliasDef, TypeAliasId> = Key::new(); |
20 | pub const IMPL: Key<ast::ImplBlock, ImplId> = Key::new(); | ||
21 | |||
22 | pub const ENUM_VARIANT: Key<ast::EnumVariant, EnumVariantId> = Key::new(); | ||
21 | pub const TUPLE_FIELD: Key<ast::TupleFieldDef, StructFieldId> = Key::new(); | 23 | pub const TUPLE_FIELD: Key<ast::TupleFieldDef, StructFieldId> = Key::new(); |
22 | pub const RECORD_FIELD: Key<ast::RecordFieldDef, StructFieldId> = Key::new(); | 24 | pub const RECORD_FIELD: Key<ast::RecordFieldDef, StructFieldId> = Key::new(); |
23 | pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new(); | 25 | pub const TYPE_PARAM: Key<ast::TypeParam, TypeParamId> = Key::new(); |
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 569da4f28..5564b166b 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -289,12 +289,24 @@ impl Lookup for TypeAliasId { | |||
289 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 289 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
290 | pub struct ImplId(salsa::InternId); | 290 | pub struct ImplId(salsa::InternId); |
291 | impl_intern_key!(ImplId); | 291 | impl_intern_key!(ImplId); |
292 | impl AstItemDef<ast::ImplBlock> for ImplId { | 292 | |
293 | fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::ImplBlock>) -> Self { | 293 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
294 | db.intern_impl(loc) | 294 | pub struct ImplLoc { |
295 | pub container: ModuleId, | ||
296 | pub ast_id: AstId<ast::ImplBlock>, | ||
297 | } | ||
298 | |||
299 | impl Intern for ImplLoc { | ||
300 | type ID = ImplId; | ||
301 | fn intern(self, db: &impl db::DefDatabase) -> ImplId { | ||
302 | db.intern_impl(self) | ||
295 | } | 303 | } |
296 | fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::ImplBlock> { | 304 | } |
297 | db.lookup_intern_impl(self) | 305 | |
306 | impl Lookup for ImplId { | ||
307 | type Data = ImplLoc; | ||
308 | fn lookup(&self, db: &impl db::DefDatabase) -> ImplLoc { | ||
309 | db.lookup_intern_impl(*self) | ||
298 | } | 310 | } |
299 | } | 311 | } |
300 | 312 | ||
@@ -479,7 +491,7 @@ impl HasModule for FunctionLoc { | |||
479 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { | 491 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
480 | match self.container { | 492 | match self.container { |
481 | ContainerId::ModuleId(it) => it, | 493 | ContainerId::ModuleId(it) => it, |
482 | ContainerId::ImplId(it) => it.module(db), | 494 | ContainerId::ImplId(it) => it.lookup(db).container, |
483 | ContainerId::TraitId(it) => it.module(db), | 495 | ContainerId::TraitId(it) => it.module(db), |
484 | } | 496 | } |
485 | } | 497 | } |
@@ -489,7 +501,7 @@ impl HasModule for TypeAliasLoc { | |||
489 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { | 501 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
490 | match self.container { | 502 | match self.container { |
491 | ContainerId::ModuleId(it) => it, | 503 | ContainerId::ModuleId(it) => it, |
492 | ContainerId::ImplId(it) => it.module(db), | 504 | ContainerId::ImplId(it) => it.lookup(db).container, |
493 | ContainerId::TraitId(it) => it.module(db), | 505 | ContainerId::TraitId(it) => it.module(db), |
494 | } | 506 | } |
495 | } | 507 | } |
@@ -499,7 +511,7 @@ impl HasModule for ConstLoc { | |||
499 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { | 511 | fn module(&self, db: &impl db::DefDatabase) -> ModuleId { |
500 | match self.container { | 512 | match self.container { |
501 | ContainerId::ModuleId(it) => it, | 513 | ContainerId::ModuleId(it) => it, |
502 | ContainerId::ImplId(it) => it.module(db), | 514 | ContainerId::ImplId(it) => it.lookup(db).container, |
503 | ContainerId::TraitId(it) => it.module(db), | 515 | ContainerId::TraitId(it) => it.module(db), |
504 | } | 516 | } |
505 | } | 517 | } |
@@ -532,7 +544,7 @@ impl HasModule for GenericDefId { | |||
532 | GenericDefId::AdtId(it) => it.module(db), | 544 | GenericDefId::AdtId(it) => it.module(db), |
533 | GenericDefId::TraitId(it) => it.module(db), | 545 | GenericDefId::TraitId(it) => it.module(db), |
534 | GenericDefId::TypeAliasId(it) => it.lookup(db).module(db), | 546 | GenericDefId::TypeAliasId(it) => it.lookup(db).module(db), |
535 | GenericDefId::ImplId(it) => it.module(db), | 547 | GenericDefId::ImplId(it) => it.lookup(db).container, |
536 | GenericDefId::EnumVariantId(it) => it.parent.module(db), | 548 | GenericDefId::EnumVariantId(it) => it.parent.module(db), |
537 | GenericDefId::ConstId(it) => it.lookup(db).module(db), | 549 | GenericDefId::ConstId(it) => it.lookup(db).module(db), |
538 | } | 550 | } |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index a80067979..b33507a9a 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -24,7 +24,7 @@ use crate::{ | |||
24 | }, | 24 | }, |
25 | path::{Path, PathKind}, | 25 | path::{Path, PathKind}, |
26 | per_ns::PerNs, | 26 | per_ns::PerNs, |
27 | AdtId, AstId, AstItemDef, ConstLoc, ContainerId, EnumId, EnumVariantId, FunctionLoc, ImplId, | 27 | AdtId, AstId, AstItemDef, ConstLoc, ContainerId, EnumId, EnumVariantId, FunctionLoc, ImplLoc, |
28 | Intern, LocalImportId, LocalModuleId, LocationCtx, ModuleDefId, ModuleId, StaticLoc, StructId, | 28 | Intern, LocalImportId, LocalModuleId, LocationCtx, ModuleDefId, ModuleId, StaticLoc, StructId, |
29 | TraitId, TypeAliasLoc, UnionId, | 29 | TraitId, TypeAliasLoc, UnionId, |
30 | }; | 30 | }; |
@@ -661,9 +661,11 @@ 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 ctx = LocationCtx::new(self.def_collector.db, module, self.file_id); | 664 | let ast_id = self.raw_items[imp].ast_id; |
665 | let imp_id = ImplId::from_ast_id(ctx, self.raw_items[imp].ast_id); | 665 | let impl_id = |
666 | self.def_collector.def_map.modules[self.module_id].impls.push(imp_id) | 666 | ImplLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } |
667 | .intern(self.def_collector.db); | ||
668 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) | ||
667 | } | 669 | } |
668 | } | 670 | } |
669 | } | 671 | } |
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 9484a61d5..f87b16b44 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -564,7 +564,8 @@ impl HasResolver for TypeAliasId { | |||
564 | 564 | ||
565 | impl HasResolver for ImplId { | 565 | impl HasResolver for ImplId { |
566 | fn resolver(self, db: &impl DefDatabase) -> Resolver { | 566 | fn resolver(self, db: &impl DefDatabase) -> Resolver { |
567 | self.module(db) | 567 | self.lookup(db) |
568 | .container | ||
568 | .resolver(db) | 569 | .resolver(db) |
569 | .push_generic_params_scope(db, self.into()) | 570 | .push_generic_params_scope(db, self.into()) |
570 | .push_impl_block_scope(self) | 571 | .push_impl_block_scope(self) |
diff --git a/crates/ra_hir_def/src/src.rs b/crates/ra_hir_def/src/src.rs index 27caa02cc..a5c4359a7 100644 --- a/crates/ra_hir_def/src/src.rs +++ b/crates/ra_hir_def/src/src.rs | |||
@@ -4,7 +4,7 @@ use hir_expand::InFile; | |||
4 | use ra_arena::map::ArenaMap; | 4 | use ra_arena::map::ArenaMap; |
5 | use ra_syntax::ast; | 5 | use ra_syntax::ast; |
6 | 6 | ||
7 | use crate::{db::DefDatabase, ConstLoc, FunctionLoc, StaticLoc, TypeAliasLoc}; | 7 | use crate::{db::DefDatabase, ConstLoc, FunctionLoc, ImplLoc, StaticLoc, TypeAliasLoc}; |
8 | 8 | ||
9 | pub trait HasSource { | 9 | pub trait HasSource { |
10 | type Value; | 10 | type Value; |
@@ -47,6 +47,15 @@ impl HasSource for StaticLoc { | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | impl HasSource for ImplLoc { | ||
51 | type Value = ast::ImplBlock; | ||
52 | |||
53 | fn source(&self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> { | ||
54 | let node = self.ast_id.to_node(db); | ||
55 | InFile::new(self.ast_id.file_id, node) | ||
56 | } | ||
57 | } | ||
58 | |||
50 | pub trait HasChildSource { | 59 | pub trait HasChildSource { |
51 | type ChildId; | 60 | type ChildId; |
52 | type Value; | 61 | type Value; |
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 7220d6e0a..848e306e9 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs | |||
@@ -6,8 +6,8 @@ use std::sync::Arc; | |||
6 | 6 | ||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use hir_def::{ | 8 | use hir_def::{ |
9 | lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AssocItemId, AstItemDef, | 9 | lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AssocItemId, FunctionId, |
10 | FunctionId, HasModule, ImplId, Lookup, TraitId, | 10 | HasModule, ImplId, Lookup, TraitId, |
11 | }; | 11 | }; |
12 | use hir_expand::name::Name; | 12 | use hir_expand::name::Name; |
13 | use ra_db::CrateId; | 13 | use ra_db::CrateId; |
@@ -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.module(db).krate) | 137 | .map(|it| it.lookup(db).container.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 1e7ff93d5..ff299f511 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.module(db).krate == krate { | 676 | let impl_type = if impl_id.lookup(db).container.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 |