diff options
author | Erlend Tobiassen <[email protected]> | 2019-01-26 12:12:55 +0000 |
---|---|---|
committer | Erlend Tobiassen <[email protected]> | 2019-01-27 14:19:38 +0000 |
commit | c5e6db16b1def5d481358489a3c6d9a6fd5cbdf4 (patch) | |
tree | 2786fbe5e8973985e980ed718034547cd5bf1b43 | |
parent | 683e5e64f42b6c74596015c5d19e2eab186fe68d (diff) |
fix #668
-rw-r--r-- | crates/ra_hir/src/module_tree.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs index d1dc3fa4b..7caebab0d 100644 --- a/crates/ra_hir/src/module_tree.rs +++ b/crates/ra_hir/src/module_tree.rs | |||
@@ -172,6 +172,7 @@ impl ModuleTree { | |||
172 | file_id: HirFileId, | 172 | file_id: HirFileId, |
173 | decl_id: Option<SourceFileItemId>, | 173 | decl_id: Option<SourceFileItemId>, |
174 | ) -> ModuleId { | 174 | ) -> ModuleId { |
175 | let is_root = parent.is_none(); | ||
175 | let id = self.alloc_mod(ModuleData { | 176 | let id = self.alloc_mod(ModuleData { |
176 | file_id, | 177 | file_id, |
177 | decl_id, | 178 | decl_id, |
@@ -295,6 +296,7 @@ fn resolve_submodule( | |||
295 | db: &impl HirDatabase, | 296 | db: &impl HirDatabase, |
296 | file_id: HirFileId, | 297 | file_id: HirFileId, |
297 | name: &Name, | 298 | name: &Name, |
299 | is_root: bool, | ||
298 | ) -> (Vec<FileId>, Option<Problem>) { | 300 | ) -> (Vec<FileId>, Option<Problem>) { |
299 | // FIXME: handle submodules of inline modules properly | 301 | // FIXME: handle submodules of inline modules properly |
300 | let file_id = file_id.original_file(db); | 302 | let file_id = file_id.original_file(db); |
@@ -303,7 +305,7 @@ fn resolve_submodule( | |||
303 | let root = RelativePathBuf::default(); | 305 | let root = RelativePathBuf::default(); |
304 | let dir_path = path.parent().unwrap_or(&root); | 306 | let dir_path = path.parent().unwrap_or(&root); |
305 | let mod_name = path.file_stem().unwrap_or("unknown"); | 307 | let mod_name = path.file_stem().unwrap_or("unknown"); |
306 | let is_dir_owner = mod_name == "mod" || mod_name == "lib" || mod_name == "main"; | 308 | let is_dir_owner = is_root || mod_name == "mod"; |
307 | 309 | ||
308 | let file_mod = dir_path.join(format!("{}.rs", name)); | 310 | let file_mod = dir_path.join(format!("{}.rs", name)); |
309 | let dir_mod = dir_path.join(format!("{}/mod.rs", name)); | 311 | let dir_mod = dir_path.join(format!("{}/mod.rs", name)); |