From 6df3aa76c300979ff34847830e4caaa787511825 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 1 Oct 2020 21:32:39 -0400 Subject: [PATCH] [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. --- c-bindings-gen/src/types.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index c7a13fe0..5375c424 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) => { -- 2.30.2