diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-23 16:53:56 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-23 16:53:56 +0100 |
commit | 0c12c4f9609ee72487af9b55a558b01af73ffe3e (patch) | |
tree | 29be52a980b4cae72f46a48c48135a15e31641e0 /crates/ra_hir_def/src/nameres | |
parent | 7aa66371ee3e8b31217513204c8b4f683584419d (diff) | |
parent | dad1333b48c38bc7a5628fc0ff5304d003776a85 (diff) |
Merge #4976
4976: New VFS r=matklad a=matklad
Still a draft, but mostly working already.
Co-authored-by: Aleksey Kladov <[email protected]>
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)) |