aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/lib.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 0a59c4ad7..a240a10b8 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -78,14 +78,13 @@ impl ModuleSource {
78 } 78 }
79 } 79 }
80 80
81 pub fn from_child_node( 81 pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource {
82 db: &impl db::DefDatabase2, 82 if let Some(m) =
83 file_id: FileId, 83 child.ast.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
84 child: &SyntaxNode, 84 {
85 ) -> ModuleSource {
86 if let Some(m) = child.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) {
87 ModuleSource::Module(m) 85 ModuleSource::Module(m)
88 } else { 86 } else {
87 let file_id = child.file_id.original_file(db);
89 let source_file = db.parse(file_id).tree(); 88 let source_file = db.parse(file_id).tree();
90 ModuleSource::SourceFile(source_file) 89 ModuleSource::SourceFile(source_file)
91 } 90 }