From 5cedb5e37f5d9272053dd94ebe255c6f83325af2 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Sat, 14 Aug 2021 00:08:43 +0300 Subject: [PATCH] lang: ignore unnamed structs instead of panic --- CHANGELOG.md | 4 ++++ lang/syn/src/idl/file.rs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a14079928b..009d9175f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ incremented for features. ## [Unreleased] +### Features + +* lang: Ignore `Unnamed` structs instead of panic ([#605](https://github.com/project-serum/anchor/pull/605)). + ## [0.13.2] - 2021-08-11 ### Fixes diff --git a/lang/syn/src/idl/file.rs b/lang/syn/src/idl/file.rs index f0eb0badfd..8789ccc05a 100644 --- a/lang/syn/src/idl/file.rs +++ b/lang/syn/src/idl/file.rs @@ -384,7 +384,8 @@ fn parse_ty_defs(ctx: &CrateContext) -> Result> { }) }) .collect::>>(), - _ => panic!("Only named structs are allowed."), + syn::Fields::Unnamed(_) => return None, + _ => panic!("Empty structs are allowed."), }; Some(fields.map(|fields| IdlTypeDefinition {