diff options
author | Aleksey Kladov <[email protected]> | 2019-12-12 13:58:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-12 13:58:04 +0000 |
commit | f135a8ea55c0a46c67713fb3b79b5f62ada430c1 (patch) | |
tree | a71a0c4da21cb40c35b6aed842d9664cbec8a59d /crates/ra_hir/src | |
parent | 63c192b34a54e826afebc735ca6225b44a876eab (diff) |
Move structs to new loc
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 4 | ||||
-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, 7 insertions, 5 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 78c7792bf..8588aa5a3 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -269,7 +269,7 @@ pub struct Struct { | |||
269 | 269 | ||
270 | impl Struct { | 270 | impl Struct { |
271 | pub fn module(self, db: &impl DefDatabase) -> Module { | 271 | pub fn module(self, db: &impl DefDatabase) -> Module { |
272 | Module { id: self.id.module(db) } | 272 | Module { id: self.id.lookup(db).container } |
273 | } | 273 | } |
274 | 274 | ||
275 | pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> { | 275 | pub fn krate(self, db: &impl DefDatabase) -> Option<Crate> { |
@@ -290,7 +290,7 @@ impl Struct { | |||
290 | } | 290 | } |
291 | 291 | ||
292 | pub fn ty(self, db: &impl HirDatabase) -> Type { | 292 | pub fn ty(self, db: &impl HirDatabase) -> Type { |
293 | Type::from_def(db, self.id.module(db).krate, self.id) | 293 | Type::from_def(db, self.id.lookup(db).container.krate, self.id) |
294 | } | 294 | } |
295 | 295 | ||
296 | fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { | 296 | fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { |
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 091349d49..978326c74 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -23,8 +23,10 @@ pub trait FromSource: Sized { | |||
23 | impl FromSource for Struct { | 23 | impl FromSource for Struct { |
24 | type Ast = ast::StructDef; | 24 | type Ast = ast::StructDef; |
25 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> { | 25 | fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> { |
26 | let id = from_source(db, src)?; | 26 | analyze_container(db, src.as_ref().map(|it| it.syntax()))[keys::STRUCT] |
27 | Some(Struct { id }) | 27 | .get(&src) |
28 | .copied() | ||
29 | .map(Struct::from) | ||
28 | } | 30 | } |
29 | } | 31 | } |
30 | impl FromSource for Union { | 32 | impl FromSource for Union { |
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index c4c6d66b7..8f35a3fbb 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs | |||
@@ -51,7 +51,7 @@ impl HasSource for StructField { | |||
51 | impl HasSource for Struct { | 51 | impl HasSource for Struct { |
52 | type Ast = ast::StructDef; | 52 | type Ast = ast::StructDef; |
53 | fn source(self, db: &impl DefDatabase) -> InFile<ast::StructDef> { | 53 | fn source(self, db: &impl DefDatabase) -> InFile<ast::StructDef> { |
54 | self.id.source(db) | 54 | self.id.lookup(db).source(db) |
55 | } | 55 | } |
56 | } | 56 | } |
57 | impl HasSource for Union { | 57 | impl HasSource for Union { |