]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Support `use crate::*` statements
authorMatt Corallo <git@bluematt.me>
Sun, 31 Oct 2021 18:13:00 +0000 (18:13 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 2 Nov 2021 16:54:45 +0000 (16:54 +0000)
c-bindings-gen/src/types.rs

index 0cc442577bf6648ebf4b8ad45e5bbb92e14ce1a1..18f6a0c051671b374e1a60ae87e3449855bd024b 100644 (file)
@@ -410,6 +410,10 @@ 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) == "crate" {
+                                       new_path = format!("{}{}", crate_name, $path_suffix);
+                                       let crate_name_ident = format_ident!("{}", crate_name);
+                                       path.push(parse_quote!(#crate_name_ident));
                                } else if partial_path == "" && !dependencies.contains(&$ident) {
                                        new_path = format!("{}::{}{}", crate_name, $ident, $path_suffix);
                                        let crate_name_ident = format_ident!("{}", crate_name);