]> git.bitcoin.ninja Git - rust-lightning/commitdiff
[bindings] Drop one static-lifetime restriction and check success
authorMatt Corallo <git@bluematt.me>
Fri, 2 Oct 2020 01:32:39 +0000 (21:32 -0400)
committerMatt Corallo <git@bluematt.me>
Wed, 21 Oct 2020 18:50:22 +0000 (14:50 -0400)
In general we should stop enforcing that all lifetimes are static
- we may take references from C and its up to reviewing the diff on
the bindings changes and the user(s) to ensure lifetimes are valid.

Also asserts a success criteria that was missed before.

c-bindings-gen/src/types.rs

index c7a13fe0d540bd5e76706075715544f49f70c368..5375c4240655fa90b9975b78facd23adbb7e996d 100644 (file)
@@ -1674,7 +1674,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        write!(w, "#[no_mangle]\npub extern \"C\" fn {}_new(", mangled_container).unwrap();
                        for (idx, gen) in args.iter().enumerate() {
                                write!(w, "{}{}: ", if idx != 0 { ", " } else { "" }, ('a' as u8 + idx as u8) as char).unwrap();
-                               self.write_c_type_intern(w, gen, None, false, false, false);
+                               assert!(self.write_c_type_intern(w, gen, None, false, false, false));
                        }
                        writeln!(w, ") -> {} {{", mangled_container).unwrap();
                        writeln!(w, "\t{} {{", mangled_container).unwrap();
@@ -1963,9 +1963,6 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                self.write_c_path_intern(w, &p.path, generics, is_ref, is_mut, ptr_for_ref)
                        },
                        syn::Type::Reference(r) => {
-                               if let Some(lft) = &r.lifetime {
-                                       if format!("{}", lft.ident) != "static" { return false; }
-                               }
                                self.write_c_type_intern(w, &*r.elem, generics, true, r.mutability.is_some(), ptr_for_ref)
                        },
                        syn::Type::Array(a) => {