Skip to content

Commit 4b3fb77

Browse files
committed
Correct use resolution for submodule use statements
Otherwise we fail to resolve a `use` that starts with a submodule of the current module.
1 parent 177b197 commit 4b3fb77

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

c-bindings-gen/src/types.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,12 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
474474
let crate_name_ident = format_ident!("{}", crate_name);
475475
path.push(parse_quote!(#crate_name_ident));
476476
} else if partial_path == "" && !dependencies.contains(&$ident) {
477-
new_path = format!("{}::{}{}", crate_name, $ident, $path_suffix);
478-
let crate_name_ident = format_ident!("{}", crate_name);
479-
path.push(parse_quote!(#crate_name_ident));
477+
new_path = format!("{}::{}{}", module_path, $ident, $path_suffix);
478+
for module in module_path.split("::") {
479+
path.push(syn::PathSegment { ident: syn::Ident::new(module, Span::call_site()), arguments: syn::PathArguments::None });
480+
}
481+
let ident_str = format_ident!("{}", $ident);
482+
path.push(parse_quote!(#ident_str));
480483
} else if format!("{}", $ident) == "self" {
481484
let mut path_iter = partial_path.rsplitn(2, "::");
482485
path_iter.next().unwrap();

0 commit comments

Comments
 (0)