Support `use self::...` statements as they are sometimes use for submodules
authorMatt Corallo <git@bluematt.me>
Wed, 24 Nov 2021 18:07:57 +0000 (18:07 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 30 Nov 2021 16:05:44 +0000 (16:05 +0000)
c-bindings-gen/src/types.rs

index cd537522505615082ae2e99edef5eca1fd4c142e..f5417010aeafa4aae98a5ba82b7d0ee9375a4924 100644 (file)
@@ -415,6 +415,11 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
                                        for module in super_mod.split("::") {
                                                path.push(syn::PathSegment { ident: syn::Ident::new(module, Span::call_site()), arguments: syn::PathArguments::None });
                                        }
+                               } else if partial_path == "" && format!("{}", $ident) == "self" {
+                                       new_path = format!("{}{}", module_path, $path_suffix);
+                                       for module in module_path.split("::") {
+                                               path.push(syn::PathSegment { ident: syn::Ident::new(module, Span::call_site()), arguments: syn::PathArguments::None });
+                                       }
                                } else if partial_path == "" && format!("{}", $ident) == "crate" {
                                        new_path = format!("{}{}", crate_name, $path_suffix);
                                        let crate_name_ident = format_ident!("{}", crate_name);