Handle type references which refer to a module defined in scope
authorMatt Corallo <git@bluematt.me>
Thu, 28 Sep 2023 02:33:58 +0000 (02:33 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 4 Oct 2023 20:02:23 +0000 (20:02 +0000)
eg
```
mod module;
fn a() -> module::Type { todo!() }
```

c-bindings-gen/src/types.rs

index 5f9e5812aa4a4cc56c97ad71fca2fe2bc81c3c8e..6a5f3e25eb633945d4e686f89fa0d6926b601ae1 100644 (file)
@@ -679,6 +679,8 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
                                Some(first_seg_str + &remaining)
                        } else if first_seg_str == "crate" {
                                Some(self.crate_name.to_owned() + &remaining)
+                       } else if self.library.modules.get(&format!("{}::{}", self.module_path, first_seg.ident)).is_some() {
+                               Some(format!("{}::{}{}", self.module_path, first_seg.ident, remaining))
                        } else { None }
                }
        }