From 3e06be96893dc608b6de44f2041869873b56e41d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 22 Jul 2023 20:03:11 +0000 Subject: [PATCH] Allow generation of manual types in reference options The limiting of supported types in `write_template_generics` isn't super useful as its only called once per type - later uses of the same type with the reference flag set or wiped doesn't change anything. Still, it is relied on somewhat, so we can't drop it entirely. Now that we've moved more of the `[u8; 32]` newtypes to option wrappers, failing for non-primitive references spuriously breaks. Instead, we just allow it for manually-mapped types and let the compiler complain if we do something invalid. --- c-bindings-gen/src/types.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index e18c465..dc8c3b9 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -2681,17 +2681,14 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { } else { unimplemented!(); } } else if let syn::Type::Path(p_arg) = t { if let Some(resolved) = self.maybe_resolve_path(&p_arg.path, generics) { - if !self.is_primitive(&resolved) { + if !self.is_primitive(&resolved) && self.c_type_from_path(&resolved, false, false).is_none() { if is_ref { // We don't currently support outer reference types for non-primitive inners return false; } } } else { - if is_ref { - // We don't currently support outer reference types for non-primitive inners - return false; - } + return false; } if !self.write_c_type_intern(w, t, generics, false, false, false, true, true) { return false; } } else { -- 2.39.5