diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/krate.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 6 |
2 files changed, 6 insertions, 13 deletions
diff --git a/crates/ra_hir/src/code_model_impl/krate.rs b/crates/ra_hir/src/code_model_impl/krate.rs index cdd30b402..86f29d959 100644 --- a/crates/ra_hir/src/code_model_impl/krate.rs +++ b/crates/ra_hir/src/code_model_impl/krate.rs | |||
@@ -1,31 +1,28 @@ | |||
1 | use ra_db::CrateId; | ||
2 | |||
3 | use crate::{ | 1 | use crate::{ |
4 | Crate, CrateDependency, AsName, Module, | 2 | Crate, CrateDependency, AsName, Module, |
5 | db::HirDatabase, | 3 | db::HirDatabase, |
6 | }; | 4 | }; |
7 | 5 | ||
8 | impl Crate { | 6 | impl Crate { |
9 | pub(crate) fn new(crate_id: CrateId) -> Crate { | ||
10 | Crate { crate_id } | ||
11 | } | ||
12 | pub(crate) fn dependencies_impl(&self, db: &impl HirDatabase) -> Vec<CrateDependency> { | 7 | pub(crate) fn dependencies_impl(&self, db: &impl HirDatabase) -> Vec<CrateDependency> { |
13 | let crate_graph = db.crate_graph(); | 8 | let crate_graph = db.crate_graph(); |
14 | crate_graph | 9 | crate_graph |
15 | .dependencies(self.crate_id) | 10 | .dependencies(self.crate_id) |
16 | .map(|dep| { | 11 | .map(|dep| { |
17 | let krate = Crate::new(dep.crate_id()); | 12 | let krate = Crate { |
13 | crate_id: dep.crate_id(), | ||
14 | }; | ||
18 | let name = dep.as_name(); | 15 | let name = dep.as_name(); |
19 | CrateDependency { krate, name } | 16 | CrateDependency { krate, name } |
20 | }) | 17 | }) |
21 | .collect() | 18 | .collect() |
22 | } | 19 | } |
23 | pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> { | 20 | pub(crate) fn root_module_impl(&self, db: &impl HirDatabase) -> Option<Module> { |
24 | let module_tree = db.module_tree(self.crate_id); | 21 | let module_tree = db.module_tree(*self); |
25 | let module_id = module_tree.modules().next()?; | 22 | let module_id = module_tree.modules().next()?; |
26 | 23 | ||
27 | let module = Module { | 24 | let module = Module { |
28 | krate: self.crate_id, | 25 | krate: *self, |
29 | module_id, | 26 | module_id, |
30 | }; | 27 | }; |
31 | Some(module) | 28 | Some(module) |
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index c6f85ac82..4a3901b8b 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ast, SyntaxNode, TreeArc}; | |||
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | Module, ModuleSource, Problem, | 5 | Module, ModuleSource, Problem, |
6 | Crate, Name, | 6 | Name, |
7 | module_tree::ModuleId, | 7 | module_tree::ModuleId, |
8 | impl_block::ImplId, | 8 | impl_block::ImplId, |
9 | nameres::{lower::ImportId}, | 9 | nameres::{lower::ImportId}, |
@@ -67,10 +67,6 @@ impl Module { | |||
67 | source_map.get(&source, impl_id) | 67 | source_map.get(&source, impl_id) |
68 | } | 68 | } |
69 | 69 | ||
70 | pub(crate) fn krate_impl(&self, _db: &impl HirDatabase) -> Option<Crate> { | ||
71 | Some(Crate::new(self.krate)) | ||
72 | } | ||
73 | |||
74 | pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Module { | 70 | pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Module { |
75 | let module_tree = db.module_tree(self.krate); | 71 | let module_tree = db.module_tree(self.krate); |
76 | let module_id = self.module_id.crate_root(&module_tree); | 72 | let module_id = self.module_id.crate_root(&module_tree); |