From ff6f1cbdff6f70b3b0058d68def156537058eb99 Mon Sep 17 00:00:00 2001 From: ssadler Date: Tue, 17 Dec 2024 16:59:58 +0100 Subject: [PATCH] Don't include PhantomData fields in IDL structs --- lang/syn/src/idl/defined.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lang/syn/src/idl/defined.rs b/lang/syn/src/idl/defined.rs index 3820d18b21..b0b3301933 100644 --- a/lang/syn/src/idl/defined.rs +++ b/lang/syn/src/idl/defined.rs @@ -86,6 +86,7 @@ pub fn gen_idl_type_def_struct( .map(|f| gen_idl_field(f, generic_params, no_docs)) .collect::>>()? .into_iter() + .filter(|(t,_)| !t.is_empty()) .unzip::<_, _, Vec<_>, Vec<_>>(); ( @@ -100,6 +101,7 @@ pub fn gen_idl_type_def_struct( .map(|f| gen_idl_type(&f.ty, generic_params)) .collect::>>()? .into_iter() + .filter(|(t,_)| !t.is_empty()) .unzip::<_, Vec<_>, Vec<_>, Vec<_>>(); ( @@ -337,6 +339,10 @@ fn gen_idl_field( }; let (ty, defined) = gen_idl_type(&field.ty, generic_params)?; + if ty.is_empty() { + return Ok((ty, defined)); + } + Ok(( quote! { #idl::IdlField { @@ -424,6 +430,9 @@ pub fn gen_idl_type( syn::Type::Path(path) if the_only_segment_is(path, "Pubkey") => { Ok((quote! { #idl::IdlType::Pubkey }, vec![])) } + syn::Type::Path(path) if the_only_segment_is(path, "PhantomData") => { + Ok((TokenStream::new(), vec![])) + } syn::Type::Path(path) if the_only_segment_is(path, "Option") => { let segment = get_first_segment(path); let arg = get_angle_bracketed_type_args(segment)