diff options
Diffstat (limited to 'crates/hir_def/src/nameres/mod_resolution.rs')
-rw-r--r-- | crates/hir_def/src/nameres/mod_resolution.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs index d5de9899c..d9cec0e27 100644 --- a/crates/hir_def/src/nameres/mod_resolution.rs +++ b/crates/hir_def/src/nameres/mod_resolution.rs | |||
@@ -62,7 +62,7 @@ impl ModDir { | |||
62 | name: &Name, | 62 | name: &Name, |
63 | attr_path: Option<&SmolStr>, | 63 | attr_path: Option<&SmolStr>, |
64 | ) -> Result<(FileId, bool, ModDir), String> { | 64 | ) -> Result<(FileId, bool, ModDir), String> { |
65 | let file_id = file_id.original_file(db.upcast()); | 65 | let orig_file_id = file_id.original_file(db.upcast()); |
66 | 66 | ||
67 | let mut candidate_files = Vec::new(); | 67 | let mut candidate_files = Vec::new(); |
68 | match attr_path { | 68 | match attr_path { |
@@ -70,13 +70,18 @@ impl ModDir { | |||
70 | candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner)) | 70 | candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner)) |
71 | } | 71 | } |
72 | None => { | 72 | None => { |
73 | candidate_files.push(format!("{}{}.rs", self.dir_path.0, name)); | 73 | if file_id.is_include_macro(db.upcast()) { |
74 | candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name)); | 74 | candidate_files.push(format!("{}.rs", name)); |
75 | candidate_files.push(format!("{}/mod.rs", name)); | ||
76 | } else { | ||
77 | candidate_files.push(format!("{}{}.rs", self.dir_path.0, name)); | ||
78 | candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name)); | ||
79 | } | ||
75 | } | 80 | } |
76 | }; | 81 | }; |
77 | 82 | ||
78 | for candidate in candidate_files.iter() { | 83 | for candidate in candidate_files.iter() { |
79 | let path = AnchoredPath { anchor: file_id, path: candidate.as_str() }; | 84 | let path = AnchoredPath { anchor: orig_file_id, path: candidate.as_str() }; |
80 | if let Some(file_id) = db.resolve_path(path) { | 85 | if let Some(file_id) = db.resolve_path(path) { |
81 | let is_mod_rs = candidate.ends_with("/mod.rs"); | 86 | let is_mod_rs = candidate.ends_with("/mod.rs"); |
82 | 87 | ||