diff options
author | Aleksey Kladov <[email protected]> | 2019-12-12 13:09:13 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-12 13:25:34 +0000 |
commit | 7b0644d81e52d00a7a6795b187f356213ff68225 (patch) | |
tree | 88da767605960bb672934c091489d3aad826f17a /crates/ra_hir | |
parent | b0739d5a26684527129882b7d182d01e635525bc (diff) |
Switch to the new location for impls
Diffstat (limited to 'crates/ra_hir')
-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 |
3 files changed, 10 insertions, 5 deletions
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 { |