11use proc_macro2:: { Span , TokenStream } ;
2- use syn:: { Data , DeriveInput , Ident , Field , Visibility , Meta , Lit } ;
2+ use syn:: { Data , DeriveInput , Ident , Field , Visibility , Meta , MetaNameValue , Lit } ;
33use quote:: quote;
44
55/// Representing the struct we are deriving
@@ -25,16 +25,15 @@ impl Input {
2525
2626 let mut derives: Vec < Ident > = vec ! [ ] ;
2727 for attr in input. attrs {
28- if let Some ( meta) = attr. interpret_meta ( ) {
29- if meta. name ( ) == "soa_derive" {
30- if let Meta :: NameValue ( meta ) = meta {
31- if let Lit :: Str ( string) = meta . lit {
28+ if let Ok ( meta) = attr. parse_meta ( ) {
29+ if meta. path ( ) . is_ident ( "soa_derive" ) {
30+ match meta {
31+ Meta :: NameValue ( MetaNameValue { lit : Lit :: Str ( string) , .. } ) => {
3232 for value in string. value ( ) . split ( ',' ) {
3333 derives. push ( Ident :: new ( value. trim ( ) , Span :: call_site ( ) ) ) ;
3434 }
3535 }
36- } else {
37- panic ! ( "expected #[soa_derive = \" Traits, To, Derive\" ], got {}" , "meta TODO" )
36+ _ => panic ! ( "expected #[soa_derive = \" Traits, To, Derive\" ], got #[{}]" , quote!( #meta) )
3837 }
3938 }
4039 }
0 commit comments