aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl/module.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model_impl/module.rs')
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index 775dd6709..2ec3ab469 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -19,7 +19,7 @@ impl Module {
19 source_root_id: SourceRootId, 19 source_root_id: SourceRootId,
20 module_id: ModuleId, 20 module_id: ModuleId,
21 ) -> Cancelable<Self> { 21 ) -> Cancelable<Self> {
22 let module_tree = db.module_tree(source_root_id)?; 22 let module_tree = db.module_tree(source_root_id);
23 let def_loc = DefLoc { 23 let def_loc = DefLoc {
24 kind: DefKind::Module, 24 kind: DefKind::Module,
25 source_root_id, 25 source_root_id,
@@ -33,7 +33,7 @@ impl Module {
33 33
34 pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { 34 pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> {
35 let loc = self.def_id.loc(db); 35 let loc = self.def_id.loc(db);
36 let module_tree = db.module_tree(loc.source_root_id)?; 36 let module_tree = db.module_tree(loc.source_root_id);
37 let link = ctry!(loc.module_id.parent_link(&module_tree)); 37 let link = ctry!(loc.module_id.parent_link(&module_tree));
38 Ok(Some(link.name(&module_tree).clone())) 38 Ok(Some(link.name(&module_tree).clone()))
39 } 39 }
@@ -59,7 +59,7 @@ impl Module {
59 db: &impl HirDatabase, 59 db: &impl HirDatabase,
60 ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> { 60 ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
61 let loc = self.def_id.loc(db); 61 let loc = self.def_id.loc(db);
62 let module_tree = db.module_tree(loc.source_root_id)?; 62 let module_tree = db.module_tree(loc.source_root_id);
63 let link = ctry!(loc.module_id.parent_link(&module_tree)); 63 let link = ctry!(loc.module_id.parent_link(&module_tree));
64 let file_id = link 64 let file_id = link
65 .owner(&module_tree) 65 .owner(&module_tree)
@@ -82,7 +82,7 @@ impl Module {
82 82
83 pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Cancelable<Module> { 83 pub(crate) fn crate_root_impl(&self, db: &impl HirDatabase) -> Cancelable<Module> {
84 let loc = self.def_id.loc(db); 84 let loc = self.def_id.loc(db);
85 let module_tree = db.module_tree(loc.source_root_id)?; 85 let module_tree = db.module_tree(loc.source_root_id);
86 let module_id = loc.module_id.crate_root(&module_tree); 86 let module_id = loc.module_id.crate_root(&module_tree);
87 Module::from_module_id(db, loc.source_root_id, module_id) 87 Module::from_module_id(db, loc.source_root_id, module_id)
88 } 88 }
@@ -90,7 +90,7 @@ impl Module {
90 /// Finds a child module with the specified name. 90 /// Finds a child module with the specified name.
91 pub fn child_impl(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> { 91 pub fn child_impl(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
92 let loc = self.def_id.loc(db); 92 let loc = self.def_id.loc(db);
93 let module_tree = db.module_tree(loc.source_root_id)?; 93 let module_tree = db.module_tree(loc.source_root_id);
94 let child_id = ctry!(loc.module_id.child(&module_tree, name)); 94 let child_id = ctry!(loc.module_id.child(&module_tree, name));
95 Module::from_module_id(db, loc.source_root_id, child_id).map(Some) 95 Module::from_module_id(db, loc.source_root_id, child_id).map(Some)
96 } 96 }
@@ -101,7 +101,7 @@ impl Module {
101 // it's kind of hard since the iterator needs to keep a reference to the 101 // it's kind of hard since the iterator needs to keep a reference to the
102 // module tree. 102 // module tree.
103 let loc = self.def_id.loc(db); 103 let loc = self.def_id.loc(db);
104 let module_tree = db.module_tree(loc.source_root_id)?; 104 let module_tree = db.module_tree(loc.source_root_id);
105 let children = loc 105 let children = loc
106 .module_id 106 .module_id
107 .children(&module_tree) 107 .children(&module_tree)
@@ -112,7 +112,7 @@ impl Module {
112 112
113 pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> { 113 pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
114 let loc = self.def_id.loc(db); 114 let loc = self.def_id.loc(db);
115 let module_tree = db.module_tree(loc.source_root_id)?; 115 let module_tree = db.module_tree(loc.source_root_id);
116 let parent_id = ctry!(loc.module_id.parent(&module_tree)); 116 let parent_id = ctry!(loc.module_id.parent(&module_tree));
117 Module::from_module_id(db, loc.source_root_id, parent_id).map(Some) 117 Module::from_module_id(db, loc.source_root_id, parent_id).map(Some)
118 } 118 }
@@ -190,7 +190,7 @@ impl Module {
190 db: &impl HirDatabase, 190 db: &impl HirDatabase,
191 ) -> Cancelable<Vec<(TreeArc<SyntaxNode>, Problem)>> { 191 ) -> Cancelable<Vec<(TreeArc<SyntaxNode>, Problem)>> {
192 let loc = self.def_id.loc(db); 192 let loc = self.def_id.loc(db);
193 let module_tree = db.module_tree(loc.source_root_id)?; 193 let module_tree = db.module_tree(loc.source_root_id);
194 Ok(loc.module_id.problems(&module_tree, db)) 194 Ok(loc.module_id.problems(&module_tree, db))
195 } 195 }
196} 196}