Skip to content

Commit f9c8046

Browse files
twistedfallogoffart
authored andcommitted
Add processing of submodules when they are located in the parent module dir
So now the following module struture is accepted (with child being a submodule of parent): /parent.rs /parent/ /parent/child.rs
1 parent de6a5d2 commit f9c8046

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cpp_build/src/parser.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,19 @@ impl<'ast> Visit<'ast> for Parser {
596596
.parse_mod(subdir)
597597
.unwrap_or_else(|err| self.mod_error = Some(err));
598598
}
599+
600+
let mut adjacent_subdir = self.current_path.clone();
601+
if let Some(cur_mod_dir) = adjacent_subdir.file_stem().map(|x| x.to_owned()) {
602+
adjacent_subdir.pop();
603+
adjacent_subdir.push(cur_mod_dir);
604+
adjacent_subdir.push(format!("{}.rs", mod_name));
605+
if adjacent_subdir.is_file() {
606+
return self
607+
.parse_mod(adjacent_subdir)
608+
.unwrap_or_else(|err| self.mod_error = Some(err));
609+
}
610+
}
611+
599612
let adjacent = self.mod_dir.join(&format!("{}.rs", mod_name));
600613
if adjacent.is_file() {
601614
return self

0 commit comments

Comments
 (0)