diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/mod_resolution.rs | 7 |
2 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index b8f6aac8f..cbce04315 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -777,11 +777,11 @@ impl ModCollector<'_, '_> { | |||
777 | name, | 777 | name, |
778 | path_attr, | 778 | path_attr, |
779 | ) { | 779 | ) { |
780 | Ok((file_id, mod_dir)) => { | 780 | Ok((file_id, is_mod_rs, mod_dir)) => { |
781 | let module_id = self.push_child_module( | 781 | let module_id = self.push_child_module( |
782 | name.clone(), | 782 | name.clone(), |
783 | ast_id, | 783 | ast_id, |
784 | Some(file_id), | 784 | Some((file_id, is_mod_rs)), |
785 | &visibility, | 785 | &visibility, |
786 | ); | 786 | ); |
787 | let raw_items = self.def_collector.db.raw_items(file_id.into()); | 787 | let raw_items = self.def_collector.db.raw_items(file_id.into()); |
@@ -814,7 +814,7 @@ impl ModCollector<'_, '_> { | |||
814 | &mut self, | 814 | &mut self, |
815 | name: Name, | 815 | name: Name, |
816 | declaration: AstId<ast::Module>, | 816 | declaration: AstId<ast::Module>, |
817 | definition: Option<FileId>, | 817 | definition: Option<(FileId, bool)>, |
818 | visibility: &crate::visibility::RawVisibility, | 818 | visibility: &crate::visibility::RawVisibility, |
819 | ) -> LocalModuleId { | 819 | ) -> LocalModuleId { |
820 | let vis = self | 820 | let vis = self |
@@ -827,7 +827,9 @@ impl ModCollector<'_, '_> { | |||
827 | modules[res].parent = Some(self.module_id); | 827 | modules[res].parent = Some(self.module_id); |
828 | modules[res].origin = match definition { | 828 | modules[res].origin = match definition { |
829 | None => ModuleOrigin::Inline { definition: declaration }, | 829 | None => ModuleOrigin::Inline { definition: declaration }, |
830 | Some(definition) => ModuleOrigin::File { declaration, definition }, | 830 | Some((definition, is_mod_rs)) => { |
831 | ModuleOrigin::File { declaration, definition, is_mod_rs } | ||
832 | } | ||
831 | }; | 833 | }; |
832 | for (name, mac) in modules[self.module_id].scope.collect_legacy_macros() { | 834 | for (name, mac) in modules[self.module_id].scope.collect_legacy_macros() { |
833 | modules[res].scope.define_legacy_macro(name, mac) | 835 | modules[res].scope.define_legacy_macro(name, mac) |
diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index 19fe0615a..39e9a6d97 100644 --- a/crates/ra_hir_def/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs | |||
@@ -44,7 +44,7 @@ impl ModDir { | |||
44 | file_id: HirFileId, | 44 | file_id: HirFileId, |
45 | name: &Name, | 45 | name: &Name, |
46 | attr_path: Option<&SmolStr>, | 46 | attr_path: Option<&SmolStr>, |
47 | ) -> Result<(FileId, ModDir), String> { | 47 | ) -> Result<(FileId, bool, ModDir), String> { |
48 | let file_id = file_id.original_file(db.upcast()); | 48 | let file_id = file_id.original_file(db.upcast()); |
49 | 49 | ||
50 | let mut candidate_files = Vec::new(); | 50 | let mut candidate_files = Vec::new(); |
@@ -64,11 +64,12 @@ impl ModDir { | |||
64 | if let Some(file_id) = db.resolve_path(file_id, candidate.as_str()) { | 64 | if let Some(file_id) = db.resolve_path(file_id, candidate.as_str()) { |
65 | let mut root_non_dir_owner = false; | 65 | let mut root_non_dir_owner = false; |
66 | let mut mod_path = RelativePathBuf::new(); | 66 | let mut mod_path = RelativePathBuf::new(); |
67 | if !(candidate.ends_with("mod.rs") || attr_path.is_some()) { | 67 | let is_mod_rs = candidate.ends_with("mod.rs"); |
68 | if !(is_mod_rs || attr_path.is_some()) { | ||
68 | root_non_dir_owner = true; | 69 | root_non_dir_owner = true; |
69 | mod_path.push(&name.to_string()); | 70 | mod_path.push(&name.to_string()); |
70 | } | 71 | } |
71 | return Ok((file_id, ModDir { path: mod_path, root_non_dir_owner })); | 72 | return Ok((file_id, is_mod_rs, ModDir { path: mod_path, root_non_dir_owner })); |
72 | } | 73 | } |
73 | } | 74 | } |
74 | Err(candidate_files.remove(0)) | 75 | Err(candidate_files.remove(0)) |