]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Use the resolved name, not original ident, for Vec naming
authorMatt Corallo <git@bluematt.me>
Sat, 24 Dec 2022 22:57:55 +0000 (22:57 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 24 Dec 2022 22:59:55 +0000 (22:59 +0000)
This will be useful in the next commit when we rename `u5` to `U5`

c-bindings-gen/src/types.rs

index b022f3255fec41a27efd03701bf8d0ac933b2813..5ced9104b030b44aa78fb6a7586565491cdf9a48 100644 (file)
@@ -2962,12 +2962,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        } else {
                                                let mut inner_c_ty = Vec::new();
                                                assert!(self.write_c_path_intern(&mut inner_c_ty, &p.path, generics, true, false, ptr_for_ref, with_ref_lifetime, c_ty));
-                                               if self.is_clonable(&String::from_utf8(inner_c_ty).unwrap()) {
-                                                       if let Some(id) = p.path.get_ident() {
-                                                               let mangled_container = format!("CVec_{}Z", id);
-                                                               write!(w, "{}::{}", Self::generated_container_path(), mangled_container).unwrap();
-                                                               self.check_create_container(mangled_container, "Vec", vec![&*s.elem], generics, false)
-                                                       } else { false }
+                                               let inner_ty_str = String::from_utf8(inner_c_ty).unwrap();
+                                               if self.is_clonable(&inner_ty_str) {
+                                                       let inner_ty_ident = inner_ty_str.rsplitn(2, "::").next().unwrap();
+                                                       let mangled_container = format!("CVec_{}Z", inner_ty_ident);
+                                                       write!(w, "{}::{}", Self::generated_container_path(), mangled_container).unwrap();
+                                                       self.check_create_container(mangled_container, "Vec", vec![&*s.elem], generics, false)
                                                } else { false }
                                        }
                                } else if let syn::Type::Reference(r) = &*s.elem {