From 3bb9efb6b70445076858ab72bebbbd7e31347307 Mon Sep 17 00:00:00 2001 From: Yilin Chen Date: Sun, 21 Mar 2021 23:02:01 +0800 Subject: use the included file as the source of expanded include macro Signed-off-by: Yilin Chen --- crates/hir_def/src/nameres/mod_resolution.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/hir_def/src/nameres/mod_resolution.rs') 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 { name: &Name, attr_path: Option<&SmolStr>, ) -> Result<(FileId, bool, ModDir), String> { + let is_include_macro = file_id.is_include_macro(db.upcast()); let file_id = file_id.original_file(db.upcast()); let mut candidate_files = Vec::new(); @@ -70,8 +71,13 @@ impl ModDir { candidate_files.push(self.dir_path.join_attr(attr_path, self.root_non_dir_owner)) } None => { - candidate_files.push(format!("{}{}.rs", self.dir_path.0, name)); - candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name)); + if is_include_macro { + candidate_files.push(format!("{}.rs", name)); + candidate_files.push(format!("{}/mod.rs", name)); + } else { + candidate_files.push(format!("{}{}.rs", self.dir_path.0, name)); + candidate_files.push(format!("{}{}/mod.rs", self.dir_path.0, name)); + } } }; -- cgit v1.2.3