1- use syn:: { Data , DeriveInput , Fields , FieldsNamed } ;
2- use syn:: { Lit , Meta } ;
1+ use syn:: { Data , DeriveInput , ExprLit , Fields , FieldsNamed , Lit } ;
2+ use syn:: { Expr , Meta } ;
33
44/// Parses the tokens_input to a DeriveInput and returns the struct name from which it derives and
55/// the named fields
@@ -22,37 +22,37 @@ pub(crate) fn parse_named_fields<'a>(
2222pub ( crate ) fn get_path ( input : & DeriveInput ) -> Result < proc_macro2:: TokenStream , syn:: Error > {
2323 let mut this_path: Option < proc_macro2:: TokenStream > = None ;
2424 for attr in input. attrs . iter ( ) {
25- if !attr. path . is_ident ( "scylla_crate" ) {
25+ if !attr. path ( ) . is_ident ( "scylla_crate" ) {
2626 continue ;
2727 }
28- match attr. parse_meta ( ) {
29- Ok ( Meta :: NameValue ( meta_name_value) ) => {
30- if let Lit :: Str ( lit_str) = & meta_name_value. lit {
31- let path_val = & lit_str. value ( ) . parse :: < proc_macro2:: TokenStream > ( ) . unwrap ( ) ;
28+ match & attr. meta {
29+ Meta :: NameValue ( name_value) => {
30+ if let Expr :: Lit ( ExprLit {
31+ lit : Lit :: Str ( lit) , ..
32+ } ) = & name_value. value
33+ {
34+ let path = syn:: Ident :: new ( & lit. value ( ) , lit. span ( ) ) ;
3235 if this_path. is_none ( ) {
33- this_path = Some ( quote:: quote!( #path_val :: _macro_internal) ) ;
36+ this_path = Some ( quote:: quote!( #path :: _macro_internal) ) ;
3437 } else {
3538 return Err ( syn:: Error :: new_spanned (
36- & meta_name_value . lit ,
39+ & name_value . path ,
3740 "the `scylla_crate` attribute was set multiple times" ,
3841 ) ) ;
3942 }
4043 } else {
4144 return Err ( syn:: Error :: new_spanned (
42- & meta_name_value . lit ,
45+ & name_value . value ,
4346 "the `scylla_crate` attribute should be a string literal" ,
4447 ) ) ;
4548 }
4649 }
47- Ok ( other) => {
50+ other => {
4851 return Err ( syn:: Error :: new_spanned (
4952 other,
5053 "the `scylla_crate` attribute have a single value" ,
5154 ) ) ;
5255 }
53- Err ( err) => {
54- return Err ( err) ;
55- }
5656 }
5757 }
5858 Ok ( this_path. unwrap_or_else ( || quote:: quote!( scylla:: _macro_internal) ) )
0 commit comments