From f135a8ea55c0a46c67713fb3b79b5f62ada430c1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 12 Dec 2019 14:58:04 +0100 Subject: Move structs to new loc --- crates/ra_hir/src/code_model.rs | 4 ++-- crates/ra_hir/src/from_source.rs | 6 ++++-- crates/ra_hir/src/has_source.rs | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src') 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 { impl Struct { pub fn module(self, db: &impl DefDatabase) -> Module { - Module { id: self.id.module(db) } + Module { id: self.id.lookup(db).container } } pub fn krate(self, db: &impl DefDatabase) -> Option { @@ -290,7 +290,7 @@ impl Struct { } pub fn ty(self, db: &impl HirDatabase) -> Type { - Type::from_def(db, self.id.module(db).krate, self.id) + Type::from_def(db, self.id.lookup(db).container.krate, self.id) } fn variant_data(self, db: &impl DefDatabase) -> Arc { 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 { impl FromSource for Struct { type Ast = ast::StructDef; fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile) -> Option { - let id = from_source(db, src)?; - Some(Struct { id }) + analyze_container(db, src.as_ref().map(|it| it.syntax()))[keys::STRUCT] + .get(&src) + .copied() + .map(Struct::from) } } 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 { impl HasSource for Struct { type Ast = ast::StructDef; fn source(self, db: &impl DefDatabase) -> InFile { - self.id.source(db) + self.id.lookup(db).source(db) } } impl HasSource for Union { -- cgit v1.2.3