@@ -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 ,
@@ -75,7 +75,13 @@ impl<'a> RpcMethod<'a> {
7575 }
7676 FnArg :: Typed ( pat_type) => {
7777 let ident = match & * pat_type. pat {
78- Pat :: Ident ( ty) => & ty. ident ,
78+ Pat :: Ident ( ty) => {
79+ let fn_arg = rename_all
80+ . as_ref ( )
81+ . map ( |r| r. rename ( & ty. ident . to_string ( ) ) )
82+ . unwrap_or ( ty. ident . to_string ( ) ) ;
83+ Ident :: new ( & fn_arg, ty. span ( ) . clone ( ) )
84+ }
7985 _ => panic ! ( "Arguments must not be patterns." ) ,
8086 } ;
8187 args. push ( ( ident, & * pat_type. ty ) ) ;
@@ -120,6 +126,7 @@ impl<'a> RpcMethod<'a> {
120126 let tokens = quote ! {
121127 #[ derive( Debug , :: serde:: Serialize , :: serde:: Deserialize ) ]
122128 #[ allow( non_camel_case_types) ]
129+ #[ allow( non_snake_case) ]
123130 struct #args_struct_ident {
124131 #( #struct_fields) *
125132 }
@@ -213,6 +220,7 @@ impl<'a> RpcMethod<'a> {
213220 } ;
214221
215222 quote ! {
223+ #[ allow( non_snake_case) ]
216224 async fn #method_ident( & mut self , #( #method_args) , * ) #output {
217225 let args = #args_struct_ident {
218226 #( #struct_fields) , *
0 commit comments