@@ -5,7 +5,7 @@ use darling::FromMeta;
55use heck:: { ToKebabCase , ToLowerCamelCase , ToShoutySnakeCase , ToSnakeCase , ToUpperCamelCase } ;
66use proc_macro2:: { Literal , TokenStream } ;
77use quote:: { format_ident, quote} ;
8- use syn:: { Attribute , FnArg , Ident , Pat , Signature , Type } ;
8+ use syn:: { spanned :: Spanned , Attribute , FnArg , Ident , Pat , Signature , Type } ;
99
1010use proxy:: proxy_macro;
1111use service:: service_macro;
@@ -51,7 +51,7 @@ impl MethodAttributes {
5151
5252pub ( crate ) struct RpcMethod < ' a > {
5353 signature : & ' a Signature ,
54- args : Vec < ( & ' a Ident , & ' a Type ) > ,
54+ args : Vec < ( Ident , & ' a Type ) > ,
5555 method_name : String ,
5656 method_name_literal : Literal ,
5757 args_struct_ident : Ident ,
@@ -67,6 +67,7 @@ impl<'a> RpcMethod<'a> {
6767 ) -> Self {
6868 let mut has_self = false ;
6969 let mut args = vec ! [ ] ;
70+ let rename_all = rename_all. as_ref ( ) ;
7071
7172 for arg in & signature. inputs {
7273 match arg {
@@ -75,7 +76,12 @@ impl<'a> RpcMethod<'a> {
7576 }
7677 FnArg :: Typed ( pat_type) => {
7778 let ident = match & * pat_type. pat {
78- Pat :: Ident ( ty) => & ty. ident ,
79+ Pat :: Ident ( ty) => {
80+ let fn_arg = rename_all
81+ . map ( |r| r. rename ( & ty. ident . to_string ( ) ) )
82+ . unwrap_or ( ty. ident . to_string ( ) ) ;
83+ Ident :: new ( & fn_arg, ty. span ( ) )
84+ }
7985 _ => panic ! ( "Arguments must not be patterns." ) ,
8086 } ;
8187 args. push ( ( ident, & * pat_type. ty ) ) ;
@@ -92,7 +98,6 @@ impl<'a> RpcMethod<'a> {
9298
9399 let method_name = signature. ident . to_string ( ) ;
94100 let method_name = rename_all
95- . as_ref ( )
96101 . map ( |r| r. rename ( & method_name) )
97102 . unwrap_or ( method_name) ;
98103 let method_name_literal = Literal :: string ( & method_name) ;
@@ -120,6 +125,7 @@ impl<'a> RpcMethod<'a> {
120125 let tokens = quote ! {
121126 #[ derive( Debug , :: serde:: Serialize , :: serde:: Deserialize ) ]
122127 #[ allow( non_camel_case_types) ]
128+ #[ allow( non_snake_case) ]
123129 struct #args_struct_ident {
124130 #( #struct_fields) *
125131 }
@@ -213,6 +219,7 @@ impl<'a> RpcMethod<'a> {
213219 } ;
214220
215221 quote ! {
222+ #[ allow( non_snake_case) ]
216223 async fn #method_ident( & mut self , #( #method_args) , * ) #output {
217224 let args = #args_struct_ident {
218225 #( #struct_fields) , *
0 commit comments