]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Handle type resolution of `crate::thing` without a `use crate`
authorMatt Corallo <git@bluematt.me>
Sun, 18 Apr 2021 00:43:21 +0000 (00:43 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 26 Apr 2021 17:26:03 +0000 (17:26 +0000)
c-bindings-gen/src/types.rs

index b0a410e208f01e9ff6f941234df862bbb4645c90..567cc7dbf0e602ee1c29035502c485d1b020af7a 100644 (file)
@@ -517,9 +517,7 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
                                format!("::{}", seg.ident)
                        }).collect();
                        let first_seg_str = format!("{}", first_seg.ident);
-                       if first_seg_str == "std" {
-                               Some(first_seg_str + &remaining)
-                       } else if let Some((imp, _)) = self.imports.get(&first_seg.ident) {
+                       if let Some((imp, _)) = self.imports.get(&first_seg.ident) {
                                if remaining != "" {
                                        Some(imp.clone() + &remaining)
                                } else {
@@ -527,6 +525,8 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
                                }
                        } else if let Some(_) = self.priv_modules.get(&first_seg.ident) {
                                Some(format!("{}::{}{}", self.module_path, first_seg.ident, remaining))
+                       } else if first_seg_str == "std" || self.dependencies.contains(&first_seg.ident) {
+                               Some(first_seg_str + &remaining)
                        } else { None }
                }
        }