From: Matt Corallo Date: Fri, 2 Oct 2020 01:32:39 +0000 (-0400) Subject: [bindings] Drop one static-lifetime restriction and check success X-Git-Tag: v0.0.12~7^2~10 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=6df3aa76c300979ff34847830e4caaa787511825;p=rust-lightning [bindings] Drop one static-lifetime restriction and check success 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. --- diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index c7a13fe0d..5375c4240 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -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) => {