aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-12 13:34:03 +0000
committerAleksey Kladov <[email protected]>2019-12-12 13:36:14 +0000
commit82e9b245587046d2a1ed432225b19023adbe3245 (patch)
treeacabb715858003dcab9af2810065b8fe40095e90 /crates/ra_hir
parent7b0644d81e52d00a7a6795b187f356213ff68225 (diff)
Move traits to the new loc
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs2
-rw-r--r--crates/ra_hir/src/from_source.rs6
-rw-r--r--crates/ra_hir/src/has_source.rs2
3 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 117ca2fe3..78c7792bf 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -577,7 +577,7 @@ pub struct Trait {
577 577
578impl Trait { 578impl Trait {
579 pub fn module(self, db: &impl DefDatabase) -> Module { 579 pub fn module(self, db: &impl DefDatabase) -> Module {
580 Module { id: self.id.module(db) } 580 Module { id: self.id.lookup(db).container }
581 } 581 }
582 582
583 pub fn name(self, db: &impl DefDatabase) -> Name { 583 pub fn name(self, db: &impl DefDatabase) -> Name {
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index b35188a21..0cf4bcae1 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -44,8 +44,10 @@ impl FromSource for Enum {
44impl FromSource for Trait { 44impl FromSource for Trait {
45 type Ast = ast::TraitDef; 45 type Ast = ast::TraitDef;
46 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> { 46 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
47 let id = from_source(db, src)?; 47 // XXX: use `.parent()` to avoid finding ourselves
48 Some(Trait { id }) 48 let parent = src.value.syntax().parent()?;
49 let container = Container::find(db, src.with_value(parent).as_ref())?;
50 container.child_by_source(db)[keys::TRAIT].get(&src).copied().map(Trait::from)
49 } 51 }
50} 52}
51impl FromSource for Function { 53impl FromSource for Function {
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs
index a888fe995..c4c6d66b7 100644
--- a/crates/ra_hir/src/has_source.rs
+++ b/crates/ra_hir/src/has_source.rs
@@ -93,7 +93,7 @@ impl HasSource for Static {
93impl HasSource for Trait { 93impl HasSource for Trait {
94 type Ast = ast::TraitDef; 94 type Ast = ast::TraitDef;
95 fn source(self, db: &impl DefDatabase) -> InFile<ast::TraitDef> { 95 fn source(self, db: &impl DefDatabase) -> InFile<ast::TraitDef> {
96 self.id.source(db) 96 self.id.lookup(db).source(db)
97 } 97 }
98} 98}
99impl HasSource for TypeAlias { 99impl HasSource for TypeAlias {