aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/mod_resolution.rs
diff options
context:
space:
mode:
authorYilin Chen <[email protected]>2021-03-21 15:02:01 +0000
committerYilin Chen <[email protected]>2021-03-21 15:02:01 +0000
commit3bb9efb6b70445076858ab72bebbbd7e31347307 (patch)
treed8a51ce380e1818ab1afb280942c696e2d05e1ec /crates/hir_def/src/nameres/mod_resolution.rs
parenta0ed87ff56e83eb03910b58a9cb80c35c5639338 (diff)
use the included file as the source of expanded include macro
Signed-off-by: Yilin Chen <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/mod_resolution.rs')
-rw-r--r--crates/hir_def/src/nameres/mod_resolution.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs
index d5de9899c..afb06fd82 100644
--- a/crates/hir_def/src/nameres/mod_resolution.rs
+++ b/crates/hir_def/src/nameres/mod_resolution.rs
@@ -62,6 +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 is_include_macro = file_id.is_include_macro(db.upcast());
65 let file_id = file_id.original_file(db.upcast()); 66 let file_id = file_id.original_file(db.upcast());
66 67
67 let mut candidate_files = Vec::new(); 68 let mut candidate_files = Vec::new();
@@ -70,8 +71,13 @@ impl ModDir {
70 candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner)) 71 candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner))
71 } 72 }
72 None => { 73 None => {
73 candidate_files.push(format!("{}{}.rs", self.dir_path.0, name)); 74 if is_include_macro {
74 candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name)); 75 candidate_files.push(format!("{}.rs", name));
76 candidate_files.push(format!("{}/mod.rs", name));
77 } else {
78 candidate_files.push(format!("{}{}.rs", self.dir_path.0, name));
79 candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name));
80 }
75 } 81 }
76 }; 82 };
77 83