From c5e6db16b1def5d481358489a3c6d9a6fd5cbdf4 Mon Sep 17 00:00:00 2001 From: Erlend Tobiassen Date: Sat, 26 Jan 2019 13:12:55 +0100 Subject: fix #668 --- crates/ra_hir/src/module_tree.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src') 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 { file_id: HirFileId, decl_id: Option, ) -> ModuleId { + let is_root = parent.is_none(); let id = self.alloc_mod(ModuleData { file_id, decl_id, @@ -295,6 +296,7 @@ fn resolve_submodule( db: &impl HirDatabase, file_id: HirFileId, name: &Name, + is_root: bool, ) -> (Vec, Option) { // FIXME: handle submodules of inline modules properly let file_id = file_id.original_file(db); @@ -303,7 +305,7 @@ fn resolve_submodule( let root = RelativePathBuf::default(); let dir_path = path.parent().unwrap_or(&root); let mod_name = path.file_stem().unwrap_or("unknown"); - let is_dir_owner = mod_name == "mod" || mod_name == "lib" || mod_name == "main"; + let is_dir_owner = is_root || mod_name == "mod"; let file_mod = dir_path.join(format!("{}.rs", name)); let dir_mod = dir_path.join(format!("{}/mod.rs", name)); -- cgit v1.2.3