diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs
index d5de9899cfa..afb06fd825b 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));
+ }
}
};
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 8529b43b6d3..4d52904b94b 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -43,7 +43,7 @@ macro_rules! register_builtin {
db: &dyn AstDatabase,
arg_id: EagerMacroId,
tt: &tt::Subtree,
- ) -> ExpandResult