Consider nested interface module paths in src_dir

This commit is contained in:
Richard Feldman 2022-07-08 17:56:30 -04:00
parent a6d99aa357
commit 9cc658119e
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -1136,7 +1136,40 @@ impl<'a> LoadStart<'a> {
);
match res_loaded {
Ok(good) => good,
Ok((module_id, msg)) => match &msg {
Msg::Header(ModuleHeader {
module_id: header_id,
module_name,
module_path,
is_root_module,
..
}) => {
debug_assert_eq!(*header_id, module_id);
debug_assert!(is_root_module);
match &module_name {
ModuleNameEnum::Interface(name) => {
// Interface modules can have names like Foo.Bar.Baz,
// in which case we need to adjust the src_dir to
// remove the "Bar/Baz" directories in order to correctly
// resolve this interface module's imports!
let dirs_to_pop = name.as_str().matches('.').count();
if dirs_to_pop > 0 {
for _ in 0..dirs_to_pop {
src_dir.pop();
}
(module_id, msg)
} else {
(module_id, msg)
}
}
_ => (module_id, msg),
}
}
_ => (module_id, msg),
},
Err(LoadingProblem::ParsingFailed(problem)) => {
let module_ids = Arc::try_unwrap(arc_modules)